MOONPHASE works out the phase of the moon for today or any date you give, reports it, and draws the moon at that phase.
What MoonPhase does
The drawing is the novelty. The calculation is the substance: it finds the times of the new moons either side of the date by summing periodic terms in the moon’s and sun’s mean anomalies, and interpolates between them. It is good to about two minutes.
How to use it
- Load the routine with
APPLOAD, or put it on your support file search path. - Type
MOONPHASE. - Accept today’s date or give another.
- Pick a point to draw the disc.
How it works
The lunar month is not constant, and that is the whole difficulty. It averages 29.53 days but varies by several hours either side, because the moon’s orbit is elliptical and the sun perturbs it.
Dividing the days since a known new moon by 29.53 is wrong by up to most of a day — which is the difference between a crescent and a quarter, and perfectly visible in the drawing.
So the series carries terms in the sun’s mean anomaly, the moon’s mean anomaly and the moon’s argument of latitude, with secular corrections in the centuries since 1899.5. The largest correction, the −0.4068 sin term in the moon’s anomaly, is worth nearly ten hours on its own.
What gets drawn is the disc as a circle and the terminator — the line between light and dark — as an ellipse across it. The terminator’s width is the cosine of the phase angle, which is what makes it a straight line at the quarters, a narrow ellipse near new and full, and correctly bowed either way between.
Notes and limits
- Accurate to about two minutes on the new moon times it interpolates between.
- Nothing is left in the drawing but the geometry. Drawing the shape by making a block of a semicircular arc and re-inserting it with an X scale leaves a block definition named after the time of day in every drawing it touches.
- The terminator is an ellipse, not an arc — which is what makes the phase read correctly.
- One undo group covers the drawing.
Download and details
| Name | MoonPhase — calculate and draw the phase of the moon |
| Download | MoonPhase.lsp — 12.5 KB, plain AutoLISP source. Downloads directly; no zip to unpack. |
| Type | AutoCAD AutoLISP routine |
| Command | MOONPHASE |
| Requires | nothing beyond a CAD platform with AutoLISP. |
| Source size | 12.5 KB, 315 lines |
| Error handling | Yes — a *error* handler restores every system variable it changed, on cancel as well as on error. |
| Undo | The whole operation is wrapped in a single undo group, so one U reverses all of it. |
| Compatibility | AutoCAD (any release with AutoLISP), BricsCAD, ZWCAD, GstarCAD, ProgeCAD and other IntelliCAD-based platforms. AutoCAD LT needs a LISP enabler. No .NET, no ObjectARX, no installer. |
| Author | YZ, August 2026 |
| Licence | Free to use, supplied “as is” with no warranty. |
References
- CLOCKFACE LISP — the other one that reads the clock and draws it
- CANNON LISP — honest physics, drawn as temporary vectors
- More free AutoLISP routines on this site
- Wisey’s Steel Shapes — free structural steel section drawing program