Files
blitzkit/src/core/math/normalizeAngle180.ts
T

12 lines
251 B
TypeScript
Raw Normal View History

2024-01-01 21:03:27 -06:00
export function normalizeAngle180(angle: number) {
const newAngle = angle % (2 * Math.PI);
if (newAngle > Math.PI) {
return newAngle - 2 * Math.PI;
}
if (newAngle < -Math.PI) {
return newAngle + 2 * Math.PI;
}
return newAngle;
}