About Books Links Bugs History |
About
This is a collection of functions to calculate the phases of the moon and
several astronomical and calendrical data connected to the sun and the moon.
Additional to this there is the Delphi component TMoon
which shows the phase of the moon at a given date.
The component works with Delphi 1 to 6, and probably also the various C++ Builder versions
(I cannot check that one as I don't speak C++), and the algorithm part
should also work with Kylix. It includes full source code,
a complete help file, and it is postcard freeware.
Download TMoon (Zipped archive, 237kB)
It includes the source code for a demo application, a clone of the Moontool - originally a X11
unix software, which was ported to Windows by John Walker, and my version adds
lots of features over the original one. This application can
of course also work without Delphi or TMoon, so here's a complete installation
for it.
Download Moontool installer (Zipped archive, 925kB)
Astronomical Algorithms by Jean Meeus 2nd edition (December 1998), Willmann-Bell, ISBN 0943396611 |
The source for most of the algorithms I used. This book contains a lot of
algorithms for many astronomical calculations. However don't expect
the full astronomical theory (otherwise the book would need thousands of pages),
many of the algorithms are number crunching polynomial terms, so the
description is focusing on how to implement that algorithm. Amazon does not have this book anymore, but you can still get this book directly at the publisher Willman-Bell. The two books Mathematical Astronomy Morsels and More Mathematical Astronomy Morsels are a kind of appendix to this book, they present many fascinating or peculiar results from the algorithms, for example that April 19th is the most common date for Easter. | |
Astronomy on the Personal Computer by Oliver Montenbruck and Thomas Pfleger 4th rev. edition (May 2000), Springer, ISBN 3540672214 | An alternative book on astronomical algorithms for the PC. It's only half the size of the Meeus book, thus it covers much less topics, but of the course the most important ones like moon, sun and planets as well as eclipse are covered. For these calculations much less of the pertubative terms are listed, thus the accuracy is less the those of Meeus - on the other hand the descriptions are a bit more elaborate. See also the publisher's webpage on this book. | |
Explanatory Supplement to the Astronomical Almanac by Kenneth Seidelmann Rev. Edition (1992), University Science Books, ISBN 0935702687 | While the first two books are only covering the algorithms to calculate many astronomical data, this book contains the theory behind them. Starting with the different time frames, coordinate systems, various calendars, but also the geometrical details of calculation solar and lunar eclipses. However the quite high price makes it worth only for those who did not get enough by the previous two books, especially those who want to know why the algorithms are the way they are. Chapter 12 about calendars is also available online (however with some omissions). | |
Calendrical Calculations - The Millennium Edition by Edward M. Reingold, Nachum Dershowitz Revised edition (2001), Cambridge University Press, ISBN 0521777526 |
This book is a real science book covering all the mathematical-algorithmical
aspects of calendars, their conversions, their structure. Being focused on this
mathematical aspect the cultural or historical are mostly left out.
So this book is the definite resource of calendarical algorithms, however it's
definitely no introductory book or a popular science book (see below for
that kind of books), but a real scientific math book. The authors have their own website. | |
Standard C Date/Time Library by Lance Latham May 1998, CMP Books, ISBN 0879304960 |
While the previous book focuses on the mathematical side, this one is focused on the actual programming side of calendarical algorithms. It covers all important present and historic calendars including a proposed calendar of Mars - and it also has reasonably more information on the historic and cultural background, but that also makes it twice a much volume as the previous book. | |
Understanding the Jewish Calendar by Nathan Bushwick February 1989, Moznaim Pub Corp, ISBN 0940118173 |
This book is a complete description of the jewish (hebrew) calendar, however it is focused for a reader with a background in jewish culture, but no knowledge on calendarical things. The first third of the book covers the astronomical basics of calendars - day, lunar month, solar year - and the other part introduces the jewish calendar step by step. But as this is done using many technical terms like the jewish holidays without further explanation (which of course a jew wouldn't need) it's somewhat hard to read. | |
Mapping Time by
E.G. Richards May 2000, Oxford Univ Press, ISBN 0192862057 |
The previous books were more focused on the technical aspects, the following ones are more popular science books about the history of the calendar, however this book is a fine mixture of both. It first introduces into the astronomical basics of calendars, then it does a kind of world trip to introduce many different calendars from all parts of the world and also from history, and finally it gives some algorithms on how to convert between some of them. | |
Marking Time by Duncan Steel 1 edition (December 8, 2000), John Wiley & Sons, ISBN 0471404217 |
A popular science description of the history of the christian calendar, from the calendar reforms of Julius Caesar, the various Easter definitions and their solution, the gregorian calendar reform, proposed but never realized further reforms. Also some calendars from other cultures are shortly mentioned, as well as an appendix giving the astronomical detailed definition of day, month and year. | |
Calendar by David Ewing Duncan 1 edition (November 9, 1999), Bard Books, ISBN 0380793245 |
Another popular science book about the history of the western calendar. It's very similar to the previous book, this one focusing a little bit more on the historic and scientific developements leading to the calendar reform of 1582, thus this part is more detailled then in the previous book. |
Links
Bugs of V2.0
John Walker's Moontool for Windows
Moontool online version (Java)
LunarPhase - a more modern version of the moontool with several additional features; shareware
Moon Calculator - a DOS program with many graphical outputs
VSOP87 the planetary theory paper, the actual tables are found
here
ELP2000 the moon theory paper, the actual tables are found
here
Systems of time - what's the difference between UTC, dynamic time, ephemeride time and so on
Physics and astronomy Java applets by Jürgen Giesen
The Calendar Zone - big selection of calendarical links
The Julian and Gregorian calendar
The Chinese calendar and some other calendrical resources on the web page of
Helmer Aslaksen
LunarCal, chinese calendar software (Charityware)
The jewish (hebrew) calendar
Calendarical Calculations - Website to the book with the same name
Universal Calendar Calculator - shareware software converting between more then 30 calendars
Week numbers - all about how the weeks are counted
What's a blue moon? by Sky and Telescope.
See also the names of the moon for others like the harvest moon
Martian calendar - various proposed calendars for Mars
Bugs of V1.2
You just need to do the patches below, and additionally download the file
ah_def.inc and exchange the one in the archive.
Of course the next version will include the new version.
because of the file moontool.inc missing. There was a version of the archive
without this file for about two days, if you had downloaded it too fast the version now
on this site now is complete.
The calculation of the offset for the local time zone works only properly for time zones
with a daylight saving, for those without daylight saving the time zone is always
used as UTC. To correct the function TimeZoneBias in main.pas
needs to be changed at the two occurances
case GetTimeZoneInformation(tz_info) of
0: result:=tz_info.StandardBias+tz_info.Bias; (* This is new! *)
1: result:=tz_info.StandardBias+tz_info.Bias;
2: result:=tz_info.DaylightBias+tz_info.Bias;
else result:=0;
end;
The function Moon_Position_Horizontal and Sun_Position_Horizontal
don't set the return values elevation and azimuth. To fix add the following two lines at the
end of both functions (Thanks to Ken Otto for reporting):
elevation:=pos1.elevation;
azimuth:=pos1.azimuth;
For a strange reason the file ah_tool.pas which
made it into the archive wasn't the one I changed to be compatible with D6,
but the old version which gives some error messages on compilation.
However it's easy to correct as it's only the use of the typed constants which
creates the problems. Just add the compiler directive (*$j+ *) in the
header of this file and it will work compile.
The same is necessary for the demo application in the file main.pas.
Most of the algorithms are based upon a continuous time frame, the dynamic time (TDT).
The UTC instead does change with the change of the earth's rotation, which leads to
the insertion of leap seconds whenever needed. Since Januar 1999 the offset between both time
frames is 64 seconds - for example for the moon position this means an offset of about 30
angular seconds. However it's not defined which time frame the TDateTime
uses, so it's up to the user to use it appropriately.
For dates before 1900 (gregorian), or to be more exact for TDateTime value below zero,
the chinese calendar functions return total nonsense result. This is caused by using the trunc
function internally instead of the floor function.
In some cases the perigee and apogee functions don't return the next such event, but
instead the second next one. The reason is that the time between two such events
can be as low as 24.6 days, however the functions check for every 28 days. To fix it change
the 28 to 24 in the following line of NextPerigee and NextApoGee
while result<date do begin
result:=nextXXXgee(temp_date,false);
temp_date:=temp_date+24;
end;
The times for the moonrise and set might be off the correct value by several minutes
because I did mix up the topocentric and geocentric horizontal coordinates. To fix
it just remove the three last calls of CorrectPosition
(not the first one however)
inside the
Calc_Rise_Set function.
The julian Easter date (the one used by the orthodox christians)
is wrong for all dates after 1582. While the algorithm itself is correct,
the conversion into the TDateTime is wrong. Instead of the EncodeDateCorrect
it should use the following EncodeDateJulian function to convert into
TDateTime.
function EncodedateJulian(year,month,day: word):TDateTime;
begin
result:=delphi_date(Calc_Julian_date_julian(year,month,day));
end;
There are two different definitions of the sign of the longitudes, I only
forgot to mention which one is used by the algorithms in my component, so
there's the chance to get confused. As
Jean Meeus uses the old astronomical definition (western longitude are positive)
I also use this one, althought I'm aware the other may be the more common one.
This is not a bug in my component, but either a very strange definition of the
TDateTime type or a big bug in the date and time functions of Delphi. Problem is for dates prior
to 1899-30-12 the TDateTime is negative, but the value behind the decimal dot
(the time) doesn't get the minus, so -0.25 = 0.25 for the DateTimeToStr
functions. To fix this add the following function before converting into a string:
function CorrectDateTime(v:TDateTime):TDateTime;
begin
result:=v;
if (v<0) and (frac(v)<>0) then
result:=int(v)-frac(v)+1;
end;
Date | Version | Changes |
---|---|---|
1997-04-03 | 1.0 | first published version, collection of functions and a
TImage-like component which shows the phase at a given date Moontool clone as a demo application |
1997-05-21 | 1.1 | setting Align to anything else then alNone cause wild flickers, fixed made the demo application runnable in 16 bit, too small bug in demo application with daylight saving fixed |
1997-12-07 | 1.2 | added calculation of seasons, moon/sunrise and -set, perigee and apogee and eclipses new icon property, 16x16 bitmap second page in Moontool with the new additional data |
2001-07-07 | 2.0 | Rotation of the moon image "Color" bitmaps New functions for horizontal coordinates of sun and moon, Perihel and Aphel Twilight (civil, nautical, astronomical) Easter date for gregorian and julian calendary Pesach date and jewish calendar functions Chinese calendar Corrected TDateTime functions Location database in Moontool Moontool set date/time dialog Online help |
Last changed 2002-09-25