PHP - Number: Converting Between Degrees and Radians
PHP Number Tips - Part 16: If you want to convert an angle measurement from degrees to radians or vice versa, so you only have to use PHP's rad2deg( ) and deg2rad( ) functions such as:
<?php //result: "90 degrees = 1.57079632679 radians " $degrees = 90; $radians = deg2rad($degrees); echo "$degrees degrees = $radians radians "; //result: "1.57079632679491 radians = 90 degrees" $radians = 1.57079632679491; $degrees = rad2deg($radians); echo "$radians radians = $degrees degrees"; ?>
The formula to convert an angle measurement in degrees (D) to radians (R) is D = R*180/pi. Fortunately, PHP comes with a function to do it for you automatically: the deg2rad( ) function or if you have a value that is already in radians, you can convert it to degrees with the rad2reg( ) function.
Tag: number. degree, radian Category: PHP Basic Post : March 16th 2008 Read: 3,363
blog comments powered by Disqus