What is the approximation equation for making the day/night wave

Basically, I have a program that will graph the day/night shade similar to this page: http://www.timeanddate.com/worldclock/sunearth.html

Could any of you give me the equation for graphing a line that approximately follows the day/night curve. I can't really think of an equation, so I'm asking here. Thanks.


A good place to start is by identifying the projection of your target map.

In this case, it is an equirectangular projection.

The day/night curve is called the terminator. Roughly speaking it is also a great circle. Your question then boils down to how to represent the terminator or great circle in an equirectangular projection.

Luckily, there's a handy answer to this on the GIS stackexchange.

The equation they end up with there is:

$\textrm{lat}=\arctan(\gamma \sin(\textrm{lat}-\textrm{lat}_0))$

Where $\textrm{lat}_0$ is the longitude of the equatorial crossing (as the geodesic enters the Northern Hemisphere when traveling eastwards) and $\gamma$ is a positive real number. You'll want to adjust $\gamma$ as needed and apply a vertical offset.

You could also click a bunch of x-y points on the image you found and fit a high-degree polynomial to them and then transform that as needed.