- java.lang.Object
-
- javafx.geometry.Point3D
-
public class Point3D extends Object
A 3D geometric point that usually represents the x, y, z coordinates. It can also represent a relative magnitude vector's x, y, z magnitudes.- Since:
- JavaFX 2.0
-
-
Constructor Summary
Constructors Constructor Description Point3D(double x, double y, double z)
Creates a new instance ofPoint3D
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Point3D
add(double x, double y, double z)
Returns a point with the specified coordinates added to the coordinates of this point.Point3D
add(Point3D point)
Returns a point with the coordinates of the specified point added to the coordinates of this point.double
angle(double x, double y, double z)
Computes the angle (in degrees) between the vector represented by this point and the specified vector.double
angle(Point3D point)
Computes the angle (in degrees) between the vector represented by this point and the vector represented by the specified point.double
angle(Point3D p1, Point3D p2)
Computes the angle (in degrees) between the three points with this point as a vertex.Point3D
crossProduct(double x, double y, double z)
Computes cross product of the vector represented by this instance and the specified vector.Point3D
crossProduct(Point3D vector)
Computes cross product of the vector represented by this instance and the specified vector.double
distance(double x1, double y1, double z1)
Computes the distance between this point and point(x1, y1, z1)
.double
distance(Point3D point)
Computes the distance between this point and the specifiedpoint
.double
dotProduct(double x, double y, double z)
Computes dot (scalar) product of the vector represented by this instance and the specified vector.double
dotProduct(Point3D vector)
Computes dot (scalar) product of the vector represented by this instance and the specified vector.boolean
equals(Object obj)
Returns a hash code value for the point.double
getX()
The x coordinate.double
getY()
The y coordinate.double
getZ()
The z coordinate.int
hashCode()
Returns a hash code for thisPoint3D
object.double
magnitude()
Computes magnitude (length) of the relative magnitude vector represented by this instance.Point3D
midpoint(double x, double y, double z)
Returns a point which lies in the middle between this point and the specified coordinates.Point3D
midpoint(Point3D point)
Returns a point which lies in the middle between this point and the specified point.Point3D
multiply(double factor)
Returns a point with the coordinates of this point multiplied by the specified factorPoint3D
normalize()
Normalizes the relative magnitude vector represented by this instance.Point3D
subtract(double x, double y, double z)
Returns a point with the specified coordinates subtracted from the coordinates of this point.Point3D
subtract(Point3D point)
Returns a point with the coordinates of the specified point subtracted from the coordinates of this point.String
toString()
Returns a string representation of thisPoint3D
.
-
-
-
Field Detail
-
ZERO
public static final Point3D ZERO
Point or vector with all three coordinates set to 0.
-
-
Method Detail
-
getX
public final double getX()
The x coordinate.- Returns:
- the x coordinate
-
getY
public final double getY()
The y coordinate.- Returns:
- the y coordinate
-
getZ
public final double getZ()
The z coordinate.- Returns:
- the z coordinate
-
distance
public double distance(double x1, double y1, double z1)
Computes the distance between this point and point(x1, y1, z1)
.- Parameters:
x1
- the x coordinate of other pointy1
- the y coordinate of other pointz1
- the z coordinate of other point- Returns:
- the distance between this point and point
(x1, y1, z1)
.
-
distance
public double distance(Point3D point)
Computes the distance between this point and the specifiedpoint
.- Parameters:
point
- the other point- Returns:
- the distance between this point and the specified
point
. - Throws:
NullPointerException
- if the specifiedpoint
is null
-
add
public Point3D add(double x, double y, double z)
Returns a point with the specified coordinates added to the coordinates of this point.- Parameters:
x
- the X coordinate additiony
- the Y coordinate additionz
- the Z coordinate addition- Returns:
- the point with added coordinates
- Since:
- JavaFX 8.0
-
add
public Point3D add(Point3D point)
Returns a point with the coordinates of the specified point added to the coordinates of this point.- Parameters:
point
- the point whose coordinates are to be added- Returns:
- the point with added coordinates
- Throws:
NullPointerException
- if the specifiedpoint
is null- Since:
- JavaFX 8.0
-
subtract
public Point3D subtract(double x, double y, double z)
Returns a point with the specified coordinates subtracted from the coordinates of this point.- Parameters:
x
- the X coordinate subtractiony
- the Y coordinate subtractionz
- the Z coordinate subtraction- Returns:
- the point with subtracted coordinates
- Since:
- JavaFX 8.0
-
subtract
public Point3D subtract(Point3D point)
Returns a point with the coordinates of the specified point subtracted from the coordinates of this point.- Parameters:
point
- the point whose coordinates are to be subtracted- Returns:
- the point with subtracted coordinates
- Throws:
NullPointerException
- if the specifiedpoint
is null- Since:
- JavaFX 8.0
-
multiply
public Point3D multiply(double factor)
Returns a point with the coordinates of this point multiplied by the specified factor- Parameters:
factor
- the factor multiplying the coordinates- Returns:
- the point with multiplied coordinates
- Since:
- JavaFX 8.0
-
normalize
public Point3D normalize()
Normalizes the relative magnitude vector represented by this instance. Returns a vector with the same direction and magnitude equal to 1. If this is a zero vector, a zero vector is returned.- Returns:
- the normalized vector represented by a
Point3D
instance - Since:
- JavaFX 8.0
-
midpoint
public Point3D midpoint(double x, double y, double z)
Returns a point which lies in the middle between this point and the specified coordinates.- Parameters:
x
- the X coordinate of the second endpointy
- the Y coordinate of the second endpointz
- the Z coordinate of the second endpoint- Returns:
- the point in the middle
- Since:
- JavaFX 8.0
-
midpoint
public Point3D midpoint(Point3D point)
Returns a point which lies in the middle between this point and the specified point.- Parameters:
point
- the other endpoint- Returns:
- the point in the middle
- Throws:
NullPointerException
- if the specifiedpoint
is null- Since:
- JavaFX 8.0
-
angle
public double angle(double x, double y, double z)
Computes the angle (in degrees) between the vector represented by this point and the specified vector.- Parameters:
x
- the X magnitude of the other vectory
- the Y magnitude of the other vectorz
- the Z magnitude of the other vector- Returns:
- the angle between the two vectors measured in degrees
- Since:
- JavaFX 8.0
-
angle
public double angle(Point3D point)
Computes the angle (in degrees) between the vector represented by this point and the vector represented by the specified point.- Parameters:
point
- the other vector- Returns:
- the angle between the two vectors measured in degrees,
NaN
if any of the two vectors is a zero vector - Throws:
NullPointerException
- if the specifiedpoint
is null- Since:
- JavaFX 8.0
-
angle
public double angle(Point3D p1, Point3D p2)
Computes the angle (in degrees) between the three points with this point as a vertex.- Parameters:
p1
- one pointp2
- other point- Returns:
- angle between the vectors (this, p1) and (this, p2) measured
in degrees,
NaN
if the three points are not different from one another - Throws:
NullPointerException
- if thep1
orp2
is null- Since:
- JavaFX 8.0
-
magnitude
public double magnitude()
Computes magnitude (length) of the relative magnitude vector represented by this instance.- Returns:
- magnitude of the vector
- Since:
- JavaFX 8.0
-
dotProduct
public double dotProduct(double x, double y, double z)
Computes dot (scalar) product of the vector represented by this instance and the specified vector.- Parameters:
x
- the X magnitude of the other vectory
- the Y magnitude of the other vectorz
- the Z magnitude of the other vector- Returns:
- the dot product of the two vectors
- Since:
- JavaFX 8.0
-
dotProduct
public double dotProduct(Point3D vector)
Computes dot (scalar) product of the vector represented by this instance and the specified vector.- Parameters:
vector
- the other vector- Returns:
- the dot product of the two vectors
- Throws:
NullPointerException
- if the specifiedvector
is null- Since:
- JavaFX 8.0
-
crossProduct
public Point3D crossProduct(double x, double y, double z)
Computes cross product of the vector represented by this instance and the specified vector.- Parameters:
x
- the X magnitude of the other vectory
- the Y magnitude of the other vectorz
- the Z magnitude of the other vector- Returns:
- the cross product of the two vectors
- Since:
- JavaFX 8.0
-
crossProduct
public Point3D crossProduct(Point3D vector)
Computes cross product of the vector represented by this instance and the specified vector.- Parameters:
vector
- the other vector- Returns:
- the cross product of the two vectors
- Throws:
NullPointerException
- if the specifiedvector
is null- Since:
- JavaFX 8.0
-
equals
public boolean equals(Object obj)
Returns a hash code value for the point.- Overrides:
equals
in classObject
- Parameters:
obj
- the reference object with which to compare.- Returns:
- a hash code value for the point.
- See Also:
Object.hashCode()
,HashMap
-
hashCode
public int hashCode()
Returns a hash code for thisPoint3D
object.- Overrides:
hashCode
in classObject
- Returns:
- a hash code for this
Point3D
object. - See Also:
Object.equals(java.lang.Object)
,System.identityHashCode(java.lang.Object)
-
toString
public String toString()
Returns a string representation of thisPoint3D
. This method is intended to be used only for informational purposes. The content and format of the returned string might vary between implementations. The returned string might be empty but cannot benull
.
-
-