Garry's Mod Wiki

math.AngleDifference

  number math.AngleDifference( number a, number b )

Description

Calculates the difference between two angles.

Arguments

1 number a
The first angle.
2 number b
The second angle.

Returns

1 number
The difference between the angles between -180 and 180

Example

Find the angle difference between various angles

print("Angle difference between 159 and 240 is " .. math.AngleDifference(159, 240)) print("Angle difference between 240 and 159 is " .. math.AngleDifference(240, 159)) print("Angle difference between 58 and 145 is " .. math.AngleDifference(58, 145))
Output: Angle difference between 159 and 240 is -81
Angle difference between 240 and 159 is 81
Angle difference between 58 and 145 is -87