ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Shared functions
  3. getAngleDifference

Function

getAngleDifference

Server and clientMath, vectors and matricesTrilogy Hub only

Returns the shortest difference between two angles in degrees, in the range -180 to 180. Positive when you need to turn towards the increasing angle.

Syntax

float getAngleDifference(float a, float b)

Arguments

afloat
The start angle.
bfloat
The target angle.

Returns

The difference from -180 to 180.

Example

print(getAngleDifference(350, 10))  -- 20
print(getAngleDifference(10, 350))  -- -20

See also