Class S2Point
java.lang.Object
org.apache.commons.math3.geometry.spherical.twod.S2Point
- All Implemented Interfaces:
Serializable
,Point<Sphere2D>
This class represents a point on the 2-sphere.
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.
- Since:
- 3.3
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final S2Point
-I (coordinates: \( \theta = \pi, \varphi = \pi/2 \)).static final S2Point
-J (coordinates: \( \theta = 3\pi/2, \varphi = \pi/2 \)).static final S2Point
-K (coordinates: \( \theta = any angle, \varphi = \pi \)).static final S2Point
A vector with all coordinates set to NaN.static final S2Point
+I (coordinates: \( \theta = 0, \varphi = \pi/2 \)).static final S2Point
+J (coordinates: \( \theta = \pi/2, \varphi = \pi/2 \))).static final S2Point
+K (coordinates: \( \theta = any angle, \varphi = 0 \)). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondouble
Compute the distance between the instance and another point.static double
Compute the distance (angular separation) between two points.boolean
Test for the equality of two points on the 2-sphere.double
getPhi()
Get the polar angle \( \varphi \).getSpace()
Get the space to which the point belongs.double
getTheta()
Get the azimuthal angle \( \theta \) in the x-y plane.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 otherwisenegate()
Get the opposite of the instance.
-
Field Details
-
PLUS_I
+I (coordinates: \( \theta = 0, \varphi = \pi/2 \)). -
PLUS_J
+J (coordinates: \( \theta = \pi/2, \varphi = \pi/2 \))). -
PLUS_K
+K (coordinates: \( \theta = any angle, \varphi = 0 \)). -
MINUS_I
-I (coordinates: \( \theta = \pi, \varphi = \pi/2 \)). -
MINUS_J
-J (coordinates: \( \theta = 3\pi/2, \varphi = \pi/2 \)). -
MINUS_K
-K (coordinates: \( \theta = any angle, \varphi = \pi \)). -
NaN
A vector with all coordinates set to NaN.
-
-
Constructor Details
-
S2Point
Simple constructor. Build a vector from its spherical coordinates- Parameters:
theta
- azimuthal angle \( \theta \) in the x-y planephi
- polar angle \( \varphi \)- Throws:
OutOfRangeException
- if \( \varphi \) is not in the [\( 0; \pi \)] range- See Also:
-
S2Point
Simple constructor. Build a vector from its underlying 3D vector- Parameters:
vector
- 3D vector- Throws:
MathArithmeticException
- if vector norm is zero
-
-
Method Details
-
getTheta
public double getTheta()Get the azimuthal angle \( \theta \) in the x-y plane.- Returns:
- azimuthal angle \( \theta \) in the x-y plane
- See Also:
-
getPhi
public double getPhi()Get the polar angle \( \varphi \).- Returns:
- polar angle \( \varphi \)
- See Also:
-
getVector
Get the corresponding normalized vector in the 3D euclidean space.- Returns:
- normalized vector
-
getSpace
Get the space to which the point belongs. -
isNaN
public boolean isNaN()Returns true if any coordinate of this point is NaN; false otherwise -
negate
Get the opposite of the instance.- Returns:
- a new vector which is opposite to the instance
-
distance
Compute the distance between the instance and another point. -
distance
Compute the distance (angular separation) between two points.- Parameters:
p1
- first vectorp2
- second vector- Returns:
- the angular separation between p1 and p2
-
equals
Test for the equality of two points on the 2-sphere.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 toDouble.NaN
, the 2D vector is equal toNaN
. -
hashCode
public int hashCode()Get a hashCode for the 2D vector.All NaN values have the same hash code.
-