Class AngleSupport

java.lang.Object
edu.cnu.mdi.util.AngleSupport

public final class AngleSupport extends Object
Angle helper utilities used by radial arc tools/items.

The main convenience is to compute a unique CCW sweep angle in the range [0, 360) from two vectors using the robust atan2(cross, dot) formulation.

Conventions

  • Angles are in degrees unless otherwise stated.
  • CCW sweep is reported in [0, 360).
  • The caller controls coordinate handedness by the vectors it provides. (For screen coordinates where +y is down, callers usually flip y.)
  • Method Details

    • signedAngleDeg

      public static double signedAngleDeg(Point2D.Double v1, Point2D.Double v2)
      Compute the signed angle from v1 to v2 in degrees using atan2(cross, dot). Range is (-180, 180].
      Parameters:
      v1 - first vector
      v2 - second vector
      Returns:
      signed angle in degrees in (-180, 180]
    • ccwSweepDeg

      public static double ccwSweepDeg(Point2D.Double v1, Point2D.Double v2)
      Compute the CCW sweep from v1 to v2 in degrees.

      This returns a unique angle in [0, 360). In particular, a signed angle of -90 becomes 270.

      Parameters:
      v1 - first vector
      v2 - second vector
      Returns:
      CCW sweep in degrees in [0, 360)
    • vec

      public static Point2D.Double vec(Point2D.Double center, Point2D.Double p)
      Convenience: vector from center to point.
      Parameters:
      center - center point
      p - other point
      Returns:
      vector p - center
    • vecFlipY

      public static Point2D.Double vecFlipY(Point2D.Double center, Point2D.Double p)
      Same as vec(Point2D.Double, Point2D.Double) but flips Y.

      Useful when converting screen-space deltas (where +y is down) into math-space vectors (where +y is up).

      Parameters:
      center - center point
      p - other point
      Returns:
      vector (dx, -dy)