2

I recently asked this question, which is a preface to this one. In that one I explain roughly what I'm attempting to achieve, but I realized that once I found that cutoff angle I still didn't have a good way of drawing the lines of latitude and longitude in terms of partial ellipses like I want to.

As mentioned in the comments of the accepted answer, I could still draw a lot of individual points and lines between them, but what I'd prefer would be to draw partial ellipses parametrized by their center, width, height, and where to start and stop drawing them in terms of radians. Translating from specific points of projection to such ellipses is the difficulty I'm facing; finding the cutoff for each line of latitude and longitude in terms of the other was meant to help find where to start and stop drawing the ellipses, but I struggle to actually do that, and I also struggle to find the other parameters (centers, heights, widths).

Here's an image showing what I'm after, the only differences being that I'm only ever going to tilt the central latitude, not the longitude, I'm not going to show the hidden parts of the ellipses (but as you can see from that image, you'd still have to know where along the ellipse you have to change the stroke), I'm going to parametrize how many divisions of longitude and latitude (typically I will have lines that are 1 degree apart pre-projection, as shown in the image I linked to in the original question), and I'm probably going to highlight the equatorial latitude with a different color.

2 Answers2

2

For this answer I'll assume that the sphere is projected onto a plane with coordinates $x,y$; that the center of the orthogonal projection has latitude (angle from the equator) $\phi_0$ on the sphere and longitude $\lambda_0$ and is projected to the point $(0,0)$ in the $x,y$ plane; that all angles are measured in radians; and that the poles of the sphere (points at latitude $\pm\frac\pi2$) are projected onto the $y$ axis.

Note that this is slightly different from the answer previously posted here, which uses $y$ where I use $x$ and $z$ where I use $y,$ but it is consistent with my answer to a different question, whose main figure I have re-used below.

Lines of Latitude

For a line of latitude, consider the figure below, depicting the projection of a sphere with pole $N$ and equator $EE'$ projected onto a plane with $x,y$ coordinates. The center of the projection is point $P.$

cross section of sphere in y,z plane, point C at coordinates (0,0), line CMN representing the axis of the sphere, line ECE' (perpendicular to CMN) representing the equatorial plane, line LMTL' perpendicular to CMN representing a line of latitude, point T on y axis inside the sphere, angle TCN = phi_0, angle ECL = phi

We get the $(x,y)$ coordinates of each projected point simply by deleting the $z$ coordinate of the original point. So the pole $N$ projects to the point $(0,r\cos\phi_0).$

The small circle at latitude $\phi$ projects to an ellipse with center $(0,r\sin\phi\cos\phi_0),$ at the same $y$-coordinate as the point $M$ in the figure. The radius of the small circle is $r\cos\phi,$ which is also the semimajor axis of the ellipse onto which the circle is projected; the major axis is parallel to the $x$ axis. The semiminor axis of the ellipse, which lies on the $y$ axis, has length $r\cos\phi\sin\phi_0.$

The plane of the small circle intersects the $y$ axis at $(0,r\sin\phi\sec\phi_0),$ shown as point $T$ in the figure. For a projection with a positive central latitude, as shown in the figure, any point on the small circle with $y$ coordinate greater than that of $T$ is on the "far" side of the sphere and is hidden in the projection. In the case where $r\sin\phi\sec\phi_0 \geq r,$ that is, for $\phi \geq \frac\pi2 - \phi_0,$ the entire ellipse is visible and not hidden. In the case where $r\sin\phi\sec\phi_0 < -r,$ that is, for $\phi < \phi_0 - \frac\pi2,$ the entire ellipse is hidden. For other small circles, the part on or below the line $y = r\sin\phi\sec\phi_0$ is visible and the part above that line is hidden.

From either this answer or this answer we can find the longitudes of the points at which the line of latitude changes from visible to hidden (for latitudes that are only partially visible). These longitudes are $$ \lambda = \lambda_0 \pm \arccos(- \tan\varphi\tan\varphi_0). $$

Lines of Longitude

A meridian (line of longitude) is half of a great circle on the sphere. To complete a great circle we can combine two meridians. Let $\Gamma_\lambda$ be the great circle that includes the meridian at longitude $\lambda$ with the meridian at longitude $\lambda - \pi$ (or $\lambda + \pi,$ depending on $\lambda$ and your preferences for how to express the longitude of a meridian).

The great circle $\Gamma_\lambda$ passes through two diametrically opposite points on the great circle $\Gamma_P$ that lies in the plane $CT$ in the previous figure. Since $\Gamma_P$ projects onto the circle of radius $r$ about $(0,0),$ which contains the rest of the projection of the sphere, the projection of $\Gamma_\lambda$ is an ellipse that is internally tangent to the circle of radius $r$ about $(0,0).$ The semimajor axis of that ellipse therefore has length $r.$

A line through the center of the sphere perpendicular to the plane of $\Gamma_\lambda$ intersects the sphere in two points known as the poles of the great circle. Both of these points are on the equator; choose one at either longitude $\lambda + \frac\pi2$ or $\lambda - \frac\pi2.$ Call that point $Q.$

The figure below shows the the orthographic projection of these shapes onto the $x,y$ plane. The north pole is projected to the point $N,$ the equator is projected to the ellipse through the point $Q$, and the ellipse through $N$ is the projection of the great circle $\Gamma_\lambda$ of the meridian at longitude $\lambda.$

orthogonal projection of sphere, north pole N, equator, line of longitude, and pole Q of the line of longitude to x and y coordinates

The coordinates of $Q$ in the projection are $(x_Q,y_Q) = (r\cos(\lambda - \lambda_0), r\sin\phi_0\sin(\lambda - \lambda_0)).$ This implies that the semiminor axis $CB$ of the ellipse through $N$ has slope $\dfrac{y_Q}{x_Q} = \sin\phi_0\tan(\lambda - \lambda_0)$ and the semimajor axis $CA$ has slope $-\csc\phi_0\cot(\lambda - \lambda_0).$

The points $Q$ and $B$ on the original sphere are on another great circle that in this projection appears as a straight line segment. On that circle, $Q$ and $B$ make right angles with the center of the sphere. Their distances from the line $CP$ are therefore $r\sin\alpha$ and $r\cos\alpha$ for some angle $\alpha.$ In the projected image, therefore, $CQ^2 + CB^2 = r^2\sin^2\alpha + r^2\cos^2\alpha = r^2.$ The semiminor axis $CB$ of the ellipse therefore has length \begin{align} \sqrt{r^2 - CQ^2} &= r \sqrt{1 - \cos^2(\lambda-\lambda_0) - \sin^2\phi_0\sin^2(\lambda-\lambda_0)} \\ &= r \cos\phi_0\sin(\lambda - \lambda_0). \end{align}

For $\phi_0 > 0,$ as shown in this example, the visible part of the great circle is the portion of the ellipse above the major axis and the portion below is hidden. If $\phi_0 < 0$ (so that $N$ is hidden) then the portion of the ellipse below its major axis is visible and the portion above is hidden.

From this answer we know that the meridian at longitude $\lambda$ changes from visible to hidden at latitude $$ \phi = -\arctan(\cot\phi_0 \cos(\lambda - \lambda_0)). $$

Note that (strictly speaking) this happens at only one point on a meridian, which is one of the vertices of the ellipse onto which the meridian is projected, because a meridian is only half a great circle and projects to only half of an ellipse. The other half of that ellipse, containing the other vertex, is the projection of the meridian at longitude $\lambda \pm \pi,$ whose visible-to-hidden transition occurs at latitude $$ \phi = \arctan(\cot\phi_0 \cos(\lambda - \lambda_0)). $$

Summary

For the line of latitude $\phi,$ \begin{align} \text{Center of ellipse} &= (0,r\sin\phi\cos\phi_0), \\ \text{Slope of major axis} &= 0, \\ \text{Length of semimajor axis} &= r\cos\phi, \\ \text{Length of semiminor axis} &= r\cos\phi\sin\phi_0, \\ \text{Longitude at end of visibility} &= \lambda_0 \pm \arccos(- \tan\varphi\tan\varphi_0), \\ \text{$y$ coordinate at end of visibility} &= r\sin\phi\sec\phi_0, \\ \text{Entire line visible if } & \begin{cases} \phi \geq \frac\pi2 - \phi_0 & \phi_0 > 0, \\ \phi \leq -\frac\pi2 - \phi_0 & \phi_0 < 0, \\ \end{cases} \\ \text{Entire line hidden if } & \begin{cases} \phi < -\frac\pi2 + \phi_0 & \phi_0 > 0, \\ \phi > \frac\pi2 + \phi_0 & \phi_0 < 0. \end{cases} \end{align}

For the meridian at longitude $\lambda,$ \begin{align} \text{Center of ellipse} &= (0,0), \\ \text{Slope of major axis} &= -\csc\phi_0\cot(\lambda - \lambda_0), \\ \text{Length of semimajor axis} &= r, \\ \text{Length of semiminor axis} &= r \cos\phi_0\sin(\lambda-\lambda_0), \\ \text{Latitude at end of visibility} &= -\arctan(\cot\phi_0 \cos(\lambda - \lambda_0)). \end{align}

David K
  • 108,155
1

I don't know how exactly you implemented the drawings. I'd suggest to leave the projection plane fixed to the $yz$ plane, and rotate instead the sphere with all its curves.

In practice, meridians and parallel can be derived from the same parametric equation, which for a non-rotated sphere is:

$$ \pmatrix{x\\ y\\ z}=\cases{ \cos\phi\cos\theta\\ \\ \sin\phi\cos\theta\\ \\ \sin\theta} $$

where $\phi\in[0,2\pi]$ is the longitude and $\theta\in[-\pi/2,\pi/2]$ is the latitude. To draw a parallel we must fix the latitude and let the longitude vary, to draw a meridian we must fix the longitude and let the latitude vary.

To draw the projections of those curves on plane $yz$ we consider only the $y$ and $z$ coordinates of the above curve. To hide those parts of the curve which are not visible we must discard the points for which the $x$ value is negative. That is, we must choose the limits of the varying parameter such that $\cos\phi\cos\theta\ge0$.

Of course the above setting is not so useful, because all parallels degenerate into straight segments. But it is not difficult to rotate the above curve about the $y$ axis by an angle $\alpha$, here's the result:

$$ \pmatrix{x\\ y\\ z}=\cases{ \cos\alpha\cos\phi\cos\theta+\sin\alpha\sin\theta\\ \\ \sin\phi\cos\theta\\ \\ \cos\alpha\sin\theta-\sin\alpha\cos\phi\cos\theta} $$ As before, you should plot only the $y$ and $z$ components, with the bound: $$ \cos\alpha\cos\phi\cos\theta+\sin\alpha\sin\theta\ge0. $$ Suppose for instance you want to draw a parallel, corresponding to a latitude $\theta$. The curve to draw is: $$ \pmatrix{y(t)\\ z(t)}=\cases{ \sin t\cos\theta\\ \\ \cos\alpha\sin\theta-\sin\alpha\cos t\cos\theta} $$ with the bounds on $t$ derived from: $$ \cos\alpha\cos t \cos\theta+\sin\alpha\sin\theta\ge0. $$ If $\cos\alpha \cos\theta>0$ this can be written as $$ \cos t \ge-{\tan\alpha\tan\theta}, $$ that is: $$ -\arccos(-\tan\alpha\tan\theta)\le t \le\arccos(-\tan\alpha\tan\theta), $$ where the $\arccos$ should default to $\pm\pi$ if its argument is $>1$ or $<-1$.

For a meridian the choice of the limits is slightly trickier, but should be manageable.

  • Sorry, but I don't think this answers the question at all. The entire point is that I'm seeking the simplicity of drawing the curves as partial ellipses. I don't maintain any 3D model that I can rotate. Maybe I'm misunderstanding what you're saying, but you end up talking about curves to draw, when the point is that from looking at it all those curves are partial ellipses, and thus I'd like to draw them using a partial ellipse primitive. Please feel free to expand if you think I'm just misunderstanding you. – Outis Nemo Mar 19 '23 at 19:23
  • The curve given above IS a partial ellipse. What do you mean by "partial ellipse primitive"? – Intelligenti pauca Mar 19 '23 at 19:43
  • Well, naturally it has to be a partial ellipse, I already know this from observation; but it's not parametrized as such in terms of the parameters I requested in the question: center, width, height, and where to start and stop drawing the ellipse in terms of radians (0 being the ellipse's right extreme, pi/2 being the bottom extreme, pi being the left extreme, and 3pi/2 being the right extreme). Or if it is, then how exactly you go from the function you've written to those parameters is not clear to me at all. – Outis Nemo Mar 19 '23 at 20:25