The percentToAngle() function calculates the angle corresponding to a given percentage value within a specified range of start and end angles. It considers a circle start angle as a reference and returns the resulting angle based on whether the rotation is clockwise or counterclockwise.
import { percentToAngle } from 'mz-math';
const angle1 = percentToAngle(0, 0, 90); // 0 degrees
const angle2 = percentToAngle(percentToAngle(50, 0, 90)); // 45 degrees
const angle3 = percentToAngle(percentToAngle(100, 0, 90)); // 90 degrees
The function signature is:
const percentToAngle: (percent: number, startAngleDeg: number, endAngleDeg: number, circleStartAngle?: number) => number;