java.lang.Object
org.hipparchus.geometry.spherical.twod.S2Point
All Implemented Interfaces:
Serializable, Point<Sphere2D,S2Point>

public class S2Point extends Object implements Point<Sphere2D,S2Point>
This class represents a point on the 2-sphere.

We use the mathematical convention to use the azimuthal angle θ in the x-y plane as the first coordinate, and the polar angle φ as the second coordinate (see Spherical Coordinates in MathWorld).

Instances of this class are guaranteed to be immutable.

See Also:
  • Field Summary Link icon

    Fields
    Modifier and Type
    Field
    Description
    static final S2Point
    -I (coordinates: θ=π,φ=π/2).
    static final S2Point
    -J (coordinates: θ=3π/2,φ=π/2).
    static final S2Point
    -K (coordinates: θ=anyangle,φ=π).
    static final S2Point
    A vector with all coordinates set to NaN.
    static final S2Point
    +I (coordinates: θ=0,φ=π/2).
    static final S2Point
    +J (coordinates: θ=π/2,φ=π/2)).
    static final S2Point
    +K (coordinates: θ=anyangle,φ=0).
  • Constructor Summary Link icon

    Constructors
    Constructor
    Description
    S2Point(double theta, double phi)
    Simple constructor.
    S2Point(Vector3D vector)
    Simple constructor.
  • Method Summary Link icon

    Modifier and Type
    Method
    Description
    double
    Compute the distance between the instance and another point.
    static double
    Compute the distance (angular separation) between two points.
    boolean
    equals(Object other)
    Test for the equality of two points on the 2-sphere.
    boolean
    Test for the equality of two points on the 2-sphere.
    double
    Get the polar angle φ.
    Get the space to which the point belongs.
    double
    Get the azimuthal angle θ in the x-y plane.
    Get the corresponding normalized vector in the 3D euclidean space.
    int
    Get a hashCode for the point.
    boolean
    Returns true if any coordinate of this point is NaN; false otherwise
    moveTowards(S2Point other, double ratio)
    Move towards another point.
    Get the opposite of the instance.
     

    Methods inherited from class java.lang.Object Link icon

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details Link icon

    • PLUS_I Link icon

      public static final S2Point PLUS_I
      +I (coordinates: θ=0,φ=π/2).
    • PLUS_J Link icon

      public static final S2Point PLUS_J
      +J (coordinates: θ=π/2,φ=π/2)).
    • PLUS_K Link icon

      public static final S2Point PLUS_K
      +K (coordinates: θ=anyangle,φ=0).
    • MINUS_I Link icon

      public static final S2Point MINUS_I
      -I (coordinates: θ=π,φ=π/2).
    • MINUS_J Link icon

      public static final S2Point MINUS_J
      -J (coordinates: θ=3π/2,φ=π/2).
    • MINUS_K Link icon

      public static final S2Point MINUS_K
      -K (coordinates: θ=anyangle,φ=π).
    • NaN Link icon

      public static final S2Point NaN
      A vector with all coordinates set to NaN.
  • Constructor Details Link icon

  • Method Details Link icon

    • getTheta Link icon

      public double getTheta()
      Get the azimuthal angle θ in the x-y plane.
      Returns:
      azimuthal angle θ in the x-y plane
      See Also:
    • getPhi Link icon

      public double getPhi()
      Get the polar angle φ.
      Returns:
      polar angle φ
      See Also:
    • getVector Link icon

      public Vector3D getVector()
      Get the corresponding normalized vector in the 3D euclidean space.
      Returns:
      normalized vector
    • getSpace Link icon

      public Space getSpace()
      Get the space to which the point belongs.
      Specified by:
      getSpace in interface Point<Sphere2D,S2Point>
      Returns:
      containing space
    • isNaN Link icon

      public boolean isNaN()
      Returns true if any coordinate of this point is NaN; false otherwise
      Specified by:
      isNaN in interface Point<Sphere2D,S2Point>
      Returns:
      true if any coordinate of this point is NaN; false otherwise
    • negate Link icon

      public S2Point negate()
      Get the opposite of the instance.
      Returns:
      a new vector which is opposite to the instance
    • distance Link icon

      public double distance(S2Point point)
      Compute the distance between the instance and another point.
      Specified by:
      distance in interface Point<Sphere2D,S2Point>
      Parameters:
      point - second point
      Returns:
      the distance between the instance and p
    • distance Link icon

      public static double distance(S2Point p1, S2Point p2)
      Compute the distance (angular separation) between two points.
      Parameters:
      p1 - first vector
      p2 - second vector
      Returns:
      the angular separation between p1 and p2
    • moveTowards Link icon

      public S2Point moveTowards(S2Point other, double ratio)
      Move towards another point.

      Motion is linear (along space curvature) and based on a ratio where 0.0 stands for not moving at all, 0.5 stands for moving halfway towards other point, and 1.0 stands for moving fully to the other point.

      Specified by:
      moveTowards in interface Point<Sphere2D,S2Point>
      Parameters:
      other - other point
      ratio - motion ratio,
      Returns:
      moved point
    • equals Link icon

      public boolean equals(Object other)
      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 point 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.

      Overrides:
      equals in class Object
      Parameters:
      other - Object to test for equality to this
      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
    • equalsIeee754 Link icon

      public boolean equalsIeee754(Object other)
      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.

      In compliance with IEEE754 handling, if any coordinates of any of the two points are NaN, then the points are considered different. This implies that S2Point.NaN.equals(S2Point.NaN) returns false despite the instance is checked against itself.

      Parameters:
      other - Object to test for equality to this
      Returns:
      true if two points objects are equal, false if object is null, not an instance of S2Point, or not equal to this S2Point instance
      Since:
      2.1
    • hashCode Link icon

      public int hashCode()
      Get a hashCode for the point.

      All NaN values have the same hash code.

      Overrides:
      hashCode in class Object
      Returns:
      a hash code value for this object
    • toString Link icon

      public String toString()
      Overrides:
      toString in class Object