java.lang.Object
com.marginallyclever.convenience.SphericalMap

public class SphericalMap extends Object
map from a sphere to a plane and back; map from a cube to a sphere and back.
  • Constructor Details

    • SphericalMap

      public SphericalMap()
  • Method Details

    • planeToPanTilt

      public static double[] planeToPanTilt(double u, double v)
      map plane to sphere
      Parameters:
      u - x position on plane, value 0...1
      v - y position on plane, value 0...1
      Returns:
      pan/tilt position on sphere in radians
    • sphereToPlane

      public static double[] sphereToPlane(double[] sphere)
      map sphere to plane
      Parameters:
      sphere - unit vector on sphere
      Returns:
      uv coordinate on plane, values 0...1
    • planeToSphere

      public static double[] planeToSphere(double u, double v)
      Parameters:
      u - x position on plane, value 0...1
      v - y position on plane, value 0...1
      Returns:
      unit vector on sphere
    • sphereToCube

      public static SphericalMap.CubeCoordinate sphereToCube(double[] unitVector)
      Cube index 0 is top, 1 is left, 2 is front, 3 is right, 4 is back, 5 is bottom
      Parameters:
      unitVector - unit vector on sphere
      Returns:
      CubeCoordinate face and position on face.
    • planeToCube

      public static SphericalMap.CubeCoordinate planeToCube(double u, double v)
      convert uv on plane to cube face and position on face.
      Parameters:
      u - x position on plane, value 0...1
      v - y position on plane, value 0...1
      Returns:
      CubeCoordinate face and position on face.
    • cubeToSphere

      public static double[] cubeToSphere(int index, double u, double v)
      convert uv on plane to unit vector on sphere
      Parameters:
      index - cube face index. See CubeCoordinate constants.
      u - x position on plane, value 0...1
      v - y position on plane, value 0...1
      Returns:
      unit vector on sphere