All files to-radians.ts

100% Statements 4/4
100% Branches 1/1
100% Functions 1/1
100% Lines 4/4

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 201x                               1x 24x 24x  
import { angleUnits, type UnitOptions } from './angle.ts';
 
/**
 * Converts degrees to radians.
 * @param angle - Angle.
 * @param options - see {@link UnitOptions}
 * @returns Angle in radians.
 * @example
 * ```typescript
 * toRadians(180); // π
 * toRadians(90, 'degrees'); // π/2
 * toRadians(0.5, 'turns'); // π
 * ```
 * @group Geometry
 * @category Angle
 */
export function toRadians(angle: number, { unit = 'degrees' }: UnitOptions = {}): number {
  return (angleUnits.radians * angle) / angleUnits[unit];
}