I try to figure out an angle of a triangle.
If one side of the triangle is 100 and the other side is 100.
How do I get that to be 45 degrees.
If I run tan-1(100/100) on my calculator i get 45. How do I do this in PHP?
Use the atan function.
tan-1(100/100) on the calculator is the equivalent to atan(100/100) in Php.
Edit: Sorry, here's the same output as the calculator:
$input = 100 / 100;
print atan($input) * (180 / pi());
//Ouputs 45
Since you have both rise and run what you really want to use is atan2(), which will handle the difference between e.g. 1/4*pi and -3/4*pi properly.
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