ATan# ( float# )
Parameters
| float - a tangent value; any number is allowed |
Description
|
Returns the angle, in degrees, whose tangent is the given value. ATan is the inverse of Tan and answers in the range -90 to +90 degrees. Feed it a slope (rise divided by run) and you get the angle of that slope back. Unlike ACos and ASin it accepts any number at all - a tangent can be arbitrarily large - so there is no range to clamp. Very large inputs simply approach 90 degrees. The catch is that a single ratio cannot tell you which way something is pointing. ATan(1) is 45 degrees, but so is the direction pointing down and to the left, whose components divide to the same 1. For aiming a sprite or an entity at a target, use ATan2, which takes the two components separately and covers the full 360 degrees. See also: Tan, ATan2, ASin, ACos, Pi. |
Example
; ATan Example ; ------------ ; ATan is the inverse of Tan: given a slope, it returns the matching ; angle in DEGREES, between -90 and +90. ; A ramp that rises 3 units over a run of 4 units: rise#=3 run#=4 Print "A ramp rising "+rise+" over a run of "+run Print "Slope = rise/run = "+(rise/run) Print "Angle = ATan(slope) = "+ATan(rise/run)+" degrees" Print "" ; Steeper slopes give angles nearer 90, shallow ones nearer 0 Print "ATan(0) = "+ATan(0) Print "ATan(0.5) = "+ATan(0.5) Print "ATan(1) = "+ATan(1) Print "ATan(2) = "+ATan(2) Print "ATan(10) = "+ATan(10) Print "ATan(1000) = "+ATan(1000)+" (never quite reaches 90)" Print "ATan(-1) = "+ATan(-1)+" (negative slopes give negative angles)" Print "" Print "ATan alone cannot tell direction over a full circle - see ATan2." Print "" Print "Press any key to close the example" WaitKey End
Index