From the latter, we obtain the equation 1 radian = (180π)o . This leads us to the rule to convert radian measure to degree measure. To convert from radians to degrees, multiply the radians by 180°π radians .
To convert degrees to radians, we have to multiply the given angle (that is in degrees) by π/180°. For this, we use the formula: Radians = Degrees × π/180°.
That means that 1 radian is equal to 180 degrees divided by π. So, in order to convert radians to degrees, all you have to do is multiply the number of radians by 180 divided by π. For instance, let's say you have to convert 1/2 π radians into degrees. Simply multiply π/2 by 180/ π to get 90 degrees.
radians = degrees * (pi/180)
degrees = radians * (180/pi)
As for implementation, the main question is how precise you want to be about the value of pi. There is some related discussion here
a complete circle in radians is 2*pi. A complete circle in degrees is 360. To go from degrees to radians, it's (d/360) * 2*pi, or d*pi/180.
x rads in degrees - > x*180/pi
x degrees in rads -> x*pi/180
I guess if you wanted to make a function for this [in PHP]:
function convert($type, $num) {
if ($type == "rads") {
$result = $num*180/pi();
}
if ($type == "degs") {
$result = $num*pi()/180;
}
return $result;
}
Yes, that could probably be written better.
In javascript you can do it this way
radians = degrees * (Math.PI/180);
degrees = radians * (180/Math.PI);
This works well enough for me :)
// deg2rad * degrees = radians
#define deg2rad (3.14159265/180.0)
// rad2deg * radians = degrees
#define rad2deg (180/3.14159265)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With