Class Point2D
java.lang.Object
javafx.geometry.Point2D
- All Implemented Interfaces:
- Interpolatable<Point2D>
A 2D geometric point that usually represents the x, y coordinates.
 It can also represent a relative magnitude vector's x, y magnitudes.
- Since:
- JavaFX 2.0
- 
Field SummaryFields
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionadd(double x, double y) Returns a point with the specified coordinates added to the coordinates of this point.Returns a point with the coordinates of the specified point added to the coordinates of this point.doubleangle(double x, double y) Computes the angle (in degrees) between the vector represented by this point and the specified vector.doubleComputes the angle (in degrees) between the vector represented by this point and the vector represented by the specified point.doubleComputes the angle (in degrees) between the three points with this point as a vertex.crossProduct(double x, double y) Computes cross product of the vector represented by this instance and the specified vector.crossProduct(Point2D vector) Computes cross product of the vector represented by this instance and the specified vector.doubledistance(double x1, double y1) Computes the distance between this point and point(x1, y1).doubleComputes the distance between this point and the specifiedpoint.doubledotProduct(double x, double y) Computes dot (scalar) product of the vector represented by this instance and the specified vector.doubledotProduct(Point2D vector) Computes dot (scalar) product of the vector represented by this instance and the specified vector.booleanIndicates whether some other object is "equal to" this one.final doublegetX()The x coordinate.final doublegetY()The y coordinate.inthashCode()Returns a hash code value for the point.interpolate(Point2D endValue, double t) Returns an intermediate value between the value of thisInterpolatableand the specifiedendValueusing the linear interpolation factort.doubleComputes magnitude (length) of the relative magnitude vector represented by this instance.midpoint(double x, double y) Returns a point which lies in the middle between this point and the specified coordinates.Returns a point which lies in the middle between this point and the specified point.multiply(double factor) Returns a point with the coordinates of this point multiplied by the specified factorNormalizes the relative magnitude vector represented by this instance.subtract(double x, double y) Returns a point with the specified coordinates subtracted from the coordinates of this point.Returns a point with the coordinates of the specified point subtracted from the coordinates of this point.toString()Returns a string representation of thisPoint2D.
- 
Field Details- 
ZEROPoint or vector with both coordinates set to 0.
 
- 
- 
Constructor Details- 
Point2Dpublic Point2D(double x, double y) Creates a new instance ofPoint2D.- Parameters:
- x- the x coordinate of the point
- y- the y coordinate of the point
 
 
- 
- 
Method Details- 
getX
- 
getY
- 
distancepublic double distance(double x1, double y1) Computes the distance between this point and point(x1, y1).- Parameters:
- x1- the x coordinate of other point
- y1- the y coordinate of other point
- Returns:
- the distance between this point and point (x1, y1).
 
- 
distanceComputes 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 specified- pointis null
 
- 
addReturns a point with the specified coordinates added to the coordinates of this point.- Parameters:
- x- the X coordinate addition
- y- the Y coordinate addition
- Returns:
- the point with added coordinates
- Since:
- JavaFX 8.0
 
- 
addReturns 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 specified- pointis null
- Since:
- JavaFX 8.0
 
- 
subtractReturns a point with the specified coordinates subtracted from the coordinates of this point.- Parameters:
- x- the X coordinate subtraction
- y- the Y coordinate subtraction
- Returns:
- the point with subtracted coordinates
- Since:
- JavaFX 8.0
 
- 
multiplyReturns 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
 
- 
subtractReturns 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 specified- pointis null
- Since:
- JavaFX 8.0
 
- 
normalizeNormalizes 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 Point2Dinstance
- Since:
- JavaFX 8.0
 
- 
midpointReturns a point which lies in the middle between this point and the specified coordinates.- Parameters:
- x- the X coordinate of the second endpoint
- y- the Y coordinate of the second endpoint
- Returns:
- the point in the middle
- Since:
- JavaFX 8.0
 
- 
midpointReturns 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 specified- pointis null
- Since:
- JavaFX 8.0
 
- 
anglepublic double angle(double x, double y) Computes the angle (in degrees) between the vector represented by this point and the specified vector.- Parameters:
- x- the X magnitude of the other vector
- y- the Y magnitude of the other vector
- Returns:
- the angle between the two vectors measured in degrees
- Since:
- JavaFX 8.0
 
- 
angleComputes 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,
         NaNif any of the two vectors is a zero vector
- Throws:
- NullPointerException- if the specified- pointis null
- Since:
- JavaFX 8.0
 
- 
angleComputes the angle (in degrees) between the three points with this point as a vertex.- Parameters:
- p1- one point
- p2- other point
- Returns:
- angle between the vectors (this, p1) and (this, p2) measured
         in degrees, NaNif the three points are not different from one another
- Throws:
- NullPointerException- if- p1or- p2is null
- Since:
- JavaFX 8.0
 
- 
magnitudepublic double magnitude()Computes magnitude (length) of the relative magnitude vector represented by this instance.- Returns:
- magnitude of the vector
- Since:
- JavaFX 8.0
 
- 
dotProductpublic double dotProduct(double x, double y) Computes dot (scalar) product of the vector represented by this instance and the specified vector.- Parameters:
- x- the X magnitude of the other vector
- y- the Y magnitude of the other vector
- Returns:
- the dot product of the two vectors
- Since:
- JavaFX 8.0
 
- 
dotProductComputes 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 specified- vectoris null
- Since:
- JavaFX 8.0
 
- 
crossProductComputes cross product of the vector represented by this instance and the specified vector.- Parameters:
- x- the X magnitude of the other vector
- y- the Y magnitude of the other vector
- Returns:
- the cross product of the two vectors
- Since:
- JavaFX 8.0
 
- 
crossProductComputes 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 specified- vectoris null
- Since:
- JavaFX 8.0
 
- 
interpolateReturns an intermediate value between the value of thisInterpolatableand the specifiedendValueusing the linear interpolation factort. The interpolation factor can be any finite value.The returned value might not be a new instance; the implementation might also return one of the two existing instances if the intermediate value would be equal to one of the existing values. However, this is an optimization and applications should not assume any particular identity of the returned value. - Specified by:
- interpolatein interface- Interpolatable<Point2D>
- Parameters:
- endValue- the target value
- t- the interpolation factor
- Returns:
- the intermediate value
- Throws:
- NullPointerException- if- endValueis- null
- Since:
- 13
 
- 
equals
- 
hashCode
- 
toStringReturns a string representation of thisPoint2D. 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.
 
-