decla-red/shared/src/physics/interpolate-angles.ts
2026-06-14 20:58:42 +01:00

6 lines
266 B
TypeScript

export const interpolateAngles = (from: number, to: number, q: number) => {
const max = Math.PI * 2;
const possibleDistance = (to - from) % max;
const shorterDistance = ((2 * possibleDistance) % max) - possibleDistance;
return from + shorterDistance * q;
};