# Moon Orbit/Phase Generator?



## Astalanya (Jan 19, 2003)

All right. I've looked right and I've looked left, I've looked high and low with no success. I am trying to find something that ought to be relatively easy to locate, but isn't. 

Does anyone know of a free (or shareware) program which calculates the phases of a moon (or two)? I know Dragonlance.com has a generator for the three moons of Dragonlance (which doesn't help me much), and IronyGames' moon phase generator isn't quite what I am after. A bit too simple. I'd like to find something where I can throw in the orbital time of the two moons for my campaign world, and get out a fairly nice summary of when the phases are, when they would eclipse, etc. 

Does such a thing exist? Or need I look pitiously at some Java coder out there?


----------



## Galfridus (Jan 20, 2003)

Having looked a lot in this general area (not specifically for what you are looking for, but for similiar items), I'm pretty sure you're going to have to resort to writing it yourself -- or finding someone who has written one but not posted it online.


----------



## MonkeyBoy (Jan 20, 2003)

*Moon Phases*

OK.

Firt things first; you are going to need to simplify a lot of the maths for real moon phases to keep yourself sane while doing this. Remember that our real calendar and its relation to the moon phases is pretty complex, calendar months all being different lengths from the lunar month, it being related to orbits etc etc. (none of which I really understand, anyway!)

So begin with a few simple assumptions, which it being a fantasy game, you are at leaisure to make. This allows a "fantasy physics" form of phase calculation, if you want more, take up traveller, or make friends with an astronomer 

0
Assume Moons do not affect each others phases! This is a rank inaccuracy; assuming you want multiple moons with different cycles, one must orbit faster than the other; anyway one or other moon is likely to at least partially eclipse the other at various times, which would be likely to factor into phases; we will ignore this, as its officially a Hard Problem...

1
Circular Orbits; this means that all phases are of equal length for any given moon.

2
Use 8 Phases, numbered from 0:
0   New Moon (No Moon)
1   1st Quarter
2   Waxing Gibbous
3   Waxing Half
4   Full
5   Waning Half
6   Waning Gibbous
7   4th Quarter

Moons will pass through these phases in sequence, returning to 0 when exiting the 4th Quarter phase. One cycle from the beginning of being a New Moon to the very end of being a 4th Quarter moon is one lunar cycle, the number of days this takes is your lunar month.
You must also be able to track what part of each phase the moon is in if the lunar cycle is anything other than 8 days. i.e. to be able to say that the moon is in the third day of the Full Moon, etc.

3
Set yourself a "source date" being the nominal date from which all your calculations begin.

Moons:
You need to know 2 things about a moon to calculate its phase on a given date:
What its phase was on the source date
Its lunar cycle

You can freely pick the source date's phase for your world, and set the lunar cycle. Remember that there are 8 phases; making your lunar cycle a multiple of 8 makes the maths easier, and avoids having some days where the moon is "on the cusp". Our moon has a cycle of approx 28 days, giving an irritating 3.5 ish days per phase... Resist the urge to have a lunar cycle shorter than 8 days...

Lets consider a source date (0), and a Moon X (with lunar cycle 24 days (3 days / phase) and which was on the 2nd day of being full on day 0).

OK, once we know that we can calculate the phase of the moon if we can express the desired date in "days since day 0".

Lets consider day 365 in our demo system. 365 / 24 = 15 (integer division) and 365 % 24 = 5. This tells us that 15 full months have passed (which would have left the phase unchanged), plus another 5 days. Since we have a 24 day cycle, that means 3 days per phase, giving us a 1 phase and 2 day advance in phase. We began on the second day of being full, so 1 phase advances us to the second day of being a Waning Gibbous moon, two days will advance us into the first day of the Waning Half Moon phase.


Now, setting a single source date for the world, and then setting moons with source phases and lunar cycles (and being sure to keep track of progression within the phase) means you can calculate phases for any number of moons, at any given date.

When I did this work for my game, I simply used excel:
I ran a date column down the page, and then entered phases into the following columns for each moon, one cell per day of each phase. Once you have a year's worth you can just cut and paste.
This lets you easily read off the phase for a given day.

The hard part is, if you're like me, when you want to use plot devices such as "only when all the moons are full" etc. Calculating a phase is easy; designing a set of lunar cycles and start dates to get such conjunctions at a frequency you want is HARD!

I have seen a moon phase calculator for eath online, but I forget where. You've intrigued me now, so I'll try to knock together a quick bit of javascript to spit out a phase (and day within a phase) for any date and moon information as stated above. Will take a day or two though


----------

