Here you can find the source of modPI2(double angle)
public static double modPI2(double angle)
//package com.java2s; //License from project: Open Source License public class Main { public static double modPI2(double angle) { while (angle < -Math.PI) angle += 2.0 * Math.PI; while (angle > Math.PI) angle -= 2.0 * Math.PI; return angle; }/* w w w .j a va 2 s .c om*/ }