Tuple2DReadOnly
Point2DBasics
public interface Point2DReadOnly extends Tuple2DReadOnly
A 2D point represents the 2D coordinates of a location on the XY-plane.
Although a point and vector hold onto the same type of information, the distinction is made between them as they represent different geometry objects and are typically not handled the same way:
Modifier and Type | Method | Description |
---|---|---|
default double |
distance(Point2DReadOnly other) |
Calculates and returns the distance between this point and
other . |
default double |
distanceFromOrigin() |
Calculates and returns the distance between this point and the origin (0, 0).
|
default double |
distanceFromOriginSquared() |
Calculates and returns the square of the distance between this point and the origin (0, 0).
|
default double |
distanceSquared(Point2DReadOnly other) |
Calculates and returns the square of the distance between this point and
other . |
default double |
distanceXY(Point3DReadOnly point3DReadOnly) |
Calculates and returns the distance between this point and
point3DReadOnly in the
XY-plane. |
default double |
distanceXYSquared(Point3DReadOnly point3DReadOnly) |
Calculates and returns the square of the distance between this point and
point3DReadOnly in the XY-plane. |
default boolean |
geometricallyEquals(Point2DReadOnly other,
double epsilon) |
Tests if
this and other represent the same point 2D to an epsilon . |
containsNaN, epsilonEquals, equals, get, get, get, get, get, get, get, getElement, getElement32, getX, getX32, getY, getY32
default double distance(Point2DReadOnly other)
other
.other
- the other point used to measure the distance. Not modified.default double distanceSquared(Point2DReadOnly other)
other
.
This method is usually preferred over distance(Point2DReadOnly)
when calculation
speed matters and knowledge of the actual distance does not, i.e. when comparing distances
between several pairs of points.
other
- the other point used to measure the square of the distance. Not modified.default double distanceXY(Point3DReadOnly point3DReadOnly)
point3DReadOnly
in the
XY-plane.
Effectively, this calculates the distance as follows:
dxy = √((this.x - point3DReadOnly.x)2 + (this.y -
point3DReadOnly.y)2)
point3DReadOnly
- the other point used to measure the distance.default double distanceXYSquared(Point3DReadOnly point3DReadOnly)
point3DReadOnly
in the XY-plane.
Effectively, this calculates the distance squared as follows:
dxy2 = (this.x - point3DReadOnly.x)2 + (this.y -
point3DReadOnly.y)2
This method is usually preferred over distanceXY(Point3DReadOnly)
when calculation
speed matters and knowledge of the actual distance does not, i.e. when comparing distances
between several pairs of points.
point3DReadOnly
- the other point used to measure the square of the distance.default double distanceFromOrigin()
default double distanceFromOriginSquared()
This method is usually preferred over distanceFromOrigin()
when calculation speed
matters and knowledge of the actual distance does not, i.e. when comparing distances of
several points with respect to the origin.
default boolean geometricallyEquals(Point2DReadOnly other, double epsilon)
this
and other
represent the same point 2D to an epsilon
.
Two points are considered geometrically equal if they are at a distance of less than or equal
to epsilon
.
Note that this.geometricallyEquals(other, epsilon) == true
does not necessarily imply
this.epsilonEquals(other, epsilon)
and vice versa.
other
- the other point 2D to compare against this. Not modified.epsilon
- the maximum distance that the two points can be spaced and still considered
equal.true
if the two points represent the same geometry, false
otherwise.