clamp radian

javascript - 2017-11-17 10:56:40
  clamp radians between 0 & 2 PI
function clampRadians(rad){
    // help for math n00bs : http://www.purplemath.com/modules/radians2.htm
    if(rad != 0){
        var nbTours = rad / (2*Math.PI);
        rad = rad - Math.floor(nbTours) * (2*Math.PI);
    }
    return rad;
}