Skip to content

@technobuddha > library > Geometry > Angle

Function: angleDifference()

ts
function angleDifference(
   startAngle: number, 
   endAngle: number, 
   options: UnitOptions): number;

Defined in: angle-difference.ts:25

Computes the difference between startAngle and endAngle.

Parameters

ParameterTypeDescription
startAnglenumberStart angle.
endAnglenumberEnd angle.
optionsUnitOptionssee UnitOptions

Returns

number

The amount that when added to startAngle will result in endAngle.

Remarks

Positive numbers mean that the direction is clockwise. Negative numbers indicate a counter-clockwise direction. The shortest route (clockwise vs counter-clockwise) between the angles is used. When the difference is π radians, the function returns π (not -π)

Example

typescript
angleDifference(Math.PI * 1/6, Math.PI * 2/6); // π * 1/6
angleDifference(Math.PI * 2/6, Math.PI * 1/6); // -π * 1/6.
angleDifference(30, 60, 'deg'); // 30