You should be able to do this with just the atan2() function.
I just found
this on google. It explains the math pretty well.
Perldoc has this ...
perldoc -f atan2
atan2 Y,X
Returns the arctangent of Y/X in the range -PI to
PI.
For the tangent operation, you may use the
"Math::Trig::tan" function, or use the familiar
relation:
sub tan { sin($_[0]) / cos($_[0]) }
Here's the start of a script you could use ...
bash-2.03$ cat ./atan2.pl
#!/usr/local/bin/perl -w
use strict;
my $x = defined($_=shift) ? $_ : die "Enter X\n";
my $y = defined($_=shift) ? $_ : die "Enter Y\n";
my $r = atan2( $y, $x );
print "angle = $r radians\n";
bash-2.03$ ./atan2.pl 4 3
angle = 0.643501108793284 radians
| Plankton: 1% Evil, 99% Hot Gas. |