Package edu.cnu.mdi.util
Class AngleSupport
java.lang.Object
edu.cnu.mdi.util.AngleSupport
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 Summary
Modifier and TypeMethodDescriptionstatic doubleccwSweepDeg(Point2D.Double v1, Point2D.Double v2) Compute the CCW sweep from v1 to v2 in degrees.static doubleCompute the signed angle from v1 to v2 in degrees using atan2(cross, dot).static Point2D.Doublevec(Point2D.Double center, Point2D.Double p) Convenience: vector from center to point.static Point2D.DoublevecFlipY(Point2D.Double center, Point2D.Double p) Same asvec(Point2D.Double, Point2D.Double)but flips Y.
-
Method Details
-
signedAngleDeg
Compute the signed angle from v1 to v2 in degrees using atan2(cross, dot). Range is(-180, 180].- Parameters:
v1- first vectorv2- second vector- Returns:
- signed angle in degrees in
(-180, 180]
-
ccwSweepDeg
Compute the CCW sweep from v1 to v2 in degrees.This returns a unique angle in
[0, 360). In particular, a signed angle of-90becomes270.- Parameters:
v1- first vectorv2- second vector- Returns:
- CCW sweep in degrees in
[0, 360)
-
vec
Convenience: vector from center to point.- Parameters:
center- center pointp- other point- Returns:
- vector p - center
-
vecFlipY
Same asvec(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 pointp- other point- Returns:
- vector (dx, -dy)
-