Core Function ATan
From Sputnik Wiki
(Difference between revisions)
(Created page with "<pre> ATan( <expression> ) </pre> === Description === Calculates the arctangent of a number. === Parameters === ==== expression ==== Any valid numeric expression. === Retur...") |
|||
Line 1: | Line 1: | ||
<pre> | <pre> | ||
− | ATan( <expression> ) | + | ATan( <expression>, <expression2> ) |
</pre> | </pre> | ||
Line 12: | Line 12: | ||
Any valid numeric expression. | Any valid numeric expression. | ||
+ | |||
+ | ==== expression2 ==== | ||
+ | |||
+ | Optional; Any valid numeric expression. | ||
+ | |||
+ | If this param is used this ATan will become ATan2 | ||
=== Return Value === | === Return Value === | ||
− | Returns the trigonometric arctangent of expression. | + | WITH ONE PARAM : |
+ | Returns the trigonometric arctangent of expression. | ||
+ | |||
+ | WITH TWO PARAMS : | ||
+ | Returns the angle whose tangent is the quotient of two specified numbers. | ||
=== Remarks === | === Remarks === | ||
Line 24: | Line 34: | ||
<syntaxhighlight lang="sputnik"> | <syntaxhighlight lang="sputnik"> | ||
+ | // Atan with 1 param | ||
$x = ATan(0.5); | $x = ATan(0.5); | ||
$pi = 4 * ATan(1); | $pi = 4 * ATan(1); | ||
Line 29: | Line 40: | ||
$y = ATan(1) * $radToDeg; | $y = ATan(1) * $radToDeg; | ||
println( "Value is: $y " ); //arctangent of 1 returns 45° | println( "Value is: $y " ); //arctangent of 1 returns 45° | ||
+ | |||
+ | // Atan2 (2 params) | ||
+ | $x = -10.0; | ||
+ | $y = 10.0; | ||
+ | $result = 0; | ||
+ | $result = Atan($y, $x) * 180 / @PI; | ||
+ | printf("The arc tangent for (x=$x, y=$y) is $result degrees.\n"); | ||
+ | // Prints The arc tangent for (x=-10.000000, y=10.000000) is 135.000000 degrees. | ||
</syntaxhighlight> | </syntaxhighlight> | ||
[[Category:Core Function]] | [[Category:Core Function]] |
Revision as of 15:36, 29 November 2011
ATan( <expression>, <expression2> )
Contents |
Description
Calculates the arctangent of a number.
Parameters
expression
Any valid numeric expression.
expression2
Optional; Any valid numeric expression.
If this param is used this ATan will become ATan2
Return Value
WITH ONE PARAM : Returns the trigonometric arctangent of expression.
WITH TWO PARAMS : Returns the angle whose tangent is the quotient of two specified numbers.
Remarks
The result of 4 * ATan(1) is PI.
Example
// Atan with 1 param $x = ATan(0.5); $pi = 4 * ATan(1); $radToDeg = 180 / @PI; $y = ATan(1) * $radToDeg; println( "Value is: $y " ); //arctangent of 1 returns 45° // Atan2 (2 params) $x = -10.0; $y = 10.0; $result = 0; $result = Atan($y, $x) * 180 / @PI; printf("The arc tangent for (x=$x, y=$y) is $result degrees.\n"); // Prints The arc tangent for (x=-10.000000, y=10.000000) is 135.000000 degrees.