home *** CD-ROM | disk | FTP | other *** search
- ############################################################################
- #
- # File: pom.icn
- #
- # Subject: Procedure to compute phase of the moon
- #
- # Author: Ralph E. Griswold
- #
- # Date: September 6, 1992
- #
- ###########################################################################
- #
- # pom(n, phase) returns record with the Julian Day number of fractional
- # part of the day for which the nth such phase since January, 1900. Phases
- # are encodes as: 0 - new moon, 1 - first quarter, 2 - full moon, 3 - last
- # quarter. GMT is assumed.
- #
- ############################################################################
- #
- # Acknowledgement: This procedure is based on an algorithm given in
- # "Numerical Recipes; The Art of Scientific Computing"; William H. Press,
- # Brian P. Flannery, Saul A. Teukolsky. and William T. Vetterling;
- # Cambridge University Press, 1986.
- #
- ############################################################################
-
- record jdate(number, fraction)
-
- procedure pom(n, nph)
- local i, jd, fraction, radians
- local am, as, c, t, t2, extra
-
- radians := &pi / 180
-
- c := n + nph / 4.0
- t := c / 1236.85
- t2 := t * t
- as := 359.2242 + 29.105356 * c
- am := 306.0253 + 385.816918 * c + 0.010730 * t2
- jd := 2415020 + 28 * n + 7 * nph
- extra := 0.75933 + 1.53058868 * c + ((1.178e-4) - (1.55e-7) * t) * t2
-
- if nph = (0 | 2) then
- extra +:= (0.1734 - 3.93e-4 * t) * sin(radians * as) - 0.4068 *
- sin(radians * am)
- else if nph = (1 | 3) then
- extra +:= (0.1721 - 4.0e-4 * t) * sin(radians * as) - 0.6280 *
- sin(radians * am)
- else fail
-
- if extra >= 0 then i := integer(extra)
- else i := integer(extra - 1.0)
- jd +:= i
- fraction := extra - i
-
- return jdate(integer(jd), fraction)
-
- end
-