config root man

Current Path : /usr/opt/perl530/man/man3/

FreeBSD hs32.drive.ne.jp 9.1-RELEASE FreeBSD 9.1-RELEASE #1: Wed Jan 14 12:18:08 JST 2015 root@hs32.drive.ne.jp:/sys/amd64/compile/hs32 amd64
Upload File :
Current File : //usr/opt/perl530/man/man3/Math::Trig.3

.\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.35)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings.  \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote.  \*(C+ will
.\" give a nicer C++.  Capital omega is used to do unbreakable dashes and
.\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
.    ds -- \(*W-
.    ds PI pi
.    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
.    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
.    ds L" ""
.    ds R" ""
.    ds C` ""
.    ds C' ""
'br\}
.el\{\
.    ds -- \|\(em\|
.    ds PI \(*p
.    ds L" ``
.    ds R" ''
.    ds C`
.    ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\"
.\" If the F register is >0, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD.  Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{\
.    if \nF \{\
.        de IX
.        tm Index:\\$1\t\\n%\t"\\$2"
..
.        if !\nF==2 \{\
.            nr % 0
.            nr F 2
.        \}
.    \}
.\}
.rr rF
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear.  Run.  Save yourself.  No user-serviceable parts.
.    \" fudge factors for nroff and troff
.if n \{\
.    ds #H 0
.    ds #V .8m
.    ds #F .3m
.    ds #[ \f1
.    ds #] \fP
.\}
.if t \{\
.    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
.    ds #V .6m
.    ds #F 0
.    ds #[ \&
.    ds #] \&
.\}
.    \" simple accents for nroff and troff
.if n \{\
.    ds ' \&
.    ds ` \&
.    ds ^ \&
.    ds , \&
.    ds ~ ~
.    ds /
.\}
.if t \{\
.    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
.    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
.    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
.    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
.    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
.    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
.    \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
.    \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
.    \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
.    ds : e
.    ds 8 ss
.    ds o a
.    ds d- d\h'-1'\(ga
.    ds D- D\h'-1'\(hy
.    ds th \o'bp'
.    ds Th \o'LP'
.    ds ae ae
.    ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "Math::Trig 3"
.TH Math::Trig 3 "2019-10-24" "perl v5.30.2" "Perl Programmers Reference Guide"
.\" For nroff, turn off justification.  Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
Math::Trig \- trigonometric functions
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 1
\&    use Math::Trig;
\&
\&    $x = tan(0.9);
\&    $y = acos(3.7);
\&    $z = asin(2.4);
\&
\&    $halfpi = pi/2;
\&
\&    $rad = deg2rad(120);
\&
\&    # Import constants pi2, pip2, pip4 (2*pi, pi/2, pi/4).
\&    use Math::Trig \*(Aq:pi\*(Aq;
\&
\&    # Import the conversions between cartesian/spherical/cylindrical.
\&    use Math::Trig \*(Aq:radial\*(Aq;
\&
\&        # Import the great circle formulas.
\&    use Math::Trig \*(Aq:great_circle\*(Aq;
.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
\&\f(CW\*(C`Math::Trig\*(C'\fR defines many trigonometric functions not defined by the
core Perl which defines only the \f(CW\*(C`sin()\*(C'\fR and \f(CW\*(C`cos()\*(C'\fR.  The constant
\&\fBpi\fR is also defined as are a few convenience functions for angle
conversions, and \fIgreat circle formulas\fR for spherical movement.
.SH "TRIGONOMETRIC FUNCTIONS"
.IX Header "TRIGONOMETRIC FUNCTIONS"
The tangent
.IP "\fBtan\fR" 4
.IX Item "tan"
.PP
The cofunctions of the sine, cosine, and tangent (cosec/csc and cotan/cot
are aliases)
.PP
\&\fBcsc\fR, \fBcosec\fR, \fBsec\fR, \fBsec\fR, \fBcot\fR, \fBcotan\fR
.PP
The arcus (also known as the inverse) functions of the sine, cosine,
and tangent
.PP
\&\fBasin\fR, \fBacos\fR, \fBatan\fR
.PP
The principal value of the arc tangent of y/x
.PP
\&\fBatan2\fR(y, x)
.PP
The arcus cofunctions of the sine, cosine, and tangent (acosec/acsc
and acotan/acot are aliases).  Note that atan2(0, 0) is not well-defined.
.PP
\&\fBacsc\fR, \fBacosec\fR, \fBasec\fR, \fBacot\fR, \fBacotan\fR
.PP
The hyperbolic sine, cosine, and tangent
.PP
\&\fBsinh\fR, \fBcosh\fR, \fBtanh\fR
.PP
The cofunctions of the hyperbolic sine, cosine, and tangent (cosech/csch
and cotanh/coth are aliases)
.PP
\&\fBcsch\fR, \fBcosech\fR, \fBsech\fR, \fBcoth\fR, \fBcotanh\fR
.PP
The area (also known as the inverse) functions of the hyperbolic
sine, cosine, and tangent
.PP
\&\fBasinh\fR, \fBacosh\fR, \fBatanh\fR
.PP
The area cofunctions of the hyperbolic sine, cosine, and tangent
(acsch/acosech and acoth/acotanh are aliases)
.PP
\&\fBacsch\fR, \fBacosech\fR, \fBasech\fR, \fBacoth\fR, \fBacotanh\fR
.PP
The trigonometric constant \fBpi\fR and some of handy multiples
of it are also defined.
.PP
\&\fBpi, pi2, pi4, pip2, pip4\fR
.SS "\s-1ERRORS DUE TO DIVISION BY ZERO\s0"
.IX Subsection "ERRORS DUE TO DIVISION BY ZERO"
The following functions
.PP
.Vb 10
\&    acoth
\&    acsc
\&    acsch
\&    asec
\&    asech
\&    atanh
\&    cot
\&    coth
\&    csc
\&    csch
\&    sec
\&    sech
\&    tan
\&    tanh
.Ve
.PP
cannot be computed for all arguments because that would mean dividing
by zero or taking logarithm of zero. These situations cause fatal
runtime errors looking like this
.PP
.Vb 3
\&    cot(0): Division by zero.
\&    (Because in the definition of cot(0), the divisor sin(0) is 0)
\&    Died at ...
.Ve
.PP
or
.PP
.Vb 2
\&    atanh(\-1): Logarithm of zero.
\&    Died at...
.Ve
.PP
For the \f(CW\*(C`csc\*(C'\fR, \f(CW\*(C`cot\*(C'\fR, \f(CW\*(C`asec\*(C'\fR, \f(CW\*(C`acsc\*(C'\fR, \f(CW\*(C`acot\*(C'\fR, \f(CW\*(C`csch\*(C'\fR, \f(CW\*(C`coth\*(C'\fR,
\&\f(CW\*(C`asech\*(C'\fR, \f(CW\*(C`acsch\*(C'\fR, the argument cannot be \f(CW0\fR (zero).  For the
\&\f(CW\*(C`atanh\*(C'\fR, \f(CW\*(C`acoth\*(C'\fR, the argument cannot be \f(CW1\fR (one).  For the
\&\f(CW\*(C`atanh\*(C'\fR, \f(CW\*(C`acoth\*(C'\fR, the argument cannot be \f(CW\*(C`\-1\*(C'\fR (minus one).  For the
\&\f(CW\*(C`tan\*(C'\fR, \f(CW\*(C`sec\*(C'\fR, \f(CW\*(C`tanh\*(C'\fR, \f(CW\*(C`sech\*(C'\fR, the argument cannot be \fIpi/2 + k *
pi\fR, where \fIk\fR is any integer.
.PP
Note that atan2(0, 0) is not well-defined.
.SS "\s-1SIMPLE\s0 (\s-1REAL\s0) \s-1ARGUMENTS, COMPLEX RESULTS\s0"
.IX Subsection "SIMPLE (REAL) ARGUMENTS, COMPLEX RESULTS"
Please note that some of the trigonometric functions can break out
from the \fBreal axis\fR into the \fBcomplex plane\fR. For example
\&\f(CWasin(2)\fR has no definition for plain real numbers but it has
definition for complex numbers.
.PP
In Perl terms this means that supplying the usual Perl numbers (also
known as scalars, please see perldata) as input for the
trigonometric functions might produce as output results that no more
are simple real numbers: instead they are complex numbers.
.PP
The \f(CW\*(C`Math::Trig\*(C'\fR handles this by using the \f(CW\*(C`Math::Complex\*(C'\fR package
which knows how to handle complex numbers, please see Math::Complex
for more information. In practice you need not to worry about getting
complex numbers as results because the \f(CW\*(C`Math::Complex\*(C'\fR takes care of
details like for example how to display complex numbers. For example:
.PP
.Vb 1
\&    print asin(2), "\en";
.Ve
.PP
should produce something like this (take or leave few last decimals):
.PP
.Vb 1
\&    1.5707963267949\-1.31695789692482i
.Ve
.PP
That is, a complex number with the real part of approximately \f(CW1.571\fR
and the imaginary part of approximately \f(CW\*(C`\-1.317\*(C'\fR.
.SH "PLANE ANGLE CONVERSIONS"
.IX Header "PLANE ANGLE CONVERSIONS"
(Plane, 2\-dimensional) angles may be converted with the following functions.
.IP "deg2rad" 4
.IX Item "deg2rad"
.Vb 1
\&    $radians  = deg2rad($degrees);
.Ve
.IP "grad2rad" 4
.IX Item "grad2rad"
.Vb 1
\&    $radians  = grad2rad($gradians);
.Ve
.IP "rad2deg" 4
.IX Item "rad2deg"
.Vb 1
\&    $degrees  = rad2deg($radians);
.Ve
.IP "grad2deg" 4
.IX Item "grad2deg"
.Vb 1
\&    $degrees  = grad2deg($gradians);
.Ve
.IP "deg2grad" 4
.IX Item "deg2grad"
.Vb 1
\&    $gradians = deg2grad($degrees);
.Ve
.IP "rad2grad" 4
.IX Item "rad2grad"
.Vb 1
\&    $gradians = rad2grad($radians);
.Ve
.PP
The full circle is 2 \fIpi\fR radians or \fI360\fR degrees or \fI400\fR gradians.
The result is by default wrapped to be inside the [0, {2pi,360,400}[ circle.
If you don't want this, supply a true second argument:
.PP
.Vb 2
\&    $zillions_of_radians  = deg2rad($zillions_of_degrees, 1);
\&    $negative_degrees     = rad2deg($negative_radians, 1);
.Ve
.PP
You can also do the wrapping explicitly by \fBrad2rad()\fR, \fBdeg2deg()\fR, and
\&\fBgrad2grad()\fR.
.IP "rad2rad" 4
.IX Item "rad2rad"
.Vb 1
\&    $radians_wrapped_by_2pi = rad2rad($radians);
.Ve
.IP "deg2deg" 4
.IX Item "deg2deg"
.Vb 1
\&    $degrees_wrapped_by_360 = deg2deg($degrees);
.Ve
.IP "grad2grad" 4
.IX Item "grad2grad"
.Vb 1
\&    $gradians_wrapped_by_400 = grad2grad($gradians);
.Ve
.SH "RADIAL COORDINATE CONVERSIONS"
.IX Header "RADIAL COORDINATE CONVERSIONS"
\&\fBRadial coordinate systems\fR are the \fBspherical\fR and the \fBcylindrical\fR
systems, explained shortly in more detail.
.PP
You can import radial coordinate conversion functions by using the
\&\f(CW\*(C`:radial\*(C'\fR tag:
.PP
.Vb 1
\&    use Math::Trig \*(Aq:radial\*(Aq;
\&
\&    ($rho, $theta, $z)     = cartesian_to_cylindrical($x, $y, $z);
\&    ($rho, $theta, $phi)   = cartesian_to_spherical($x, $y, $z);
\&    ($x, $y, $z)           = cylindrical_to_cartesian($rho, $theta, $z);
\&    ($rho_s, $theta, $phi) = cylindrical_to_spherical($rho_c, $theta, $z);
\&    ($x, $y, $z)           = spherical_to_cartesian($rho, $theta, $phi);
\&    ($rho_c, $theta, $z)   = spherical_to_cylindrical($rho_s, $theta, $phi);
.Ve
.PP
\&\fBAll angles are in radians\fR.
.SS "\s-1COORDINATE SYSTEMS\s0"
.IX Subsection "COORDINATE SYSTEMS"
\&\fBCartesian\fR coordinates are the usual rectangular \fI(x, y, z)\fR\-coordinates.
.PP
Spherical coordinates, \fI(rho, theta, pi)\fR, are three-dimensional
coordinates which define a point in three-dimensional space.  They are
based on a sphere surface.  The radius of the sphere is \fBrho\fR, also
known as the \fIradial\fR coordinate.  The angle in the \fIxy\fR\-plane
(around the \fIz\fR\-axis) is \fBtheta\fR, also known as the \fIazimuthal\fR
coordinate.  The angle from the \fIz\fR\-axis is \fBphi\fR, also known as the
\&\fIpolar\fR coordinate.  The North Pole is therefore \fI0, 0, rho\fR, and
the Gulf of Guinea (think of the missing big chunk of Africa) \fI0,
pi/2, rho\fR.  In geographical terms \fIphi\fR is latitude (northward
positive, southward negative) and \fItheta\fR is longitude (eastward
positive, westward negative).
.PP
\&\fB\s-1BEWARE\s0\fR: some texts define \fItheta\fR and \fIphi\fR the other way round,
some texts define the \fIphi\fR to start from the horizontal plane, some
texts use \fIr\fR in place of \fIrho\fR.
.PP
Cylindrical coordinates, \fI(rho, theta, z)\fR, are three-dimensional
coordinates which define a point in three-dimensional space.  They are
based on a cylinder surface.  The radius of the cylinder is \fBrho\fR,
also known as the \fIradial\fR coordinate.  The angle in the \fIxy\fR\-plane
(around the \fIz\fR\-axis) is \fBtheta\fR, also known as the \fIazimuthal\fR
coordinate.  The third coordinate is the \fIz\fR, pointing up from the
\&\fBtheta\fR\-plane.
.SS "3\-D \s-1ANGLE CONVERSIONS\s0"
.IX Subsection "3-D ANGLE CONVERSIONS"
Conversions to and from spherical and cylindrical coordinates are
available.  Please notice that the conversions are not necessarily
reversible because of the equalities like \fIpi\fR angles being equal to
\&\fI\-pi\fR angles.
.IP "cartesian_to_cylindrical" 4
.IX Item "cartesian_to_cylindrical"
.Vb 1
\&    ($rho, $theta, $z) = cartesian_to_cylindrical($x, $y, $z);
.Ve
.IP "cartesian_to_spherical" 4
.IX Item "cartesian_to_spherical"
.Vb 1
\&    ($rho, $theta, $phi) = cartesian_to_spherical($x, $y, $z);
.Ve
.IP "cylindrical_to_cartesian" 4
.IX Item "cylindrical_to_cartesian"
.Vb 1
\&    ($x, $y, $z) = cylindrical_to_cartesian($rho, $theta, $z);
.Ve
.IP "cylindrical_to_spherical" 4
.IX Item "cylindrical_to_spherical"
.Vb 1
\&    ($rho_s, $theta, $phi) = cylindrical_to_spherical($rho_c, $theta, $z);
.Ve
.Sp
Notice that when \f(CW$z\fR is not 0 \f(CW$rho_s\fR is not equal to \f(CW$rho_c\fR.
.IP "spherical_to_cartesian" 4
.IX Item "spherical_to_cartesian"
.Vb 1
\&    ($x, $y, $z) = spherical_to_cartesian($rho, $theta, $phi);
.Ve
.IP "spherical_to_cylindrical" 4
.IX Item "spherical_to_cylindrical"
.Vb 1
\&    ($rho_c, $theta, $z) = spherical_to_cylindrical($rho_s, $theta, $phi);
.Ve
.Sp
Notice that when \f(CW$z\fR is not 0 \f(CW$rho_c\fR is not equal to \f(CW$rho_s\fR.
.SH "GREAT CIRCLE DISTANCES AND DIRECTIONS"
.IX Header "GREAT CIRCLE DISTANCES AND DIRECTIONS"
A great circle is section of a circle that contains the circle
diameter: the shortest distance between two (non-antipodal) points on
the spherical surface goes along the great circle connecting those two
points.
.SS "great_circle_distance"
.IX Subsection "great_circle_distance"
You can compute spherical distances, called \fBgreat circle distances\fR,
by importing the \fBgreat_circle_distance()\fR function:
.PP
.Vb 1
\&  use Math::Trig \*(Aqgreat_circle_distance\*(Aq;
\&
\&  $distance = great_circle_distance($theta0, $phi0, $theta1, $phi1, [, $rho]);
.Ve
.PP
The \fIgreat circle distance\fR is the shortest distance between two
points on a sphere.  The distance is in \f(CW$rho\fR units.  The \f(CW$rho\fR is
optional, it defaults to 1 (the unit sphere), therefore the distance
defaults to radians.
.PP
If you think geographically the \fItheta\fR are longitudes: zero at the
Greenwhich meridian, eastward positive, westward negative \*(-- and the
\&\fIphi\fR are latitudes: zero at the North Pole, northward positive,
southward negative.  \fB\s-1NOTE\s0\fR: this formula thinks in mathematics, not
geographically: the \fIphi\fR zero is at the North Pole, not at the
Equator on the west coast of Africa (Bay of Guinea).  You need to
subtract your geographical coordinates from \fIpi/2\fR (also known as 90
degrees).
.PP
.Vb 2
\&  $distance = great_circle_distance($lon0, pi/2 \- $lat0,
\&                                    $lon1, pi/2 \- $lat1, $rho);
.Ve
.SS "great_circle_direction"
.IX Subsection "great_circle_direction"
The direction you must follow the great circle (also known as \fIbearing\fR)
can be computed by the \fBgreat_circle_direction()\fR function:
.PP
.Vb 1
\&  use Math::Trig \*(Aqgreat_circle_direction\*(Aq;
\&
\&  $direction = great_circle_direction($theta0, $phi0, $theta1, $phi1);
.Ve
.SS "great_circle_bearing"
.IX Subsection "great_circle_bearing"
Alias 'great_circle_bearing' for 'great_circle_direction' is also available.
.PP
.Vb 1
\&  use Math::Trig \*(Aqgreat_circle_bearing\*(Aq;
\&
\&  $direction = great_circle_bearing($theta0, $phi0, $theta1, $phi1);
.Ve
.PP
The result of great_circle_direction is in radians, zero indicating
straight north, pi or \-pi straight south, pi/2 straight west, and
\&\-pi/2 straight east.
.SS "great_circle_destination"
.IX Subsection "great_circle_destination"
You can inversely compute the destination if you know the
starting point, direction, and distance:
.PP
.Vb 1
\&  use Math::Trig \*(Aqgreat_circle_destination\*(Aq;
\&
\&  # $diro is the original direction,
\&  # for example from great_circle_bearing().
\&  # $distance is the angular distance in radians,
\&  # for example from great_circle_distance().
\&  # $thetad and $phid are the destination coordinates,
\&  # $dird is the final direction at the destination.
\&
\&  ($thetad, $phid, $dird) =
\&    great_circle_destination($theta, $phi, $diro, $distance);
.Ve
.PP
or the midpoint if you know the end points:
.SS "great_circle_midpoint"
.IX Subsection "great_circle_midpoint"
.Vb 1
\&  use Math::Trig \*(Aqgreat_circle_midpoint\*(Aq;
\&
\&  ($thetam, $phim) =
\&    great_circle_midpoint($theta0, $phi0, $theta1, $phi1);
.Ve
.PP
The \fBgreat_circle_midpoint()\fR is just a special case of
.SS "great_circle_waypoint"
.IX Subsection "great_circle_waypoint"
.Vb 1
\&  use Math::Trig \*(Aqgreat_circle_waypoint\*(Aq;
\&
\&  ($thetai, $phii) =
\&    great_circle_waypoint($theta0, $phi0, $theta1, $phi1, $way);
.Ve
.PP
Where the \f(CW$way\fR is a value from zero ($theta0, \f(CW$phi0\fR) to one ($theta1,
\&\f(CW$phi1\fR).  Note that antipodal points (where their distance is \fIpi\fR
radians) do not have waypoints between them (they would have an an
\&\*(L"equator\*(R" between them), and therefore \f(CW\*(C`undef\*(C'\fR is returned for
antipodal points.  If the points are the same and the distance
therefore zero and all waypoints therefore identical, the first point
(either point) is returned.
.PP
The thetas, phis, direction, and distance in the above are all in radians.
.PP
You can import all the great circle formulas by
.PP
.Vb 1
\&  use Math::Trig \*(Aq:great_circle\*(Aq;
.Ve
.PP
Notice that the resulting directions might be somewhat surprising if
you are looking at a flat worldmap: in such map projections the great
circles quite often do not look like the shortest routes \*(--  but for
example the shortest possible routes from Europe or North America to
Asia do often cross the polar regions.  (The common Mercator projection
does \fBnot\fR show great circles as straight lines: straight lines in the
Mercator projection are lines of constant bearing.)
.SH "EXAMPLES"
.IX Header "EXAMPLES"
To calculate the distance between London (51.3N 0.5W) and Tokyo
(35.7N 139.8E) in kilometers:
.PP
.Vb 1
\&    use Math::Trig qw(great_circle_distance deg2rad);
\&
\&    # Notice the 90 \- latitude: phi zero is at the North Pole.
\&    sub NESW { deg2rad($_[0]), deg2rad(90 \- $_[1]) }
\&    my @L = NESW( \-0.5, 51.3);
\&    my @T = NESW(139.8, 35.7);
\&    my $km = great_circle_distance(@L, @T, 6378); # About 9600 km.
.Ve
.PP
The direction you would have to go from London to Tokyo (in radians,
straight north being zero, straight east being pi/2).
.PP
.Vb 1
\&    use Math::Trig qw(great_circle_direction);
\&
\&    my $rad = great_circle_direction(@L, @T); # About 0.547 or 0.174 pi.
.Ve
.PP
The midpoint between London and Tokyo being
.PP
.Vb 1
\&    use Math::Trig qw(great_circle_midpoint);
\&
\&    my @M = great_circle_midpoint(@L, @T);
.Ve
.PP
or about 69 N 89 E, in the frozen wastes of Siberia.
.PP
\&\fB\s-1NOTE\s0\fR: you \fBcannot\fR get from A to B like this:
.PP
.Vb 3
\&   Dist = great_circle_distance(A, B)
\&   Dir  = great_circle_direction(A, B)
\&   C    = great_circle_destination(A, Dist, Dir)
.Ve
.PP
and expect C to be B, because the bearing constantly changes when
going from A to B (except in some special case like the meridians or
the circles of latitudes) and in \fBgreat_circle_destination()\fR one gives
a \fBconstant\fR bearing to follow.
.SS "\s-1CAVEAT FOR GREAT CIRCLE FORMULAS\s0"
.IX Subsection "CAVEAT FOR GREAT CIRCLE FORMULAS"
The answers may be off by few percentages because of the irregular
(slightly aspherical) form of the Earth.  The errors are at worst
about 0.55%, but generally below 0.3%.
.SS "Real-valued asin and acos"
.IX Subsection "Real-valued asin and acos"
For small inputs \fBasin()\fR and \fBacos()\fR may return complex numbers even
when real numbers would be enough and correct, this happens because of
floating-point inaccuracies.  You can see these inaccuracies for
example by trying theses:
.PP
.Vb 2
\&  print cos(1e\-6)**2+sin(1e\-6)**2 \- 1,"\en";
\&  printf "%.20f", cos(1e\-6)**2+sin(1e\-6)**2,"\en";
.Ve
.PP
which will print something like this
.PP
.Vb 2
\&  \-1.11022302462516e\-16
\&  0.99999999999999988898
.Ve
.PP
even though the expected results are of course exactly zero and one.
The formulas used to compute \fBasin()\fR and \fBacos()\fR are quite sensitive to
this, and therefore they might accidentally slip into the complex
plane even when they should not.  To counter this there are two
interfaces that are guaranteed to return a real-valued output.
.IP "asin_real" 4
.IX Item "asin_real"
.Vb 1
\&    use Math::Trig qw(asin_real);
\&
\&    $real_angle = asin_real($input_sin);
.Ve
.Sp
Return a real-valued arcus sine if the input is between [\-1, 1],
\&\fBinclusive\fR the endpoints.  For inputs greater than one, pi/2
is returned.  For inputs less than minus one, \-pi/2 is returned.
.IP "acos_real" 4
.IX Item "acos_real"
.Vb 1
\&    use Math::Trig qw(acos_real);
\&
\&    $real_angle = acos_real($input_cos);
.Ve
.Sp
Return a real-valued arcus cosine if the input is between [\-1, 1],
\&\fBinclusive\fR the endpoints.  For inputs greater than one, zero
is returned.  For inputs less than minus one, pi is returned.
.SH "BUGS"
.IX Header "BUGS"
Saying \f(CW\*(C`use Math::Trig;\*(C'\fR exports many mathematical routines in the
caller environment and even overrides some (\f(CW\*(C`sin\*(C'\fR, \f(CW\*(C`cos\*(C'\fR).  This is
construed as a feature by the Authors, actually... ;\-)
.PP
The code is not optimized for speed, especially because we use
\&\f(CW\*(C`Math::Complex\*(C'\fR 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 \f(CWasin(2)\fR to give
an answer instead of giving a fatal runtime error.
.PP
Do not attempt navigation using these formulas.
.PP
Math::Complex
.SH "AUTHORS"
.IX Header "AUTHORS"
Jarkko Hietaniemi <\fIjhi!at!iki.fi\fR>,
Raphael Manfredi <\fIRaphael_Manfredi!at!pobox.com\fR>,
Zefram <zefram@fysh.org>
.SH "LICENSE"
.IX Header "LICENSE"
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.

Man Man