<?Php
echo round(deg2rad(90),2); // Output is 1.57
?>
deg2rad() with sin() cos()
Decimal places
Sin(), cos() and other trigonometric functions takes input in radian so while using if we are using data in degree then we have to convert them first and then use with Sin() , Cos() etc.
<?Php
echo sin(deg2rad(90)); // Output is 1
?>
Let us try few more examples
<?Php
echo sin(deg2rad(0)); // Output is 0
echo "<br>";
echo round(sin(deg2rad(180))); // Output is 0
echo "<br>";
echo sin(deg2rad(270)); // Output is -1
echo "<br>";
echo cos(deg2rad(0)); // Output is 1
echo "<br>";
echo cos(deg2rad(180)); // Output is -1
echo "<br>";
echo tan(deg2rad(45)); // Output is 1
?>