Class Angles

java.lang.Object
com.crossbotics.ftchelper.util.Angles

public final class Angles extends Object
Angle helpers, in degrees.

Headings go around in a circle, so plain subtraction gives wrong answers near the "seam". Example: from 170 degrees to -170 degrees is a 20-degree turn, not 340. These helpers fix that. Docs: docs/modules/util.md

  • Method Details

    • wrapDegrees

      public static double wrapDegrees(double degrees)
      Puts an angle into the range -180 (not included) to 180 (included).

      Examples: 190 gives -170; -540 gives 180; 45 gives 45.

      Parameters:
      degrees - any angle
      Returns:
      the same direction, written between -180 and 180
    • shortestDiff

      public static double shortestDiff(double targetDeg, double currentDeg)
      The shortest turn from current to target.

      Positive result = turn counterclockwise (left), the same sign as the IMU. Example: shortestDiff(-170, 170) gives 20. Signs are explained in docs/conventions.md.

      Parameters:
      targetDeg - where you want to point
      currentDeg - where you point now
      Returns:
      the turn, from -180 to 180 degrees