4

I'm not sure if this is appropriate for math.SE. But I figured that my problem is with understanding, and not with execution, so I thought it to be more appropriate for math.SE instead of tex.SE.

I would like to draw a sphere with some great circles on it, programmatically in TikZ. So I started out with two circles in the $xz$-plane, and in the $zy$-plane and some coordinate axes:

\begin{tikzpicture}[scale=2]
    % coordinate axes
    \draw[->] (-1.5, 0, 0) -- (1.5, 0, 0);
    \draw[->] (0, -1.5, 0) -- (0, 1.5, 0);
    \draw[->] (0, 0, -1.5) -- (0, 0, 1.5);
% the circles
<span class="math-container">\begin{scope}[canvas is xz plane at y = 0]
\draw (0,0) circle[radius=1];

\end{scope} \begin{scope}[canvas is zy plane at x=0] \draw (0,0) circle[radius=1]; \end{scope} \end{tikzpicture}

This gives the following picture:

two circles

Then I thought if we rotate one the latitude circle, this should give the sphere with more latitudes, right? The following code does exactly this

\foreach \t in {120,125,...,285} {
    \begin{scope}[
            % draw on a rotated plane
            plane x = {(({sin(\t)},0,cos(\t))},
            plane y = {(0,1,0)},
            canvas is plane
        ]
        \draw (0,0) circle[radius=1];
    \end{scope}
}

Adding this produces the following picture.

enter image description here

I don't understand why the outline is not perfectly round. What's going on here? Is it because we are not doing dealing properly with perspective? Or did I miss something else?

red_trumpet
  • 8,515
  • 1
    The circles don't look aligned even when there are only two. My guess is you need to use some sort of absolute coordinate system – pancini Apr 21 '22 at 21:11
  • There is a nice sphere with great circles and source code at TeXample.net https://texample.net/tikz/examples/map-projections/ – Gribouillis Apr 21 '22 at 21:18
  • @Gribouillis Yeah, I also found this when googling around. But I didn't understand what's going on, and the code is a bit complicated with lots of macros. Can you explain this better? – red_trumpet Apr 21 '22 at 21:21
  • @pancini What exactly do you mean? Note that the coordinate axes are not supposed to be the semi axes of the ellipses, because we look at the sphere from the top! – red_trumpet Apr 21 '22 at 21:23

1 Answers1

3

The projection of the three axes is not orthographic. It's as if you took a sphere with three axes, where the $x$ and $y$ axes where in the plane of the paper (or computer monitor) and the $z$ axis was sticking straight out, and then you yanked the $z$ axis toward the bottom left corner of the picture while keeping the $x$ and $y$ axes fixed in place. By doing this you pushed parts of the sphere in front of the $x,y$ plane in that direction, and pushed the parts of the sphere behind the $x,y$ plane in the opposite direction, while the great circle in the $x,y$ plane did not move at all. That is, instead of rotating the sphere, you distorted it, and that's why the sphere seems to be bulging out in those directions.

An isometric projection (three axes at $120$-degree angles to each other) is orthographic and relatively easy to set up. It should work better.

Looking at this a little closer, it seems like your particular TikZ environment is simply set up to do this badly by default. There may be a way to get it to do an orthographic projection of the three axes instead of what it's doing in your example (which looks like a cabinetmaker's projection) but that's a software interface question, not a math question.

On further investigation all the TikZ coordinate systems I see in this document are orthographic, so maybe you just are not using the right package for what you need.

David K
  • 98,388
  • It may be that this really is a tex.se question after all. Are you using the tikz-3dplot package? – David K Apr 22 '22 at 00:09
  • That clears things up, thanks! I was using the standard 3d coordinates from tikz and the 3d package, but those coordinates turn out not to be orthographic. I was missing the notion of what that even means. Now I can change the coordinates to be orthographic. – red_trumpet Apr 22 '22 at 03:26