Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | 1x 1x 357x 357x | import { type AngleUnit, angleUnits } from './angle.ts'; /** * Converts an angle from one unit to another. * @param input - Angle to convert * @param from - The input unit of the angle * @param to - The output unit of the angle * @returns Converted angle. * @example * ```typescript * toAngle(180, 'degrees'); // π * toAngle(Math.PI, 'radians', 'degrees'); // 180 * toAngle(1, 'turns', 'radians'); // 2π * ``` * @group Geometry * @category Angle */ export function toAngle(input: number, from: AngleUnit, to: AngleUnit = 'radians'): number { return (input / angleUnits[from]) * angleUnits[to]; } |