mathAngleDifference

Calculates the shortest angular difference between two angles. Takes angle1 (first angle in degrees), angle2 (second angle in degrees). Returns the shortest signed angular distance from angle1 to angle2 in degrees, wrapped to the range [-180, 180].

Mathematics

Parameters & Returns

Parameters

angle1 Double
angle2 Double

Returns

Double

Quick Summary

Calculates the shortest angular difference between two angles. Takes angle1 (first angle in degrees), angle2 (second angle in degrees). Returns the shortest signed angular distance from angle1 to angle2 in degrees, wrapped to the range [-180, 180].

Technical Exegesis...

Returns the shortest signed angular distance from angle1 to angle2 in degrees, wrapped to the range [-180, 180].

Accounts for angle wrapping, so the difference between 350 degrees and 10 degrees is 20 degrees (not 340 degrees). Useful for rotating towards a target angle by the shortest path.

Example

Example.bam
; No example implemented yet