Top Description Fields Constructors Methods
org.apache.commons.math3.geometry.spherical.twod

public Class S2Point

extends Object
implements Point<Sphere2D>
Class Inheritance
All Implemented Interfaces
org.apache.commons.math3.geometry.Point, java.io.Serializable
Imports
org.apache.commons.math3.exception.MathArithmeticException, .OutOfRangeException, org.apache.commons.math3.geometry.Point, .Space, org.apache.commons.math3.geometry.euclidean.threed.Vector3D, org.apache.commons.math3.util.FastMath, .MathUtils

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

Field Summary

Modifier and TypeField and Description
public static final S2Point
MINUS_I

-I (coordinates: \( \theta = \pi, \varphi = \pi/2 \)).

public static final S2Point
MINUS_J

-J (coordinates: \( \theta = 3\pi/2, \varphi = \pi/2 \)).

public static final S2Point
MINUS_K

-K (coordinates: \( \theta = any angle, \varphi = \pi \)).

public static final S2Point
NaN

A vector with all coordinates set to NaN.

private final double
phi

Polar angle \( \varphi \).

public static final S2Point
PLUS_I

+I (coordinates: \( \theta = 0, \varphi = \pi/2 \)).

public static final S2Point
PLUS_J

+J (coordinates: \( \theta = \pi/2, \varphi = \pi/2 \))).

public static final S2Point
PLUS_K

+K (coordinates: \( \theta = any angle, \varphi = 0 \)).

private static final long
serialVersionUID

Serializable UID.

private final double
theta

Azimuthal angle \( \theta \) in the x-y plane.

private final Vector3D
vector

Corresponding 3D normalized vector.

Constructor Summary

AccessConstructor and Description
public
S2Point(final double
azimuthal angle \( \theta \) in the x-y plane
theta
,
final double
polar angle \( \varphi \)
phi
)

Simple constructor.

public
S2Point(final Vector3D
3D vector
vector
)

Simple constructor.

private
S2Point(final double
azimuthal angle \( \theta \) in the x-y plane
theta
,
final double
polar angle \( \varphi \)
phi
,
final Vector3D
corresponding vector
vector
)

Build a point from its internal components.

Method Summary

Modifier and TypeMethod and Description
public double
distance(final Point<Sphere2D>
second point
point
)

Implements org.apache.commons.math3.geometry.Point.distance.

Compute the distance between the instance and another point.

public static double

Returns:

the angular separation between p1 and p2
distance
(S2Point
first vector
p1
,
S2Point
second vector
p2
)

Compute the distance (angular separation) between two points.

public boolean

Returns:

true if two points on the 2-sphere objects are equal, false if object is null, not an instance of S2Point, or not equal to this S2Point instance
equals
(Object
Object to test for equality to this
other
)

Overrides java.lang.Object.equals.

Test for the equality of two points on the 2-sphere.

public double

Returns:

polar angle \( \varphi \)
getPhi
()

Get the polar angle \( \varphi \).

public Space
getSpace()

Implements org.apache.commons.math3.geometry.Point.getSpace.

Get the space to which the point belongs.

public double

Returns:

azimuthal angle \( \theta \) in the x-y plane
getTheta
()

Get the azimuthal angle \( \theta \) in the x-y plane.

public Vector3D

Returns:

normalized vector
getVector
()

Get the corresponding normalized vector in the 3D euclidean space.

public int

Returns:

a hash code value for this object
hashCode
()

Overrides java.lang.Object.hashCode.

Get a hashCode for the 2D vector.

public boolean
isNaN()

Implements org.apache.commons.math3.geometry.Point.isNaN.

Returns true if any coordinate of this point is NaN; false otherwise

public S2Point

Returns:

a new vector which is opposite to the instance
negate
()

Get the opposite of the instance.

private static Vector3D

Returns:

normalized vector
vector
(final double
azimuthal angle \( \theta \) in the x-y plane
theta
,
final double
polar angle \( \varphi \)
phi
)

Build the normalized vector corresponding to spherical coordinates.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

MINUS_Iback to summary
public static final S2Point MINUS_I

-I (coordinates: \( \theta = \pi, \varphi = \pi/2 \)).

MINUS_Jback to summary
public static final S2Point MINUS_J

-J (coordinates: \( \theta = 3\pi/2, \varphi = \pi/2 \)).

MINUS_Kback to summary
public static final S2Point MINUS_K

-K (coordinates: \( \theta = any angle, \varphi = \pi \)).

NaNback to summary
public static final S2Point NaN

