Class Globe


  • public class Globe
    extends java.lang.Object
    Planet or celestial object approximated by a reference ellipsoid and elevation models. Globe expresses its ellipsoidal parameters and elevation values in meters.
    • Constructor Detail

      • Globe

        public Globe​(Ellipsoid ellipsoid,
                     GeographicProjection projection)
        Constructs a globe with a specified reference ellipsoid and projection.
        Parameters:
        ellipsoid - the reference ellipsoid defining the globe's equatorial radius and polar radius
        projection - the geographic projection used by the globe, specifies the globe's Cartesian coordinate system
        Throws:
        java.lang.IllegalArgumentException - If the ellipsoid is null
    • Method Detail

      • getEllipsoid

        public Ellipsoid getEllipsoid()
        Indicates the reference ellipsoid defining this globe's equatorial radius and polar radius.
        Returns:
        this globe's reference ellipsoid
      • setEllipsoid

        public void setEllipsoid​(Ellipsoid ellipsoid)
        Sets the reference ellipsoid that defines this globe's equatorial radius and polar radius.
        Parameters:
        ellipsoid - the new reference ellipsoid
        Throws:
        java.lang.IllegalArgumentException - If the ellipsoid is null
      • getEquatorialRadius

        public double getEquatorialRadius()
        Indicates the radius in meters of the globe's ellipsoid at the equator.
        Returns:
        the radius at the equator, in meters.
      • getPolarRadius

        public double getPolarRadius()
        Indicates the radius in meters of the globe's ellipsoid at the poles.
        Returns:
        the radius at the poles, in meters.
      • getRadiusAt

        public double getRadiusAt​(double latitude,
                                  double longitude)
        Indicates the radius in meters of the globe's ellipsoid at a specified location.
        Parameters:
        latitude - the location's latitude in degrees
        longitude - the location's longitude in degrees
        Returns:
        the radius in meters of the globe's ellipsoid at the specified location
      • getEccentricitySquared

        public double getEccentricitySquared()
        Indicates the eccentricity squared parameter of the globe's ellipsoid. This is equivalent to 2*f - f*f, where f is the ellipsoid's flattening parameter.
        Returns:
        the eccentricity squared parameter of the globe's ellipsoid.
      • setElevationModel

        public void setElevationModel​(ElevationModel elevationModel)
      • getProjection

        public GeographicProjection getProjection()
        Indicates the geographic projection used by this globe. The projection specifies this globe's Cartesian coordinate system.
        Returns:
        the globe's projection
      • setProjection

        public void setProjection​(GeographicProjection projection)
        Sets the geographic projection used by this globe. The projection specifies this globe's Cartesian coordinate system.
        Parameters:
        projection - the projection to use
        Throws:
        java.lang.IllegalArgumentException - if the projection is null
      • geographicToCartesian

        public Vec3 geographicToCartesian​(double latitude,
                                          double longitude,
                                          double altitude,
                                          Vec3 result)
        Converts a geographic position to Cartesian coordinates. This globe's projection specifies the Cartesian coordinate system.
        Parameters:
        latitude - the position's latitude in degrees
        longitude - the position's longitude in degrees
        altitude - the position's altitude in meters
        result - a pre-allocated Vec3 in which to store the computed X, Y and Z Cartesian coordinates
        Returns:
        the result argument, set to the computed Cartesian coordinates
        Throws:
        java.lang.IllegalArgumentException - if the result is null
      • geographicToCartesianNormal

        public Vec3 geographicToCartesianNormal​(double latitude,
                                                double longitude,
                                                Vec3 result)
      • geographicToCartesianTransform

        public Matrix4 geographicToCartesianTransform​(double latitude,
                                                      double longitude,
                                                      double altitude,
                                                      Matrix4 result)
      • geographicToCartesianGrid

        public float[] geographicToCartesianGrid​(Sector sector,
                                                 int numLat,
                                                 int numLon,
                                                 float[] height,
                                                 float verticalExaggeration,
                                                 Vec3 origin,
                                                 float[] result,
                                                 int offset,
                                                 int rowStride)
      • geographicToCartesianBorder

        public float[] geographicToCartesianBorder​(Sector sector,
                                                   int numLat,
                                                   int numLon,
                                                   float height,
                                                   Vec3 origin,
                                                   float[] result)
      • cartesianToGeographic

        public Position cartesianToGeographic​(double x,
                                              double y,
                                              double z,
                                              Position result)
        Converts a Cartesian point to a geographic position. This globe's projection specifies the Cartesian coordinate system.
        Parameters:
        x - the Cartesian point's X component
        y - the Cartesian point's Y component
        z - the Cartesian point's Z component
        result - a pre-allocated Position in which to store the computed geographic position
        Returns:
        the result argument, set to the computed geographic position
        Throws:
        java.lang.IllegalArgumentException - if the result is null
      • cartesianToLocalTransform

        public Matrix4 cartesianToLocalTransform​(double x,
                                                 double y,
                                                 double z,
                                                 Matrix4 result)
      • horizonDistance

        public double horizonDistance​(double height)
        Indicates the distance to the globe's horizon from a specified height above the globe's ellipsoid. The result of this method is undefined if the height is negative.
        Parameters:
        height - the viewer's height above the globe's ellipsoid in meters
        Returns:
        the horizon distance in meters
      • intersect

        public boolean intersect​(Line line,
                                 Vec3 result)
        Computes the first intersection of this globe with a specified line. The line is interpreted as a ray; intersection points behind the line's origin are ignored.
        Parameters:
        line - the line to intersect with this globe
        result - a pre-allocated Vec3 in which to return the computed point
        Returns:
        true if the ray intersects the globe, otherwise false
        Throws:
        java.lang.IllegalArgumentException - If either argument is null
      • getElevationAtLocation

        public double getElevationAtLocation​(double latitude,
                                             double longitude)
        Determine terrain altitude in specified geographic point from elevation model
        Parameters:
        latitude - location latitude
        longitude - location longitude
        Returns:
        Elevation in meters in specified location