Astro::Montenbruck::Core::MathUtils - Core mathematical routines used by AstroScript modules.
Version 0.01
use Astro::Montenbruck::Core::MathUtils qw/dms/; my ($d, $m, $s) = dms(55.75); # (55, 45, 0) ...
"frac($x)"
"frac360($x)"
"dms($x)"
"hms($x)"
"zdms($x)"
"ddd($deg[, $min[, $sec]])"
"polynome($t, @terms)"
"to_range($x, $range)"
"reduce_deg($x)"
"reduce_rad($x)"
"opposite_deg($x)"
"opposite_rad($x)"
"angle_c($x, $y)"
"angle_c_rad($x, $y)"
"angle_s($x1, $y1, $x2, $y2)"
"diff_angle($a, $b, $mode='degrees')"
"cart($r, $theta, $phi)"
"polar($x, $y, $z)"
Fractional part of a decimal number.
Range function, similar to "to_range($x, $range)", used with polinomial function for better accuracy.
Given decimal hours (or degrees), return nearest hours (or degrees), int, minutes, int, and seconds, float.
decimal value, 0..360 for angular mode, 0..24 for time
places (optional) amount of required sexadecimal values to be returned (1-3); default = 3 (degrees/hours, minutes, seconds)
array of degrees (int), minutes (int), seconds (float)
Alias for "dms"
Converts decimal degrees to zodiac sign number (zero based), zodiac degrees, minutes and seconds.
array of zodiac sign (0-11), degrees (int), minutes (int), seconds (float)
Converts sexadecimal values to decimal.
1 to 3 sexadecimal values, such as: degrees, minutes and seconds, or degrees and minutes, or just degrees:
ddd(11)
ddd(11, 46)
ddd(11, 46, 20)
If any non-zero argument is negative, the result is negative.
ddd(-11, 46, 0) = -11.766666666666667
ddd(11, -46, 0) = 11.766666666666667
Negative sign in wrong position is ignored.
decimal (degrees or hours)
Calculates polynome: $a1 + $a2*$t + $a3*$t*$t + $a4*$t*$t*$t...
$t coefficient, in astronomical routines usually time in centuries
any number of decimal values
decimal number
Reduces $x to 0 >= $x < $range
number to reduce
limit (non-inclusive), e.g: 360 for degrees, 24 for hours
number
Reduces $x to 0 >= $x < 360
Reduces $x to 0 >= $x < pi2
Returns opposite degree.
Returns opposite radian.
Calculate shortest arc in dergees between $x and $y.
Calculates shortest arc in radians between $x and $y.
Calculates arc between 2 points on a sphera. Expected arguments: 2 pairs of coordinates (X, Y) of the 2 points.
The coordinates may be ecliptic, equatorial or horizontal.
Return angle $b - $a, accounting for circular values.
$b - $a
Parameters $a and $b should be in the range 0..pi*2 or 0..360, depending on optional $mode argument. The result will be in the range -pi..pi or -180..180. This allows us to directly compare angles which cross through 0: 359 degress... 0 degrees... 1 degree... etc.
$a first angle, in radians or degrees
$b second angle, in radians or degrees
$mode "degrees" (default) or "radians", case insensitive.
"degrees"
"radians"
Calculate sin(phi); phi in units of 1 revolution = 360 degrees
Conversion of polar coordinates (r,theta,phi) into certesian (x,y,z).
$r, distance from the origin;
$theta (in radians) corresponding to [-90 deg, +90 deg];
$phi (in radians) corresponding to [-360 deg, +360 deg])
Rectangular coordinates:
$x, X
$y, Y
$z, Z
Conversion of cartesian coordinates (x,y,z) into polar (r,theta,phi).
Spherical coordinates:
Sergey Krushinsky, <krushi at cpan.org>
<krushi at cpan.org>
Copyright 2009-2019 Sergey Krushinsky.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Astro::Montenbruck, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Astro::Montenbruck
CPAN shell
perl -MCPAN -e shell install Astro::Montenbruck
For more information on module installation, please visit the detailed CPAN module installation guide.