@tempots/std

angleDifference() function

Calculates the minimum difference between two angles in degrees.

Signature:

angleDifference: (a: number, b: number, turn?: number) => number

Parameters

Parameter

Type

Description

a

number

The first angle in degrees.

b

number

The second angle in degrees.

turn

number

(Optional) The total number of degrees in a full turn. Default is 360.0.

Returns: number

The difference between the two angles.

Example

angleDifference(0, 90) // returns 90
angleDifference(90, 0) // returns -90
angleDifference(0, 270) // returns -90
angleDifference(270, 0) // returns 90