Welcome to the Monastery | |
PerlMonks |
Re: Code refactoring: simple trig, but it's been so long.by Zaxo (Archbishop) |
on Dec 30, 2004 at 02:02 UTC ( [id://418155]=note: print w/replies, xml ) | Need Help?? |
You can save some messing around with, my $angle = atan2 $x2-$x1, $y2-$y1; I think that short-circuiting that is premature optimization, and may be an actual pessimization since FPU's do atan2 atomicly. Atan2 knows what quadrant the angle is in from the signs of its arguments, so you can save checking all those cases. Also, stick with radian measure except possibly for printed display. Those together remove the need for Math::Trig. After Compline,
In Section
Seekers of Perl Wisdom
|
|