A vector with all coordinates set to NaN.

phiback to summary
private final double phi

Polar angle \( \varphi \).

PLUS_Iback to summary
public static final S2Point PLUS_I

+I (coordinates: \( \theta = 0, \varphi = \pi/2 \)).

PLUS_Jback to summary
public static final S2Point PLUS_J

+J (coordinates: \( \theta = \pi/2, \varphi = \pi/2 \))).

PLUS_Kback to summary
public static final S2Point PLUS_K

+K (coordinates: \( \theta = any angle, \varphi = 0 \)).

serialVersionUIDback to summary
private static final long serialVersionUID

Serializable UID.

thetaback to summary
private final double theta

Azimuthal angle \( \theta \) in the x-y plane.

vectorback to summary
private final Vector3D vector

Corresponding 3D normalized vector.

Constructor Detail

S2Pointback to summary
public S2Point(final double theta, final double phi) throws OutOfRangeException

Simple constructor. Build a vector from its spherical coordinates

Parameters
theta:double

azimuthal angle \( \theta \) in the x-y plane

phi:double

polar angle \( \varphi \)

Exceptions
OutOfRangeException:
if \( \varphi \) is not in the [\( 0; \pi \)] range
See Also
getTheta(), getPhi()
S2Pointback to summary
public S2Point(final Vector3D vector) throws MathArithmeticException

Simple constructor. Build a vector from its underlying 3D vector

Parameters
vector:Vector3D

3D vector

Exceptions
MathArithmeticException:
if vector norm is zero
S2Pointback to summary
private S2Point(final double theta, final double phi, final Vector3D vector)

Build a point from its internal components.

Parameters
theta:double

azimuthal angle \( \theta \) in the x-y plane

phi:double

polar angle \( \varphi \)

vector:Vector3D

corresponding vector

Method Detail

distanceback to summary
public double distance(final Point<Sphere2D> point)

Implements org.apache.commons.math3.geometry.Point.distance.

Doc from org.apache.commons.math3.geometry.Point.distance.

Compute the distance between the instance and another point.

Parameters
point:Point<Sphere2D>

second point

Returns:double

the distance between the instance and p

distanceback to summary
public static double distance(S2Point p1, S2Point p2)

Compute the distance (angular separation) between two points.

Parameters
p1:S2Point

first vector

p2:S2Point

second vector

Returns:double

the angular separation between p1 and p2

equalsback to summary
public boolean equals(Object other)

Overrides java.lang.Object.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 to Double.NaN, the 2D vector is equal to NaN.

Parameters
other:Object

Object to test for equality to this

Returns:boolean

true if two points on the 2-sphere objects are equal, false if object is null, not an instance of S2Point, or not equal to this S2Point instance

Annotations
@Override
getPhiback to summary
public double getPhi()

Get the polar angle \( \varphi \).

Returns:double

polar angle \( \varphi \)

See Also
S2Point(double, double)
getSpaceback to summary
public Space getSpace()

Implements org.apache.commons.math3.geometry.Point.getSpace.

Doc from org.apache.commons.math3.geometry.Point.getSpace.

Get the space to which the point belongs.

Returns:Space

containing space

getThetaback to summary
public double getTheta()

Get the azimuthal angle \( \theta \) in the x-y plane.

Returns:double

azimuthal angle \( \theta \) in the x-y plane

See Also
S2Point(double, double)
getVectorback to summary
public Vector3D getVector()

Get the corresponding normalized vector in the 3D euclidean space.

Returns:Vector3D

normalized vector

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Get a hashCode for the 2D vector.

All NaN values have the same hash code.

Returns:int

a hash code value for this object

Annotations
@Override
isNaNback to summary
public boolean isNaN()

Implements org.apache.commons.math3.geometry.Point.isNaN.

Doc from org.apache.commons.math3.geometry.Point.isNaN.

Returns true if any coordinate of this point is NaN; false otherwise

Returns:boolean

true if any coordinate of this point is NaN; false otherwise

negateback to summary
public S2Point negate()

Get the opposite of the instance.

Returns:S2Point

a new vector which is opposite to the instance

vectorback to summary
private static Vector3D vector(final double theta, final double phi) throws OutOfRangeException

Build the normalized vector corresponding to spherical coordinates.

Parameters
theta:double

azimuthal angle \( \theta \) in the x-y plane

phi:double

polar angle \( \varphi \)

Returns:Vector3D

normalized vector

Exceptions
OutOfRangeException:
if \( \varphi \) is not in the [\( 0; \pi \)] range