You may want to use trigonometric functions, such as sine, cosine, and tangent.
Use sin(), cos(), and tan(). These functions assume all angles are in radians, not degrees.The numbers are in degrees, so use deg2rad() and rad2deg().
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="EN" lang="EN"> <head> <title>Trigonometric Functions</title> <meta Name="Author" Content="Hann So"> </head> <body> <p> <?php echo "<p>the number is in radian.</p>"; $num = 0.785; echo "sin($num): ", sin($num), "<br />"; echo "cos($num): ", cos($num), "<br />"; echo "tan($num): ", tan($num), "<br />"; echo "<p>the number is in degree.</p>"; $num = 45; echo "sin(deg2rad($num)): ", sin(deg2rad($num)), "<br />"; echo "cos(deg2rad($num)): ", cos(deg2rad($num)), "<br />"; echo "tan(deg2rad($num)): ", tan(deg2rad($num)), "<br />"; ?> </p> </body> </html> |