Astro-Utils

 view release on metacpan or  search on metacpan

lib/Astro/Utils.pm  view on Meta::CPAN

    my @c = (1934.136,32964.467,20.186,445267.112,45036.886,
             22518.443,65928.934,3034.906,9037.513,
             33718.147,150.678,2281.226,29929.562,31555.956,
             4443.417,67555.328,4562.452,62894.029,
             31436.921,14577.848,31931.756,34777.259,
             1222.114,16859.074);

    my $s = 0;
    foreach my $i (0..23) {
        $s += ($a[$i] * _cos($b[$i] + ($c[$i] * $t)));
    }

    return $s;
}

sub _jde0 {
    my ($k, $year) = @_;

    # Julian Ephemeris Day Calculation.
    my ($jde0, $y);

    if ($year >= -1000 && $year <= 1000) {
        # Astronmical Algorithms, Chapter 27, page 178 (Table 27.A).
        $y = $year / 1000;

        if ($k == 0) {
            $jde0 = 1721139.29189 +
                    (365242.13740 * $y) +
                    (0.06134 * _pow($y, 2)) +
                    (0.00111 * _pow($y, 3)) -
                    (0.00071 * _pow($y, 4));
        }
        elsif ($k == 1) {
            $jde0 = 1721233.25401 +
                    (365241.72562 * $y) -
                    (0.05323 * _pow($y, 2)) +
                    (0.00907 * _pow($y, 3)) +
                    (0.00025 * _pow($y, 4));
        }
        elsif ($k == 2) {
            $jde0 = 1721325.70455 +
                    (365242.49558 * $y) -
                    (0.11677 * _pow($y, 2)) -
                    (0.00297 * _pow($y, 3)) +
                    (0.00074 * _pow($y, 4));
        }
        elsif ($k == 3) {
            $jde0 = 1721414.39987 +
                    (365242.88257 * $y) -
                    (0.00769 * _pow($y, 2)) -
                    (0.00933 * _pow($y, 3)) -
                    (0.00006 * _pow($y, 4));
        }
    }
    elsif ($year > 1000 && $year <= 3000) {
        # Astronmical Algorithms, Chapter 27, page 178 (Table 27.B).
        $y = ($year - 2000) / 1000;

        if ($k == 0) {
            $jde0 = 2451623.80984 +
                (365242.37404 * $y) +
                (0.05169 * _pow($y, 2)) -
                (0.00411 * _pow($y, 3)) -
                (0.00057 * _pow($y, 4));
        }
        elsif ($k == 1) {
            $jde0 = 2451716.56767 +
                (365241.62603 * $y) +
                (0.00325 * _pow($y, 2)) +
                (0.00888 * _pow($y, 3)) -
                (0.00030 * _pow($y, 4));
        }
        elsif ($k == 2) {
            $jde0 = 2451810.21715 +
                (365242.01767 * $y) -
                (0.11575 * _pow($y, 2)) +
                (0.00337 * _pow($y, 3)) +
                (0.00078 * _pow($y, 4));
        }
        elsif ($k == 3) {
            $jde0 = 2451900.05952 +
                (365242.74049 * $y) -
                (0.06223 * _pow($y, 2)) -
                (0.00823 * _pow($y, 3)) +
                (0.00032 * _pow($y, 4));
        }
    }

    return $jde0;
}

sub _pow {
    my ($n, $m) = @_;

    my $r = 1;
    foreach (1..$m) {
        $r *= $n;
    }

    return $r;
}

sub _cos {
    my ($degree) = @_;

    return cos(($degree * $PI)/180);
}

=head1 AUTHOR

Mohammad S Anwar, C<< <mohammad.anwar at yahoo.com> >>

=head1 REPOSITORY

L<https://github.com/manwar/Astro-Utils>

=head1 BUGS

Please report any  bugs or feature requests to C<bug-astro-utils at rt.cpan.org>,
or through the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Astro-Utils>.
I will  be notified and then you'll automatically be notified of progress on your
bug as I make changes.

=head1 SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc Astro::Utils

You can also look for information at:

=over 4

=item * RT: CPAN's request tracker (report bugs here)

L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Astro-Utils>

=item * AnnoCPAN: Annotated CPAN documentation

L<http://annocpan.org/dist/Astro-Utils>

=item * CPAN Ratings



( run in 2.098 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )