<P><CODE>Math::Trig</CODE> defines many trigonometric functions not defined by the
core Perl which defines only the <A HREF="../../lib/Pod/perlfunc.html#item_sin"><CODE>sin()</CODE></A> and <A HREF="../../lib/Pod/perlfunc.html#item_cos"><CODE>cos()</CODE></A>. The constant
<STRONG>pi</STRONG> is also defined as are a few convenience functions for angle
<P>To calculate the distance between London (51.3N 0.5W) and Tokyo (35.7N
139.8E) in kilometers:</P>
<PRE>
use Math::Trig qw(great_circle_distance deg2rad);</PRE>
<PRE>
# Notice the 90 - latitude: phi zero is at the North Pole.
@L = (deg2rad(-0.5), deg2rad(90 - 51.3));
@T = (deg2rad(139.8),deg2rad(90 - 35.7));</PRE>
<PRE>
$km = great_circle_distance(@L, @T, 6378);</PRE>
<P>The answer may be off by few percentages because of the irregular
(slightly aspherical) form of the Earth. The used formula</P>
<PRE>
lat0 = 90 degrees - phi0
lat1 = 90 degrees - phi1
d = R * arccos(cos(lat0) * cos(lat1) * cos(lon1 - lon01) +
sin(lat0) * sin(lat1))</PRE>
<P>is also somewhat unreliable for small distances (for locations
separated less than about five degrees) because it uses arc cosine
which is rather ill-conditioned for values close to zero.</P>
<P>
<HR>
<H1><A NAME="bugs">BUGS</A></H1>
<P>Saying <CODE>use Math::Trig;</CODE> exports many mathematical routines in the
caller environment and even overrides some (<A HREF="../../lib/Pod/perlfunc.html#item_sin"><CODE>sin</CODE></A>, <A HREF="../../lib/Pod/perlfunc.html#item_cos"><CODE>cos</CODE></A>). This is
construed as a feature by the Authors, actually... ;-)</P>
<P>The code is not optimized for speed, especially because we use
<CODE>Math::Complex</CODE> and thus go quite near complex numbers while doing
the computations even when the arguments are not. This, however,
cannot be completely avoided if we want things like <CODE>asin(2)</CODE> to give
an answer instead of giving a fatal runtime error.</P>
<P>
<HR>
<H1><A NAME="authors">AUTHORS</A></H1>
<P>Jarkko Hietaniemi <<EM><A HREF="mailto:jhi@iki.fi">jhi@iki.fi</A></EM>> and