3

All I want to do is to rotate the axes of the accepted answer of the question in

How to draw and annotate a spherical coordinate system

such that the new z-axis stays where the current y-axis is.

My new axes (say, x', y' and z') should seem to be exactly where those xyz-axes are but with the following correspondences:

  • z' <-- y
  • y' <-- x
  • x' <-- z

I don't want simply to change the axes' labels, because I want to work with the axis z' still being along the direction (0,0,1) and the angle theta must still come from it.

Stuff from How to draw and annotate a spherical coordinate system below:

enter image description here

\documentclass{article} 

\usepackage{tikz}
\usepackage{tikz-3dplot}

\begin{document}
\tdplotsetmaincoords{60}{110}
%
\pgfmathsetmacro{\rvec}{.8}
\pgfmathsetmacro{\thetavec}{30}
\pgfmathsetmacro{\phivec}{60}
%
\begin{tikzpicture}[scale=5,tdplot_main_coords]
\coordinate (O) at (0,0,0);
\draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$};
\draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$};
\draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$};
\tdplotsetcoord{P}{\rvec}{\thetavec}{\phivec}
\draw[-stealth,color=red] (O) -- (P) node[above right] {$P$};
\draw[dashed, color=red] (O) -- (Pxy);
\draw[dashed, color=red] (P) -- (Pxy);
\tdplotdrawarc{(O)}{0.2}{0}{\phivec}{anchor=north}{$\phi$}
\tdplotsetthetaplanecoords{\phivec}
\tdplotdrawarc[tdplot_rotated_coords]{(0,0,0)}{0.5}{0}%
    {\thetavec}{anchor=south west}{$\theta$}
\end{tikzpicture}
\end{document}

I couldn't to that with \tdplotsetmaincoords{}{} because that command only rotates around x-axis and then around the new z-axis (from the configuration showed below), and reaching my configuration requires a third rotation (like Euler angles) or rotation around y-axis.

This is a picture from Changing axes in tikz-3dplot picture (bobobobo's answer) showing the start configuration for rotations with tdplotsetmaincoords

Start configuration for rotations with command tdplotsetmaincoords{}{}.

2

I was finally able to do that with \tdplotsetrotatedcoords{-90}{-90}{0}. I also had to put \tdplotsetrotatedthetaplanecoords{\phivec} instead of \tdplotsetthetaplanecoords{\phivec}.

Rotated spherical coordinate angles.

\documentclass{article} 

\usepackage{tikz}
\usepackage{tikz-3dplot}

\begin{document}

\tdplotsetmaincoords{60}{110}
\tdplotsetrotatedcoords{-90}{-90}{0}
%
\begin{tikzpicture}[scale=5,tdplot_rotated_coords]
  \coordinate (O) at (0,0,0);
  \draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$};
  \draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$};
  \draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$};
  \def\rvec{1}
  \def\thetavec{45}
  \def\phivec{30}
  \tdplotsetcoord{P}{\rvec}{\thetavec}{\phivec}
  \draw[-stealth,color=red] (O) -- (P) node[above right] {$P$};
  \draw[dashed, color=red] (O) -- (Pxy);
  \draw[dashed, color=red] (P) -- (Pxy);
%  \draw[dashed, color=red] (P) -- (Pyz);
%  \draw[dashed, color=red] (O) -- (Pxz);
%  \draw[dashed, color=red] (P) -- (Pxz);
  \tdplotdrawarc[tdplot_rotated_coords]{(O)}{0.2}{0}{\phivec}{anchor=north east}{$\phi$}
  \tdplotsetrotatedthetaplanecoords{\phivec}
  \tdplotdrawarc[tdplot_rotated_coords]{(0,0,0)}{0.5}{0}{\thetavec}{anchor=south west}{$\theta$}
\end{tikzpicture}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.