@tempots/std

interpolateAngle() function

Interpolates values in a polar coordinate system looking for the narrowest delta angle. It can be either clock-wise or counter-clock-wise.

Signature:

interpolateAngle: (a: number, b: number, t: number, turn?: number) => number

Parameters

Parameter

Type

Description

a

number

The first angle in degrees.

b

number

The second angle in degrees.

t

number

The interpolation value.

turn

number

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

Returns: number

The interpolated angle.

Example

interpolateAngle(0, 90, 0.5) // returns 45
interpolateAngle(0, 270, 0.5) // returns 315
interpolateAngle(0, 90, 0.25) // returns 22.5
interpolateAngle(0, 270, 0.25) // returns 337.5