Package com.crossbotics.ftchelper.util
Class Angles
java.lang.Object
com.crossbotics.ftchelper.util.Angles
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 Summary
Modifier and TypeMethodDescriptionstatic doubleshortestDiff(double targetDeg, double currentDeg) The shortest turn fromcurrenttotarget.static doublewrapDegrees(double degrees) Puts an angle into the range -180 (not included) to 180 (included).
-
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 fromcurrenttotarget.Positive result = turn counterclockwise (left), the same sign as the IMU. Example:
shortestDiff(-170, 170)gives20. Signs are explained in docs/conventions.md.- Parameters:
targetDeg- where you want to pointcurrentDeg- where you point now- Returns:
- the turn, from -180 to 180 degrees
-