Package edu.cnu.mdi.view.demo.geoslice
Class SliceProjection
java.lang.Object
edu.cnu.mdi.view.demo.geoslice.SliceProjection
Coordinate conversion utilities for the geometry slice demos.
The demos use a simple constant-phi slice through 3D Cartesian geometry. The 2D display convention is:
slice x = z
slice y = radial distance in the selected phi plane
These methods convert between cylindrical/spherical/Cartesian coordinates and the 2D slice coordinates used by the MDI view. They are public so both the 2D MDI view and the companion MDI-3D explanatory view can use the same model and coordinate conventions.
-
Method Summary
Modifier and TypeMethodDescriptionstatic Pointcylindrical(double r, double phiDeg, double z) Convert cylindrical coordinates to a 3D Cartesian point.static doublenormalizeDegrees(double angleDeg) Normalize an angle to the range(-180, 180].static doubleCompute the spherical azimuthal angle phi in degrees.static Point2D.DoubleprojectToSlice(Point p, double phiDeg) Project a 3D point in the selected constant-phi plane into 2D slice coordinates.static doubleCompute the 3D radius from the origin.static PointsliceToCartesian(Point2D.Double slicePoint, double phiDeg) Convert a 2D slice-coordinate point back into a 3D Cartesian point lying in the current constant-phi plane.static doubleCompute the spherical polar angle theta in degrees.
-
Method Details
-
cylindrical
Convert cylindrical coordinates to a 3D Cartesian point.x = r cos(phi) y = r sin(phi) z = z- Parameters:
r- radial coordinatephiDeg- azimuthal angle in degreesz- z coordinate- Returns:
- Cartesian 3D point
-
projectToSlice
Project a 3D point in the selected constant-phi plane into 2D slice coordinates.x = z y = radial coordinate in the selected phi plane- Parameters:
p- 3D Cartesian pointphiDeg- current slice azimuth, in degrees- Returns:
- 2D slice point
-
sliceToCartesian
Convert a 2D slice-coordinate point back into a 3D Cartesian point lying in the current constant-phi plane.If the slice point is
(z, s), wheresis the radial coordinate in the current phi plane, then:x = s cos(phi) y = s sin(phi) z = z- Parameters:
slicePoint- point in 2D slice world coordinatesphiDeg- current slice azimuth, in degrees- Returns:
- corresponding 3D Cartesian point
-
radius
Compute the 3D radius from the origin.- Parameters:
p- Cartesian point- Returns:
sqrt(x^2 + y^2 + z^2)
-
thetaDeg
Compute the spherical polar angle theta in degrees.The convention is the usual physics/detector convention:
theta = 0points along positive z, andtheta = 90lies in the x-y plane.- Parameters:
p- Cartesian point- Returns:
- theta in degrees
-
phiDeg
Compute the spherical azimuthal angle phi in degrees.- Parameters:
p- Cartesian point- Returns:
- phi in degrees, normalized to
(-180, 180]
-
normalizeDegrees
public static double normalizeDegrees(double angleDeg) Normalize an angle to the range(-180, 180].- Parameters:
angleDeg- angle in degrees- Returns:
- normalized angle in degrees
-