Point2D (Java SE 10 & JDK 10 ) (original) (raw)
- javafx.geometry.Point2D
public class Point2D
extends Object
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 Summary
Fields
Modifier and Type Field Description static Point2D ZERO Point or vector with both coordinates set to 0. Constructor Summary
Constructors
Constructor Description Point2D(double x, double y) Creates a new instance of Point2D. Method Summary
All Methods Instance Methods Concrete Methods
Modifier and Type Method Description Point2D add(double x, double y) Returns a point with the specified coordinates added to the coordinates of this point. Point2D add(Point2D point) Returns a point with the coordinates of the specified point added to the coordinates of this point. double angle(double x, double y) Computes the angle (in degrees) between the vector represented by this point and the specified vector. double angle(Point2D point) Computes the angle (in degrees) between the vector represented by this point and the vector represented by the specified point. double angle(Point2D p1,Point2D p2) Computes the angle (in degrees) between the three points with this point as a vertex. Point3D crossProduct(double x, double y) Computes cross product of the vector represented by this instance and the specified vector. Point3D crossProduct(Point2D vector) Computes cross product of the vector represented by this instance and the specified vector. double distance(double x1, double y1) Computes the distance between this point and point (x1, y1). double distance(Point2D point) Computes the distance between this point and the specified point. double dotProduct(double x, double y) Computes dot (scalar) product of the vector represented by this instance and the specified vector. double dotProduct(Point2D vector) Computes dot (scalar) product of the vector represented by this instance and the specified vector. boolean equals(Object obj) Indicates whether some other object is "equal to" this one. double getX() The x coordinate. double getY() The y coordinate. int hashCode() Returns a hash code value for the point. double magnitude() Computes magnitude (length) of the relative magnitude vector represented by this instance. Point2D midpoint(double x, double y) Returns a point which lies in the middle between this point and the specified coordinates. Point2D midpoint(Point2D point) Returns a point which lies in the middle between this point and the specified point. Point2D multiply(double factor) Returns a point with the coordinates of this point multiplied by the specified factor Point2D normalize() Normalizes the relative magnitude vector represented by this instance. Point2D subtract(double x, double y) Returns a point with the specified coordinates subtracted from the coordinates of this point. Point2D subtract(Point2D 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 this Point2D. * ### Methods declared in class java.lang.[Object](../../java/lang/Object.html "class in java.lang") `[clone](../../java/lang/Object.html#clone%28%29), [finalize](../../java/lang/Object.html#finalize%28%29), [getClass](../../java/lang/Object.html#getClass%28%29), [notify](../../java/lang/Object.html#notify%28%29), [notifyAll](../../java/lang/Object.html#notifyAll%28%29), [wait](../../java/lang/Object.html#wait%28%29), [wait](../../java/lang/Object.html#wait%28long%29), [wait](../../java/lang/Object.html#wait%28long,int%29)`
Field Detail
* #### ZERO public static final [Point2D](../../javafx/geometry/Point2D.html "class in javafx.geometry") ZERO Point or vector with both coordinates set to 0.
Constructor Detail
* #### Point2D public Point2D(double x, double y) Creates a new instance of `Point2D`. Parameters: `x` \- the x coordinate of the point `y` \- the y coordinate of the point
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 * #### distance public 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)`. * #### distance public double distance([Point2D](../../javafx/geometry/Point2D.html "class in javafx.geometry") point) Computes the distance between this point and the specified `point`. Parameters: `point` \- the other point Returns: the distance between this point and the specified `point`. Throws: `[NullPointerException](../../java/lang/NullPointerException.html "class in java.lang")` \- if the specified `point` is null * #### add public [Point2D](../../javafx/geometry/Point2D.html "class in javafx.geometry") add(double x, double y) Returns 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 * #### add public [Point2D](../../javafx/geometry/Point2D.html "class in javafx.geometry") add([Point2D](../../javafx/geometry/Point2D.html "class in javafx.geometry") 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](../../java/lang/NullPointerException.html "class in java.lang")` \- if the specified `point` is null Since: JavaFX 8.0 * #### subtract public [Point2D](../../javafx/geometry/Point2D.html "class in javafx.geometry") subtract(double x, double y) Returns 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 * #### multiply public [Point2D](../../javafx/geometry/Point2D.html "class in javafx.geometry") 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 * #### subtract public [Point2D](../../javafx/geometry/Point2D.html "class in javafx.geometry") subtract([Point2D](../../javafx/geometry/Point2D.html "class in javafx.geometry") 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](../../java/lang/NullPointerException.html "class in java.lang")` \- if the specified `point` is null Since: JavaFX 8.0 * #### normalize public [Point2D](../../javafx/geometry/Point2D.html "class in javafx.geometry") 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 `Point2D` instance Since: JavaFX 8.0 * #### midpoint public [Point2D](../../javafx/geometry/Point2D.html "class in javafx.geometry") midpoint(double x, double y) Returns 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 * #### midpoint public [Point2D](../../javafx/geometry/Point2D.html "class in javafx.geometry") midpoint([Point2D](../../javafx/geometry/Point2D.html "class in javafx.geometry") 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](../../java/lang/NullPointerException.html "class in java.lang")` \- if the specified `point` is null Since: JavaFX 8.0 * #### angle public 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 * #### angle public double angle([Point2D](../../javafx/geometry/Point2D.html "class in javafx.geometry") 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](../../java/lang/NullPointerException.html "class in java.lang")` \- if the specified `point` is null Since: JavaFX 8.0 * #### angle public double angle([Point2D](../../javafx/geometry/Point2D.html "class in javafx.geometry") p1, [Point2D](../../javafx/geometry/Point2D.html "class in javafx.geometry") p2) Computes 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, `NaN` if the three points are not different from one another Throws: `[NullPointerException](../../java/lang/NullPointerException.html "class in java.lang")` \- if `p1` or `p2` 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) 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 * #### dotProduct public double dotProduct([Point2D](../../javafx/geometry/Point2D.html "class in javafx.geometry") 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](../../java/lang/NullPointerException.html "class in java.lang")` \- if the specified `vector` is null Since: JavaFX 8.0 * #### crossProduct public [Point3D](../../javafx/geometry/Point3D.html "class in javafx.geometry") crossProduct(double x, double y) Computes 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 * #### crossProduct public [Point3D](../../javafx/geometry/Point3D.html "class in javafx.geometry") crossProduct([Point2D](../../javafx/geometry/Point2D.html "class in javafx.geometry") 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](../../java/lang/NullPointerException.html "class in java.lang")` \- if the specified `vector` is null Since: JavaFX 8.0 * #### equals public boolean equals([Object](../../java/lang/Object.html "class in java.lang") obj) Indicates whether some other object is "equal to" this one. Overrides: `[equals](../../java/lang/Object.html#equals%28java.lang.Object%29)` in class `[Object](../../java/lang/Object.html "class in java.lang")` Parameters: `obj` \- the reference object with which to compare Returns: true if this point is the same as the obj argument; false otherwise See Also: [Object.hashCode()](../../java/lang/Object.html#hashCode%28%29), [HashMap](../../java/util/HashMap.html "class in java.util") * #### hashCode public int hashCode() Returns a hash code value for the point. Overrides: `[hashCode](../../java/lang/Object.html#hashCode%28%29)` in class `[Object](../../java/lang/Object.html "class in java.lang")` Returns: a hash code value for the point. See Also: [Object.equals(java.lang.Object)](../../java/lang/Object.html#equals%28java.lang.Object%29), [System.identityHashCode(java.lang.Object)](../../java/lang/System.html#identityHashCode%28java.lang.Object%29) * #### toString public [String](../../java/lang/String.html "class in java.lang") toString() Returns a string representation of this `Point2D`. 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 be `null`. Overrides: `[toString](../../java/lang/Object.html#toString%28%29)` in class `[Object](../../java/lang/Object.html "class in java.lang")` Returns: a string representation of the object.
Report a bug or suggest an enhancement
For further API reference and developer documentation see the Java SE Documentation, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples.
Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.
Copyright © 1993, 2018, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA.
All rights reserved. Use is subject to license terms and the documentation redistribution policy.