Class PolarPoint


  • public class PolarPoint
    extends java.lang.Object
    Represents a point in space defined by a latitude, longitude and distance from the origin.

    Instances of PolarPoint are immutable.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static PolarPoint ZERO  
    • Constructor Summary

      Constructors 
      Constructor Description
      PolarPoint​(Angle latitude, Angle longitude, double radius)
      Obtains a PolarPoint from two angles and a radius.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object o)  
      static PolarPoint fromCartesian​(double x, double y, double z)
      Obtains a PolarPoint from cartesian coordinates.
      static PolarPoint fromCartesian​(Vec4 cartesianPoint)
      Obtains a PolarPoint from a cartesian point.
      static PolarPoint fromDegrees​(double latitude, double longitude, double radius)
      Obtains a PolarPoint from degrees and a radius.
      static PolarPoint fromRadians​(double latitude, double longitude, double radius)
      Obtains a PolarPoint from radians and a radius.
      Angle getLatitude()
      Obtains the latitude of this polar point
      Angle getLongitude()
      Obtains the longitude of this polar point
      double getRadius()
      Obtains the radius of this polar point
      int hashCode()  
      Vec4 toCartesian()
      Obtains a cartesian point equivalent to this PolarPoint, except in cartesian space.
      static Vec4 toCartesian​(Angle latitude, Angle longitude, double radius)
      Obtains a cartesian point from a given latitude, longitude and distance from center.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • PolarPoint

        public PolarPoint​(Angle latitude,
                          Angle longitude,
                          double radius)
        Obtains a PolarPoint from two angles and a radius.
        Parameters:
        latitude - the latitude
        longitude - the longitude
        radius - the distance from the center
        Throws:
        java.lang.IllegalArgumentException - if latitude or longitude is null
    • Method Detail

      • fromRadians

        public static PolarPoint fromRadians​(double latitude,
                                             double longitude,
                                             double radius)
        Obtains a PolarPoint from radians and a radius.
        Parameters:
        latitude - the latitude in radians
        longitude - the longitude in radians
        radius - the distance form the center
        Returns:
        a new PolarPoint
      • fromDegrees

        public static PolarPoint fromDegrees​(double latitude,
                                             double longitude,
                                             double radius)
        Obtains a PolarPoint from degrees and a radius.
        Parameters:
        latitude - the latitude in degrees
        longitude - the longitude in degrees
        radius - the distance form the center
        Returns:
        a new PolarPoint
      • fromCartesian

        public static PolarPoint fromCartesian​(Vec4 cartesianPoint)
        Obtains a PolarPoint from a cartesian point.
        Parameters:
        cartesianPoint - the point to convert
        Returns:
        the cartesian point expressed as a polar point
        Throws:
        java.lang.IllegalArgumentException - if cartesianPoint is null
      • fromCartesian

        public static PolarPoint fromCartesian​(double x,
                                               double y,
                                               double z)
        Obtains a PolarPoint from cartesian coordinates.
        Parameters:
        x - the x coordinate of the cartesian point
        y - the y coordinate of the cartesian point
        z - the z coordinate of the cartesian point
        Returns:
        a polar point located at (x,y,z) in cartesian space
      • getLatitude

        public final Angle getLatitude()
        Obtains the latitude of this polar point
        Returns:
        this polar point's latitude
      • getLongitude

        public final Angle getLongitude()
        Obtains the longitude of this polar point
        Returns:
        this polar point's longitude
      • getRadius

        public final double getRadius()
        Obtains the radius of this polar point
        Returns:
        the distance from this polar point to its origin
      • toCartesian

        public final Vec4 toCartesian()
        Obtains a cartesian point equivalent to this PolarPoint, except in cartesian space.
        Returns:
        this polar point in cartesian coordinates
      • toCartesian

        public static Vec4 toCartesian​(Angle latitude,
                                       Angle longitude,
                                       double radius)
        Obtains a cartesian point from a given latitude, longitude and distance from center. This method is equivalent to, but may perform faster than Vec4 p = new PolarPoint(latitude, longitude, radius).toCartesian()
        Parameters:
        latitude - the latitude
        longitude - the longitude
        radius - the distance from the origin
        Returns:
        a cartesian point from two angles and a radius
        Throws:
        java.lang.IllegalArgumentException - if latitude or longitude is null
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object