Computing the exact terminator line is computationally intensive due to the fact the Earth is not a perfect sphere, and because the Sun is not infinitely far away. However, the terminator can be approximated by assuming so. Although the title says it's for the solar terminator, it works for any object that is far away.

This algorithms accepts the Geographic Position (GP) of the Sun (or any far away object), and returns the latitude along the terminator for a given longitude. So all points are obtained by looping through the longitude from -180 to +180 at any desired resolution.

If the goal is to draw a polygon, the polygon must be closed correctly so that it does not contain the Sun. This is most easily done by comparing the GP latitude with the latitude of the terminator at its GP longitude. Additionally, some consideration may need to be taken when the latitude of the Sun is exactly 0°, as the terminator takes on two rectangles in many map projections.

Loop from \(\lambda\) = -180° to \(\lambda\) = 180°
$$
\begin{align*}
ha &=\lambda - \lambda_{gp} \\
\tan \phi &= -\frac{\cos ha }{\tan \phi_{gp}} \\
\end{align*}
$$
Where \(\phi_{gp}\) is the GP lattidue, \(\lambda_{gp}\) is the GP longitude, \(\phi\) is
the outline point's latitude, and \(\lambda\) is the outline point's longitude.