pgf-tikz / pgf

A Portable Graphic Format for TeX
https://pgf-tikz.github.io/
1.15k stars 108 forks source link

xyz spherical: longitude should be measured from x axis #1360

Open Firestar-Reimu opened 2 months ago

Firestar-Reimu commented 2 months ago

Brief outline of the proposed feature

/tikz/cs/radius=<number>
Factor by which the x-, y-, and z-vector are multiplied.
(no default, initially 0)
/tikz/cs/latitude=<degrees>
 (no default, initially 0)
Angle of the coordinate between the y- and z-vector, measured from the y-vector.
/tikz/cs/longitude=<degrees>
 (no default, initially 0)
Angle of the coordinate between the x- and y-vector, measured from the y-vector.

First, longitude should be measured from x-vector, and should follow the right-hand-rule, like this φ:

image

Second, latitude should be measured from xy-plane (not y-vector), like this 90-θ (or you can use the polar angle θ which is measured from z-vector)

Third, radius is not x-, y-, z-vector multiplied, but $\sqrt{x^2 + y^2 + z^2}$

Minimal working example (MWE)

\documentclass{article}
\usepackage{tikz,tikz-3dplot}
    \begin{document}
            \tdplotsetmaincoords{75}{105}
            \begin{tikzpicture}[tdplot_main_coords]
            \begin{scope}[canvas is xy plane at z=0]
                \draw (0,0) circle (3cm);
                \draw [->,dashed] (-3,0) -- (3,0) node {$x$};
                \draw [->,black,dashed] (0,-3) -- (0,3) node {$y$};
            \end{scope}
            \draw [->,red,dashed] (0,0,0) -- (0,0,3) node {$z$};
            \draw [blue] (0,0,0) -- (xyz spherical cs:radius=3,longitude=60,latitude=0);
            \draw [green] (0,0,0) -- (xyz spherical cs:radius=3,longitude=60,latitude=60);
            \end{tikzpicture}
    \end{document}

image

you can see that the longitude=60 is measured from y-vector and follow the left-hand-rule, which is not compatible with Physicists and Mathematicians.

hmenke commented 2 months ago

That's unfortunate, but it has been like that for quite some time so we cannot change this anymore. Otherwise we would break all the drawings that rely on this convention. Therefore I've marked your issue as a feature request.

Firestar-Reimu commented 2 months ago

So why you set the coordinate like this at first?

hmenke commented 1 month ago

I have no idea why it was set this way. It was introduced all the way back in 2006. You can try to contact the original author to maybe get an answer. https://github.com/pgf-tikz/pgf/commit/e150a7c6b512b2a9e03d73f0ce2e6789b044c034