public class S2Point extends Object implements Point<Sphere2D>
We use the mathematical convention to use the azimuthal angle \( \theta \) in the x-y plane as the first coordinate, and the polar angle \( \varphi \) as the second coordinate (see Spherical Coordinates in MathWorld).
Instances of this class are guaranteed to be immutable.
Modifier and Type | Field and Description |
---|---|
static S2Point |
MINUS_I
-I (coordinates: \( \theta = \pi, \varphi = \pi/2 \)).
|
static S2Point |
MINUS_J
-J (coordinates: \( \theta = 3\pi/2, \varphi = \pi/2 \)).
|
static S2Point |
MINUS_K
-K (coordinates: \( \theta = any angle, \varphi = \pi \)).
|
static S2Point |
NaN
A vector with all coordinates set to NaN.
|
static S2Point |
PLUS_I
+I (coordinates: \( \theta = 0, \varphi = \pi/2 \)).
|
static S2Point |
PLUS_J
+J (coordinates: \( \theta = \pi/2, \varphi = \pi/2 \))).
|
static S2Point |
PLUS_K
+K (coordinates: \( \theta = any angle, \varphi = 0 \)).
|
Constructor and Description |
---|
S2Point(double theta,
double phi)
Simple constructor.
|
S2Point(Vector3D vector)
Simple constructor.
|
Modifier and Type | Method and Description |
---|---|
double |
distance(Point<Sphere2D> point)
Compute the distance between the instance and another point.
|
static double |
distance(S2Point p1,
S2Point p2)
Compute the distance (angular separation) between two points.
|
boolean |
equals(Object other)
Test for the equality of two points on the 2-sphere.
|
double |
getPhi()
Get the polar angle \( \varphi \).
|
Space |
getSpace()
Get the space to which the point belongs.
|
double |
getTheta()
Get the azimuthal angle \( \theta \) in the x-y plane.
|
Vector3D |
getVector()
Get the corresponding normalized vector in the 3D euclidean space.
|
int |
hashCode()
Get a hashCode for the 2D vector.
|
boolean |
isNaN()
Returns true if any coordinate of this point is NaN; false otherwise
|
S2Point |
negate()
Get the opposite of the instance.
|
String |
toString() |
public static final S2Point PLUS_I
public static final S2Point PLUS_J
public static final S2Point PLUS_K
public static final S2Point MINUS_I
public static final S2Point MINUS_J
public static final S2Point MINUS_K
public static final S2Point NaN
public S2Point(double theta, double phi) throws MathIllegalArgumentException
theta
- azimuthal angle \( \theta \) in the x-y planephi
- polar angle \( \varphi \)MathIllegalArgumentException
- if \( \varphi \) is not in the [\( 0; \pi \)] rangegetTheta()
,
getPhi()
public S2Point(Vector3D vector) throws MathRuntimeException
vector
- 3D vectorMathRuntimeException
- if vector norm is zeropublic double getTheta()
S2Point(double, double)
public double getPhi()
S2Point(double, double)
public Vector3D getVector()
public Space getSpace()
public boolean isNaN()
public S2Point negate()
public double distance(Point<Sphere2D> point)
public static double distance(S2Point p1, S2Point p2)
p1
- first vectorp2
- second vectorpublic boolean equals(Object other)
If all coordinates of two points are exactly the same, and none are
Double.NaN
, the two points are considered to be 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
2D vector are equal to Double.NaN
, the 2D vector is equal to
NaN
.
public int hashCode()
All NaN values have the same hash code.
Copyright © 2016–2020 Hipparchus.org. All rights reserved.