Class SliceProjection

java.lang.Object
edu.cnu.mdi.view.demo.geoslice.SliceProjection

public final class SliceProjection extends Object
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 Details

    • cylindrical

      public static Point cylindrical(double r, double phiDeg, double z)
      Convert cylindrical coordinates to a 3D Cartesian point.
           x = r cos(phi)
           y = r sin(phi)
           z = z
       
      Parameters:
      r - radial coordinate
      phiDeg - azimuthal angle in degrees
      z - z coordinate
      Returns:
      Cartesian 3D point
    • projectToSlice

      public static Point2D.Double projectToSlice(Point p, double phiDeg)
      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 point
      phiDeg - current slice azimuth, in degrees
      Returns:
      2D slice point
    • sliceToCartesian

      public static Point sliceToCartesian(Point2D.Double slicePoint, double phiDeg)
      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), where s is 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 coordinates
      phiDeg - current slice azimuth, in degrees
      Returns:
      corresponding 3D Cartesian point
    • radius

      public static double radius(Point p)
      Compute the 3D radius from the origin.
      Parameters:
      p - Cartesian point
      Returns:
      sqrt(x^2 + y^2 + z^2)
    • thetaDeg

      public static double thetaDeg(Point p)
      Compute the spherical polar angle theta in degrees.

      The convention is the usual physics/detector convention: theta = 0 points along positive z, and theta = 90 lies in the x-y plane.

      Parameters:
      p - Cartesian point
      Returns:
      theta in degrees
    • phiDeg

      public static double phiDeg(Point p)
      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