Class Point3D

All Implemented Interfaces:
Serializable, Comparable, TemporalComputedObject3D, MatrixPropertiesObject, XmlRepresentable
Direct Known Subclasses:
Bille, Gravity, POINT3D_RIO, Point3D.P, RtVector3D

public class Point3D extends Representable
The Point3D class represents a point in a three-dimensional space. It provides methods to perform various operations on points. Classe pour les éléments à trois coordonnées de type Double Points, Vecteur 3D et calcul
See Also:
  • Field Details

    • X

      public static final Point3D X
      Represents a constant point in 3D space.
    • Y

      public static final Point3D Y
      Represents a constant point in 3D space.
    • Z

      public static final Point3D Z
      Represents a constant point in 3D space.
    • O0

      public static final Point3D O0
      Represents a constant point in 3D space.
    • INFINI

      public static final Point3D INFINI
      Represents a constant point in 3D space.
  • Constructor Details

    • Point3D

      public Point3D()
    • Point3D

      public Point3D(Double x0, Double y0, Double z0, ITexture t)
      Represents a three-dimensional point with coordinates (x, y, z) and an associated texture.
      Parameters:
      x0 - The x-coordinate of the point
      y0 - The y-coordinate of the point
      z0 - The z-coordinate of the point
      t - The texture associated with the point
    • Point3D

      public Point3D(double[] x0)
      Represents a three-dimensional point with coordinates (x, y, z).
      Parameters:
      x0 - The x-coordinate of the point
    • Point3D

      public Point3D(Double... x0)
      Represents a three-dimensional point with coordinates (x, y, z).
      Parameters:
      x0 - The x-coordinate of the point
    • Point3D

      public Point3D(Double[] x0, ITexture t)
      Represents a three-dimensional point with coordinates (x, y, z) and an associated texture.
      Parameters:
      x0 - The x-coordinate of the point
      t - The texture associated with the point
    • Point3D

      public Point3D(int n)
      Creates a Point3D object with the specified length.
      Parameters:
      n - The length of the Point3D object
    • Point3D

      public Point3D(@NotNull @NotNull Point3D p0)
      Creates a new Point3D object by copying the coordinates of another Point3D object.
      Parameters:
      p0 - The Point3D object to be copied
    • Point3D

      public Point3D(StructureMatrix<Double> coordArr)
      Represents a three-dimensional point with coordinates (x, y, z) initialized from a object.
      Parameters:
      coordArr - An object containing the coordinates of the point in the order [x, y, z].
  • Method Details

    • start

      public static void start()
    • end

      public static void end()
    • n

      public static Point3D n(Double a, Double b, Double c)
      Creates a new Point3D object with the given coordinates.
      Parameters:
      a - The x-coordinate of the point
      b - The y-coordinate of the point
      c - The z-coordinate of the point
      Returns:
      A new Point3D object with the specified coordinates
    • n

      public static Point3D n(Point3D p)
      Creates a new Point3D object with the same coordinates as the input point.
      Parameters:
      p - The Point3D object from which the coordinates will be copied
      Returns:
      A new Point3D object with the same coordinates as p
    • distance

      public static Double distance(Point3D p1, Point3D p2)
      Calculates the Euclidean distance between two 3D points.
      Parameters:
      p1 - The first 3D point.
      p2 - The second 3D point.
      Returns:
      The Euclidean distance between p1 and p2.
    • random

      public static Point3D random(Double d)
      Generates a random Point3D object with coordinates in the range [-0.5, 0.5].
      Parameters:
      d - The scaling factor to apply on the generated coordinates
      Returns:
      A new Point3D object with random coordinates multiplied by the scaling factor
    • random

      public static Point3D random(Double d, int n)
      Generates a random Point3D object with coordinates in the range [-0.5, 0.5].
      Parameters:
      d - The scaling factor to apply on the generated coordinates
      n - The number of times the generated coordinates will be multiplied by the scaling factor
      Returns:
      A new Point3D object with random coordinates multiplied by the scaling factor
    • r

      public static Point3D r(Double d)
      Generates a random Point3D object with coordinates in the range [-0.5, 0.5].
      Parameters:
      d - The scaling factor to apply on the generated coordinates
      Returns:
      A new Point3D object with random coordinates multiplied by the scaling factor
    • random2

      public static Point3D random2(Double d)
      Generates a random 3D point with coordinates in the range [-0.5, 0.5] multiplied by the scaling factor.
      Parameters:
      d - The scaling factor to apply on the generated coordinates
      Returns:
      A new Point
    • toArray1d

      public static double[] toArray1d(Point3D norme1, double[] arr)
      Convert a Point3D object to a one-dimensional double array.
      Parameters:
      norme1 - The Point3D object containing the coordinates to be converted.
      arr - The array to store the coordinates. If the length of the array is less than 3, a new array of length 3 will be created.
      Returns:
      The one-dimensional double array containing the coordinates of the Point3D object.
    • circle

      public static Point3D circle(double v)
      Generates a point on a circle given a parameter value.
      Parameters:
      v - The parameter value.
      Returns:
      A Point3D object representing a point on the circle with coordinates (cos(v), sin(v), 0.0).
    • sphere

      public static Point3D sphere(double v, double v1)
      Generates a point on a sphere given two parameter values.
      Parameters:
      v - The first parameter value.
      v1 - The second parameter value.
      Returns:
      A Point3D object representing a point on the sphere with coordinates (cos(v) * sin(v1), sin(v) * sin(v1), cos(v1)).
    • clone

      public Object clone()
      Overrides:
      clone in class Object
    • get

      public Double get(int i)
      Retrieves the element at the specified index from the coordArr array.
      Parameters:
      i - the index of the element to retrieve
      Returns:
      the element at the specified index
    • getDoubleArray

      public List<Double> getDoubleArray()
      Retrieves an array of doubles.
      Returns:
      a List of doubles representing the array of doubles.
    • getY

      public Double getY()
      Retrieves the y-coordinate value of a point.
      Returns:
      The y-coordinate value of the point as a Double.
    • setY

      public void setY(Double x0)
      Sets the Y coordinate of the point.
      Parameters:
      x0 - the new Y coordinate value
    • getZ

      public Double getZ()
      Retrieves the Z-coordinate from the coordinate array.
      Returns:
      the Z-coordinate value
    • setZ

      public void setZ(Double x0)
      Sets the Z-coordinate value of the coordinate array. The Z-coordinate value is stored at index 2 of the coordinate array.
      Parameters:
      x0 - the new Z-coordinate value to set
    • getX

      public Double getX()
      Retrieves the X-coordinate value.
      Returns:
      the X-coordinate value
    • setX

      public void setX(Double x0)
      Sets the x-coordinate value.
      Parameters:
      x0 - the new x-coordinate value to be set
    • plus

      public Point3D plus(Point3D p)
      Calculates the vector sum of this point and the given point.
      Parameters:
      p - the point to be added to this point
      Returns:
      a new Point3D representing the vector sum of this point and the given point
    • moins

      public Point3D moins(Point3D p)
      Returns a new Point3D object that represents the difference between the current point and the provided point. The difference is calculated by subtracting the corresponding coordinates of the provided point from the current point.
      Parameters:
      p - The point to subtract from the current point.
      Returns:
      A new Point3D object representing the difference between the current point and the provided point.
    • mult

      public Point3D mult(Point3D p)
      Multiplies each coordinate of the current Point3D object with the corresponding coordinate of the specified Point3D object. Creates a new Point3D object with the multiplied coordinates and returns it. The current Point3D object remains unchanged.
      Parameters:
      p - The Point3D object to multiply with the current Point3D object.
      Returns:
      A new Point3D object with the multiplied coordinates.
    • multDot

      public Point3D multDot(Point3D p1)
      Multiplies the coordinates of two points element-wise.
      Parameters:
      p1 - The Point3D object to multiply with.
      Returns:
      A new Point3D object with the multiplied coordinates.
    • mult

      public Point3D mult(Double d)
      Multiplies the coordinates of the current Point3D object by the given scaling factor.
      Parameters:
      d - The scaling factor to multiply the coordinates by.
      Returns:
      A new Point3D object with the scaled coordinates.
    • mult

      public Point3D mult(double d)
      Multiplies each coordinate of the Point3D by the given value.
      Parameters:
      d - the value to multiply the coordinates by
      Returns:
      a new Point3D object with the multiplied coordinates
    • norme

      public Double norme()
      Calculates the norm of the vector.
      Returns:
      the norm of the vector as a Double value
    • norme1

      public Point3D norme1()
      Calculates the normalized vector of this Point3D object.
      Returns:
      The normalized Point3D object.
    • plus

      public Point3D plus(Double d)
      Adds the given value to each coordinate of this point and returns a new Point3D object.
      Parameters:
      d - the value to be added to each coordinate
      Returns:
      a new Point3D object with each coordinate incremented by the given value
    • prodScalaire

      public Double prodScalaire(Point3D p2)
      Calculates the dot product between this point and the given point.
      Parameters:
      p2 - the second point in the dot product calculation
      Returns:
      the dot product value as a Double
      Throws:
      NullPointerException - if p2 is null
    • dot

      public Double dot(Point3D p2)
      Calculates the dot product between this point and the given point.
      Parameters:
      p2 - The other point used to calculate the dot product.
      Returns:
      The dot product between this point and the given point.
    • prodVect

      public Point3D prodVect(Point3D p1)
      Calculates the cross product between this point and the given point.
      Parameters:
      p1 - The point to calculate the cross product with.
      Returns:
      The result of the cross product as a new Point3D object.
    • set

      public void set(int i, Double d)
      Sets the value of the element at the specified index in the coordArr array.
      Parameters:
      i - the index of the element to be set
      d - the new value for the element at the specified index
    • toLongString

      public String toLongString()
      Converts the coordinates and texture of the object to a formatted long string representation.
      Returns:
      The long string representation of the object.
    • toString

      public String toString()
      Returns a string representation of the object.

      The returned string contains the coordinates of the point in the format p3(x, y, z), where (x, y, z) are the values of the coordinates.

      Overrides:
      toString in class Representable
      Returns:
      a string representation of the object.
    • ISdrawStructureDrawFastIMPLEMENTED

      public boolean ISdrawStructureDrawFastIMPLEMENTED(ZBuffer z)
      Checks if the structure is drawn fast.
      Overrides:
      ISdrawStructureDrawFastIMPLEMENTED in class Representable
      Parameters:
      z - The z-buffer used for drawing the structure.
      Returns:
      true if the structure is drawn fast, false otherwise.
    • drawStructureDrawFast

      public void drawStructureDrawFast(ZBuffer z)
      Draws the structure quickly using the given ZBuffer.
      Overrides:
      drawStructureDrawFast in class Representable
      Parameters:
      z - the ZBuffer object used for rendering the structure
    • get2D

      public Point2D get2D()
      Returns a Point2D object representing the two-dimensional coordinates.
      Returns:
      a Point2D object representing the two-dimensional coordinates.
    • normalize

      public void normalize()
      Normalizes the vector by dividing each element by its norm.
    • to2DwoZ

      public Point2D to2DwoZ()
      Returns a Point2D object representing the two-dimensional point without the z-coordinate.
      Returns:
      a Point2D object representing the two-dimensional point without the z-coordinate
    • NormeCarree

      public Double NormeCarree()
      Calculates the square of the norm of a vector represented by an array of coordinates.
      Returns:
      The square of the norm of the vector.
    • intersects

      public Representable intersects(Representable r2)
      Checks if this Representable intersects with the given Representable.
      Overrides:
      intersects in class Representable
      Parameters:
      r2 - the Representable to check for intersection
      Returns:
      the intersecting Representable if it exists, otherwise null
    • changeTo

      public Point3D changeTo(Point3D dst)
      Changes the coordinates and texture of this Point3D to the coordinates and texture of the given Point3D.
      Parameters:
      dst - the Point3D object whose coordinates and texture will be copied
      Returns:
      this Point3D object with updated coordinates and texture
    • n

      public static Point3D n(double x, double y, double z)
      Creates a new Point3D object with the given x, y, and z coordinates.
      Parameters:
      x - the x-coordinate of the point
      y - the y-coordinate of the point
      z - the z-coordinate of the point
      Returns:
      a new Point3D object with the specified coordinates
    • getLength

      public double getLength()
      Returns the length of the vector.
      Returns:
      the length of the vector (norm)
    • textureIndex

      public void textureIndex(Double tempx, Double tempy, Double tempz)
      Sets the texture index for the object based on the given coordinates.
      Parameters:
      tempx - The X-coordinate for the texture index.
      tempy - The Y-coordinate for the texture index.
      tempz - The Z-coordinate for the texture index.
    • getNormale

      public Point3D getNormale()
    • setNormale

      public void setNormale(Point3D p)
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • isAnyNaN

      public boolean isAnyNaN()
      Checks if any element in the coordArr array is NaN.
      Returns:
      true if any element in coordArr is NaN, false otherwise
    • declareProperties

      public void declareProperties()
      Description copied from class: Representable
      Declares the properties of the Representable class. This method clears the declaredDataStructure map and adds specific properties to it based on the object's rotation and type. If the object's rotation is not null and the object is not an instance of Point3D, a "rotation/Rotation" property is added. The "vectors/vectors" property is always added to the map.
      Specified by:
      declareProperties in interface MatrixPropertiesObject
      Overrides:
      declareProperties in class Representable
    • getCoordArr

      public StructureMatrix<Double> getCoordArr()
      Retrieves the coordinate array as a
      Returns:
      a containing the coordinate array
    • setCoordArr

      public void setCoordArr(StructureMatrix<Double> coordArr)
      Sets the coordinate array.
      Parameters:
      coordArr - the structure matrix representing the coordinates
    • calculerPoint0dT

      public Point3D calculerPoint0dT(double t)
    • toColor

      public Color toColor()
      Converts the current object to a Color object.
      Returns:
      The Color object representing the RGB values of the current object.
    • fromColor

      public static Point3D fromColor(Color color)
      Converts a Color object to a Point3D object.
      Parameters:
      color - the Color object to convert
      Returns:
      a Point3D object representing the color components
    • getTempz

      public Double getTempz()
    • setTempz

      public void setTempz(Double tempz)
    • getTempy

      public Double getTempy()
    • setTempy

      public void setTempy(Double tempy)
    • getTempx

      public Double getTempx()
    • setTempx

      public void setTempx(Double tempx)
    • rotate

      @Deprecated public void rotate(Point3D point3D, Point3D ref, Point3D axe)
      Deprecated.
      Rotates a Point3D around a reference point using a specified axis. The rotation is performed in-place, meaning the original Point3D object is modified.
      Parameters:
      point3D - the Point3D object to be rotated
      ref - the reference point around which the rotation occurs
      axe - the axis used for rotation