Skip to content

@technobuddha > library > Geometry > Angle

Function: toAngle() ​

ts
function toAngle(
   input: number, 
   from: AngleUnit, 
   to: AngleUnit): number;

Defined in: to-angle.ts:18

Converts an angle from one unit to another.

Parameters ​

ParameterTypeDefault valueDescription
inputnumberundefinedAngle to convert
fromAngleUnitundefinedThe input unit of the angle
toAngleUnit'radians'The output unit of the angle

Returns ​

number

Converted angle.

Example ​

typescript
toAngle(180, 'degrees'); // π
toAngle(Math.PI, 'radians', 'degrees'); // 180
toAngle(1, 'turns', 'radians'); // 2π