Package one.empty3.library
Class Point3D
java.lang.Object
one.empty3.library.Representable
one.empty3.library.Point3D
- All Implemented Interfaces:
Serializable
,Comparable
,TemporalComputedObject3D
,MatrixPropertiesObject
,XmlRepresentable
- Direct Known Subclasses:
Bille
,Gravity
,POINT3D_RIO
,Point3D.P
,RtVector3D
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:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Point3D
Represents a constant point in 3D space.static final Point3D
Represents a constant point in 3D space.static final Point3D
Represents a constant point in 3D space.static final Point3D
Represents a constant point in 3D space.static final Point3D
Represents a constant point in 3D space.Fields inherited from class one.empty3.library.Representable
CFAST, classPainters, DEFAULT_TEXTURE, defaultHashMapData, DISPLAY_ALL, NFAST, parent, PATH_ELEM_DOUBLE_VALUES, PATH_ELEM_REPRESENTABLE, PATH_ELEM_STRUCTURE_MATRIX, render, rotation, SCALE1, scene, SURFACE_DISPLAY_COL_QUADS, SURFACE_DISPLAY_COL_TRI, SURFACE_DISPLAY_LINES, SURFACE_DISPLAY_POINTS, SURFACE_DISPLAY_TEXT_QUADS, T, texture, vectors
-
Constructor Summary
ConstructorsConstructorDescriptionPoint3D()
Point3D
(double[] x0) Represents a three-dimensional point with coordinates (x, y, z).Point3D
(int n) Creates a Point3D object with the specified length.Represents a three-dimensional point with coordinates (x, y, z).Represents a three-dimensional point with coordinates (x, y, z) and an associated texture.Represents a three-dimensional point with coordinates (x, y, z) and an associated texture.Creates a new Point3D object by copying the coordinates of another Point3D object.Point3D
(StructureMatrix<Double> coordArr) Represents a three-dimensional point with coordinates (x, y, z) initialized from a object. -
Method Summary
Modifier and TypeMethodDescriptioncalculerPoint0dT
(double t) Changes the coordinates and texture of this Point3D to the coordinates and texture of the given Point3D.static Point3D
circle
(double v) Generates a point on a circle given a parameter value.clone()
void
Declares the properties of the Representable class.static Double
Calculates the Euclidean distance between two 3D points.Calculates the dot product between this point and the given point.void
Draws the structure quickly using the given ZBuffer.static void
end()
boolean
static Point3D
Converts a Color object to a Point3D object.get
(int i) Retrieves the element at the specified index from the coordArr array.get2D()
Returns a Point2D object representing the two-dimensional coordinates.Retrieves the coordinate array as aRetrieves an array of doubles.double
Returns the length of the vector.getTempx()
getTempy()
getTempz()
getX()
Retrieves the X-coordinate value.getY()
Retrieves the y-coordinate value of a point.getZ()
Retrieves the Z-coordinate from the coordinate array.Checks if this Representable intersects with the given Representable.boolean
isAnyNaN()
Checks if any element in the coordArr array is NaN.boolean
Checks if the structure is drawn fast.Returns a new Point3D object that represents the difference between the current point and the provided point.mult
(double d) Multiplies each coordinate of the Point3D by the given value.Multiplies the coordinates of the current Point3D object by the given scaling factor.Multiplies each coordinate of the current Point3D object with the corresponding coordinate of the specified Point3D object.Multiplies the coordinates of two points element-wise.static Point3D
n
(double x, double y, double z) Creates a new Point3D object with the given x, y, and z coordinates.static Point3D
Creates a new Point3D object with the given coordinates.static Point3D
Creates a new Point3D object with the same coordinates as the input point.void
Normalizes the vector by dividing each element by its norm.norme()
Calculates the norm of the vector.norme1()
Calculates the normalized vector of this Point3D object.Calculates the square of the norm of a vector represented by an array of coordinates.Adds the given value to each coordinate of this point and returns a new Point3D object.Calculates the vector sum of this point and the given point.prodScalaire
(Point3D p2) Calculates the dot product between this point and the given point.Calculates the cross product between this point and the given point.static Point3D
Generates a random Point3D object with coordinates in the range [-0.5, 0.5].static Point3D
Generates a random Point3D object with coordinates in the range [-0.5, 0.5].static Point3D
Generates a random Point3D object with coordinates in the range [-0.5, 0.5].static Point3D
Generates a random 3D point with coordinates in the range [-0.5, 0.5] multiplied by the scaling factor.void
Deprecated.void
Sets the value of the element at the specified index in the coordArr array.void
setCoordArr
(StructureMatrix<Double> coordArr) Sets the coordinate array.void
void
void
void
void
Sets the x-coordinate value.void
Sets the Y coordinate of the point.void
Sets the Z-coordinate value of the coordinate array.static Point3D
sphere
(double v, double v1) Generates a point on a sphere given two parameter values.static void
start()
void
textureIndex
(Double tempx, Double tempy, Double tempz) Sets the texture index for the object based on the given coordinates.to2DwoZ()
Returns a Point2D object representing the two-dimensional point without the z-coordinate.static double[]
Convert a Point3D object to a one-dimensional double array.toColor()
Converts the current object to a Color object.Converts the coordinates and texture of the object to a formatted long string representation.toString()
Returns a string representation of the object.Methods inherited from class one.empty3.library.Representable
become, calculerCurveT, calculerPointT, calculerSurfaceT, compareTo, computeCubic, computeSpherical, copy, declarations, draw, getCFAST, getDeclaredDataStructure, getDeclaredLists, getDeclaredProperty, getDisplayType, getDisplayTypes, getOrientedPoint, getOrig, getPainter, getPath, getProperty, getPropertyType, getRotation, getTexture, getVectors, getVectX, getVectY, getVectZ, id, id, informer, intersects, paint, refPoint, replace, rotate, setAxes, setCFAST, setDisplayType, setOrig, setPainter, setPaintingAct, setPaintingActForClass, setPosition, setProperty, setRotation, setTexture, setVectX, setVectY, setVectZ, supporteTexture, T, texture, texture, xmlRepresentation, xmlRepresentation, xmlRepresentation, xmlRepresentation, xmlRepresentation, xmlRepresentation, xmlRepresentation, xmlRepresentation, xmlRepresentation, xmlRepresentation
-
Field Details
-
X
Represents a constant point in 3D space. -
Y
Represents a constant point in 3D space. -
Z
Represents a constant point in 3D space. -
O0
Represents a constant point in 3D space. -
INFINI
Represents a constant point in 3D space.
-
-
Constructor Details
-
Point3D
public Point3D() -
Point3D
Represents a three-dimensional point with coordinates (x, y, z) and an associated texture.- Parameters:
x0
- The x-coordinate of the pointy0
- The y-coordinate of the pointz0
- The z-coordinate of the pointt
- 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
Represents a three-dimensional point with coordinates (x, y, z).- Parameters:
x0
- The x-coordinate of the point
-
Point3D
Represents a three-dimensional point with coordinates (x, y, z) and an associated texture.- Parameters:
x0
- The x-coordinate of the pointt
- 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
Creates a new Point3D object by copying the coordinates of another Point3D object.- Parameters:
p0
- The Point3D object to be copied
-
Point3D
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
Creates a new Point3D object with the given coordinates.- Parameters:
a
- The x-coordinate of the pointb
- The y-coordinate of the pointc
- The z-coordinate of the point- Returns:
- A new Point3D object with the specified coordinates
-
n
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
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
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
Generates a random Point3D object with coordinates in the range [-0.5, 0.5].- Parameters:
d
- The scaling factor to apply on the generated coordinatesn
- 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
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
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
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
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
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
-
get
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
Retrieves an array of doubles.- Returns:
- a List of doubles representing the array of doubles.
-
getY
Retrieves the y-coordinate value of a point.- Returns:
- The y-coordinate value of the point as a Double.
-
setY
Sets the Y coordinate of the point.- Parameters:
x0
- the new Y coordinate value
-
getZ
Retrieves the Z-coordinate from the coordinate array.- Returns:
- the Z-coordinate value
-
setZ
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
Retrieves the X-coordinate value.- Returns:
- the X-coordinate value
-
setX
Sets the x-coordinate value.- Parameters:
x0
- the new x-coordinate value to be set
-
plus
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
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
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
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
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
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
Calculates the norm of the vector.- Returns:
- the norm of the vector as a Double value
-
norme1
Calculates the normalized vector of this Point3D object.- Returns:
- The normalized Point3D object.
-
plus
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
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
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
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
Sets the value of the element at the specified index in the coordArr array.- Parameters:
i
- the index of the element to be setd
- the new value for the element at the specified index
-
toLongString
Converts the coordinates and texture of the object to a formatted long string representation.- Returns:
- The long string representation of the object.
-
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 classRepresentable
- Returns:
- a string representation of the object.
-
ISdrawStructureDrawFastIMPLEMENTED
Checks if the structure is drawn fast.- Overrides:
ISdrawStructureDrawFastIMPLEMENTED
in classRepresentable
- Parameters:
z
- The z-buffer used for drawing the structure.- Returns:
- true if the structure is drawn fast, false otherwise.
-
drawStructureDrawFast
Draws the structure quickly using the given ZBuffer.- Overrides:
drawStructureDrawFast
in classRepresentable
- Parameters:
z
- the ZBuffer object used for rendering the structure
-
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
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
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
Checks if this Representable intersects with the given Representable.- Overrides:
intersects
in classRepresentable
- Parameters:
r2
- the Representable to check for intersection- Returns:
- the intersecting Representable if it exists, otherwise null
-
changeTo
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
Creates a new Point3D object with the given x, y, and z coordinates.- Parameters:
x
- the x-coordinate of the pointy
- the y-coordinate of the pointz
- 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
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
-
setNormale
-
equals
-
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 interfaceMatrixPropertiesObject
- Overrides:
declareProperties
in classRepresentable
-
getCoordArr
Retrieves the coordinate array as a- Returns:
- a containing the coordinate array
-
setCoordArr
Sets the coordinate array.- Parameters:
coordArr
- the structure matrix representing the coordinates
-
calculerPoint0dT
-
toColor
Converts the current object to a Color object.- Returns:
- The Color object representing the RGB values of the current object.
-
fromColor
Converts a Color object to a Point3D object.- Parameters:
color
- the Color object to convert- Returns:
- a Point3D object representing the color components
-
getTempz
-
setTempz
-
getTempy
-
setTempy
-
getTempx
-
setTempx
-
rotate
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 rotatedref
- the reference point around which the rotation occursaxe
- the axis used for rotation
-