public class S2Point extends java.lang.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.
|
private double |
phi
Polar angle \( \varphi \).
|
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 \)).
|
private static long |
serialVersionUID
Serializable UID.
|
private double |
theta
Azimuthal angle \( \theta \) in the x-y plane.
|
private Vector3D |
vector
Corresponding 3D normalized vector.
|
Modifier | Constructor and Description |
---|---|
|
S2Point(double theta,
double phi)
Simple constructor.
|
private |
S2Point(double theta,
double phi,
Vector3D vector)
Build a point from its internal components.
|
|
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(java.lang.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.
|
private static Vector3D |
vector(double theta,
double phi)
Build the normalized vector corresponding to spherical coordinates.
|
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
private static final long serialVersionUID
private final double theta
private final double phi
private final Vector3D vector
public S2Point(double theta, double phi) throws OutOfRangeException
theta
- azimuthal angle \( \theta \) in the x-y planephi
- polar angle \( \varphi \)OutOfRangeException
- if \( \varphi \) is not in the [\( 0; \pi \)] rangegetTheta()
,
getPhi()
public S2Point(Vector3D vector) throws MathArithmeticException
vector
- 3D vectorMathArithmeticException
- if vector norm is zeroprivate S2Point(double theta, double phi, Vector3D vector)
theta
- azimuthal angle \( \theta \) in the x-y planephi
- polar angle \( \varphi \)vector
- corresponding vectorprivate static Vector3D vector(double theta, double phi) throws OutOfRangeException
theta
- azimuthal angle \( \theta \) in the x-y planephi
- polar angle \( \varphi \)OutOfRangeException
- if \( \varphi \) is not in the [\( 0; \pi \)] rangepublic 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(java.lang.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
.
equals
in class java.lang.Object
other
- Object to test for equality to thispublic int hashCode()
All NaN values have the same hash code.
hashCode
in class java.lang.Object
Copyright (c) 2003-2016 Apache Software Foundation