Measurement of Angle is one of the foundation stones of Geometry and Trigonometry, and the two most commonly used methods of measurement are Degrees and Radians. Because of it’s simplicity many prefer to use degree over Radian. Some of the reasons that makes degrees more preferable are:
- Degrees may not be much efficient while calculating derivatives or complicated relations, but it is easy to understand and visualize.
- While Radian is in fact a ratio, Degree is considered as the unit of rotational displacement where a complete rotation is equivalent to 360 Degrees. Because of this simplicity students are taught and are much more familiar to Degrees rather than Radians.
Thus in some cases we may require to convert from radians to degrees, this is where the method rad2deg() comes in aid.
Parameters: The function takes a single parameter $value which is of type float that represents an angle in Radians.
Return Type: This function returns a float value that represents the Degree equivalent of the given angle $value.
Input : $value = M_PI_4; Output : 45 Input : $value = M_PI_2; Output : 90 Input : $value = M_PI; Output : 180
Below program illustrates the working of rad2deg() in PHP:
pi = 180 pi/2 = 90 pi/4 = 45 pi/8 = 22.5
Important points to note:
- It calculates the Degrees equivalent of the angle given in Radians.
- The counterpart of the method is rad2deg().
- This method produces highly accurate results but is not much time efficient.