UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

21 lines (16 loc) 400 B
import { PI2 } from "../math/PI2.js"; /** * Force angle to [-PI, +PI] range * * @param {number} angle in radians * @return {number} in radians */ export function normalize_angle_rad(angle) { // based on answer https://stackoverflow.com/a/2323034/3973586 let r = angle % PI2; r = (r + PI2) % PI2; if (r > Math.PI) { r -= PI2; } return r; }