php requires radian arguments to trig functions

Instead of using rad2deg to convert radians to degrees, you should be using deg2rad, as PHP trig functions take radians as arguments, not degrees. See http://php.net/manual/en/function.sin.php.