Jump to content

Perl Programming/Keywords/atan2

From Wikibooks, open books for an open world
Previous: and Keywords Next: AUTOLOAD

The atan2 keyword

[edit | edit source]

atan2 is the trigonometric function tangent that returns the arctangent of Y/X in the range -π to π.

Syntax

[edit | edit source]
  atan2 Y, X

Examples

[edit | edit source]
The code
*PI = \3.1415926535;
$a = 3;
$b = 5;
$arctan = atan2($a, $b);

print "arctan(" . $a . ", " . $b . ") = " . $arctan . " rad = " . $arctan*180/$PI . " deg\n";
prints the arc tangent in radians and degrees:
Previous: and Keywords Next: AUTOLOAD