# Procedural Calendar Generation & Lunar Phases

Here we are again! This is Part 3 of a small series on how to randomly generate a physically accurate calendar starting from planet’s orbital parameters. You can find the general motivation here, part one here and part two here.

Said that, here we go with the next part: lunar phases.

## Why lunar phases

Lunar phases are incredibly important in a calendar. So important, that many of the early humanity calendars are, in fact, lunar calendars or lunisolar calendars. Of course, this is true if and only if the planet is lucky enough to have a big moon like us.

In any case, moon is how we define months. A calendar generator must include the moon period into account to have months (we can also include different criteria for months generation, but this is a more advanced feature).

Once we introduce an important moon, then, we are automatically adding lunar phases into the mix. In our world, we have so many “lore” attached to the concept of lunar phases that it is impossible that another planet with a principal satellite would ignore the feature.

So we need to compute the lunar phases and put them into our calendar.

## What is a lunar phases?

Many people think that lunar phases are caused by the shadow of the earth on the Moon. This is wrong. Lunar phases are just caused by the Sun lighting the Moon from a different angle every night.

A lunar phase is how much surface of the satellite I can see from the planet. Because the moon takes a month to do a full revolution around the Earth/planet, during the month we will see different “percentages” of the satellite under the light. This is shown in the picture above.

## How to compute lunar phases

For lunar phases we need to focus on the satellite-moon system. We assume that satellite-planet-star all orbit on the same plane. This is false (otherwise we would have a solar eclipse every month), but it is enough for lunar phases computation.

Then, we assume that light comes in a fixes and parallel direction. This is also not true, after all, the planet is moving during that month, but it is still a good approximation.

Finally, we have everything we need:

1. We call lunar phase the percentage of the side of the satellite exposed to the star that we can see from the planet. As you can see from the image above, this is the angle between the line orthogonal to the line connecting the planet and the moon (the light blue line), and the line orthogonal to the line connecting the star to the moon (the orange line).
2. The orange line is fixed in our approximation (that is true if planet revolution is much larger than moon revolution). The blue line, instead depends on the true anomaly of the satellite around the planet. Not only, the difference between the orange and the blue line is exactly the true anomaly!
3. What we want now it is the ratio between the true anomaly and the 180° angle: $$\frac{|theta|}{pi}$$. This is the “progress” of moon phase. It goes from 0 (new moon), to 0.5 (first quarter), to 1 (full moon) and back to zero.
4. Remember, we know how to compute the true anomaly! It is the same we used for the orbit of the planet!

This is a very simplified model but it is enough to add the concept of moon phases to our calendar.

Now we have months, moon phases, seasons and general properties of the calendar. Next step is to start adding some cultural aspect on it.