Package com.marginallyclever.convenience
Class SphericalMap
java.lang.Object
com.marginallyclever.convenience.SphericalMap
map from a sphere to a plane and back; map from a cube to a sphere and back.
-
Nested Class Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic double[]
cubeToSphere
(int index, double u, double v) convert uv on plane to unit vector on spherestatic SphericalMap.CubeCoordinate
planeToCube
(double u, double v) convert uv on plane to cube face and position on face.static double[]
planeToPanTilt
(double u, double v) map plane to spherestatic double[]
planeToSphere
(double u, double v) 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 bottomstatic double[]
sphereToPlane
(double[] sphere) map sphere to plane
-
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...1v
- 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...1v
- y position on plane, value 0...1- Returns:
- unit vector on sphere
-
sphereToCube
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
convert uv on plane to cube face and position on face.- Parameters:
u
- x position on plane, value 0...1v
- 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...1v
- y position on plane, value 0...1- Returns:
- unit vector on sphere
-