function rad(degrees) { var pi = Math.PI; return degrees * (pi / 180); }