public final class Point1S extends Object implements Point<Point1S>
2pi
. However, instances separated by a
multiple of 2pi
are considered equivalent for most methods, with the
exceptions being equals(Object)
and hashCode()
, where the
azimuth values must match exactly in order for instances to be considered
equal.
Instances of this class are guaranteed to be immutable.
Modifier and Type | Field and Description |
---|---|
static Point1S |
NaN
A point with all coordinates set to NaN.
|
static Comparator<Point1S> |
NORMALIZED_AZIMUTH_ASCENDING_ORDER
Comparator that sorts points by normalized azimuth in ascending order.
|
static Point1S |
PI
A point with coordinates set to
pi . |
static Point1S |
ZERO
A point with coordinates set to
0*pi . |
Modifier and Type | Method and Description |
---|---|
Point1S |
above(double base)
Return an equivalent point with an azimuth value at or above the given base
value in radians.
|
Point1S |
above(Point1S base)
Return an equivalent point with an azimuth value at or above the given base.
|
Point1S |
antipodal()
Get the point exactly opposite this point on the circle,
pi distance away. |
double |
distance(Point1S point) |
static double |
distance(Point1S p1,
Point1S p2)
Compute the shortest distance (angular separation) between two points.
|
boolean |
eq(Point1S other,
Precision.DoubleEquivalence precision)
Return true if this instance is equivalent to the argument.
|
boolean |
equals(Object other)
Test for the exact equality of two points on the 1-sphere.
|
static Point1S |
from(PolarCoordinates polar)
Create a new point instance containing an azimuth value equal to that of the
given set of polar coordinates.
|
static Point1S |
from(Vector2D vector)
Create a new point instance from the given Euclidean 2D vector.
|
double |
getAzimuth()
Get the azimuth angle in radians.
|
int |
getDimension() |
double |
getNormalizedAzimuth()
Get the azimuth angle normalized to the range
[0, 2pi) . |
Vector2D |
getVector()
Get the normalized vector corresponding to this azimuth angle in 2D Euclidean space.
|
int |
hashCode()
Get a hashCode for the point.
|
boolean |
isFinite() |
boolean |
isInfinite() |
boolean |
isNaN() |
static Point1S |
of(org.apache.commons.numbers.angle.Angle azimuth)
Create a new point instance from the given azimuth angle.
|
static Point1S |
of(double azimuth)
Create a new point instance from the given azimuth angle.
|
static Point1S |
parse(String str)
Parse the given string and returns a new point instance.
|
double |
signedDistance(Point1S point)
Return the signed distance (angular separation) between this instance and the
given point in the range
[-pi, pi) . |
static double |
signedDistance(Point1S p1,
Point1S p2)
Compute the signed shortest distance (angular separation) between two points.
|
String |
toString() |
public static final Comparator<Point1S> NORMALIZED_AZIMUTH_ASCENDING_ORDER
getNormalizedAzimuth()
public double getAzimuth()
of(double)
public double getNormalizedAzimuth()
[0, 2pi)
.[0, 2pi)
.public Vector2D getVector()
public int getDimension()
getDimension
in interface Spatial
public boolean isInfinite()
isInfinite
in interface Spatial
public double distance(Point1S point)
The returned value is the shortest angular distance between
the two points, in the range [0, pi]
.
public double signedDistance(Point1S point)
[-pi, pi)
. If p1
is the current instance,
p2
the given point, and d
the signed distance, then
p1.getAzimuth() + d
is an angle equivalent to p2.getAzimuth()
.point
- point to compute the signed distance to[-pi, pi)
public Point1S above(double base)
[base, base + 2pi)
.base
- base azimuth to place this instance's azimuth value above[base, base + 2pi)
IllegalArgumentException
- if the azimuth value is NaN or infinite and
cannot be normalizedpublic Point1S above(Point1S base)
[base, base + 2pi)
.base
- point to place this instance's azimuth value above[base, base + 2pi)
IllegalArgumentException
- if the azimuth value is NaN or infinite and
cannot be normalizedpublic Point1S antipodal()
pi
distance away.
The azimuth of the antipodal point is in the range [0, 2pi)
.public boolean eq(Point1S other, Precision.DoubleEquivalence precision)
2pi
are considered equivalent.other
- point to compare withprecision
- precision context used for floating point comparisonspublic int hashCode()
2pi
will not
necessarily have the same hash code.
All NaN values have the same hash code.
public boolean equals(Object other)
If all coordinates of the given points are exactly the same, and none are
Double.NaN
, the points are considered to be equal. Points with
azimuth values separated by multiples of 2pi
are not considered
equal.
NaN
coordinates are considered to affect globally the vector
and be equals to each other - i.e, if either (or all) coordinates of the
point are equal to Double.NaN
, the point is equal to
NaN
.
public static Point1S of(double azimuth)
azimuth
- azimuth angle in radiansgetAzimuth()
public static Point1S of(org.apache.commons.numbers.angle.Angle azimuth)
azimuth
- azimuth azimuth anglegetAzimuth()
public static Point1S from(Vector2D vector)
vector
- 3D vector to create the point frompublic static Point1S from(PolarCoordinates polar)
polar
- polar coordinates to convert to a pointpublic static Point1S parse(String str)
toString()
.str
- the string to parseIllegalArgumentException
- if the given string has an invalid formatpublic static double signedDistance(Point1S p1, Point1S p2)
[-pi, pi)
and is such that p1.getAzimuth() + d
(where d
is the signed distance) is an angle equivalent to p2.getAzimuth()
.p1
- first pointp2
- second point[-pi, pi)
.public static double distance(Point1S p1, Point1S p2)
[0, pi]
. This method is equal to the absolute value of
the signed distance
.p1
- first pointp2
- second point[0, pi]
.signedDistance(Point1S, Point1S)
Copyright © 2016–2021 The Apache Software Foundation. All rights reserved.