1

This question already has an answer here:

I have this figure in spherical coordinates taken from here. I would like to use this figure to illustrate unit vectors at the point P. I have not been able to adapt the figures given on various posts. I manged to run the asymptote code here but in pdf format it comes compressed such that it is unreadable. I would appreciate if someone can add me some code in tikz so that I can draw a circle through P, with vectors in the three directions, east, north and zenith. I reproduce the code from the first site quoted above (appreciation and thanks @jubobs)

Yes the code by jubobs is half of what I want. What I want added to this are three unit vectors in the direction of the coordinate direction, i.e. at P we probably would have a circle running from north pole to south pole, and through P a vector in z-direction, a vector in $\phi$ direction and a vector in $\theta$ direction.

Please note that I am only adding a small addition to this post. The addition is explained in the last paragraph above.

The code supplied by mammot does exactly what I was looking for, my real appreciation for spending time and effort mammot. When I incorporate the code I get this. I had tried to turn the vector in the positive x-direction (opposite to what is the figure) no success so far. Seconddly I would appreciate adding a circle from north pole to south pole through P. Sorry for being too demanding, but the work is done. This is what I wanted and its fine. Once more my appreciation.

\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] (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$}
%
\tdplotsetthetaplanecoords{\phivec}
\tdplotdrawarc[tdplot_rotated_coords]{(0,0,0)}{0.5}{0} {\thetavec}
{anchor=south west}{$\theta$} \coordinate (Shift) at (P);
\tdplotsetrotatedcoords{-\phivec}{-\thetavec}{\phivec};
\tdplotsetrotatedcoordsorigin{(Shift)};
\begin{scope}[tdplot_rotated_coords,scale=0.4,blue]
\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'$};
\end{scope}
\end{tikzpicture}
\end{document}

marked as duplicate by Stefan Pinnow, Zarko tikz-pgf Jan 2 '18 at 22:01

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • When you're saying that the asymptote code is compressed, do you mean that the image is too small? If so, have you tried playing with size and/or size3, e.g. by adding size(200); size3(200); to the asymptote code? – user121799 Jan 2 '18 at 22:39
  • Thanks @marmot I will give feedback after I play around with size. Lst time I tried i was getting nowhere. – Zilore Mumba Jan 2 '18 at 22:48
  • Does adding \tdplotsetthetaplanecoords{\phivec} \tdplotdrawarc[tdplot_rotated_coords]{(0,0,0)}{0.5}{0}% {\thetavec}{anchor=south west}{$\theta$} \coordinate (Shift) at (P); \tdplotsetrotatedcoords{-\phivec}{-\thetavec}{\phivec} \tdplotsetrotatedcoordsorigin{(Shift)} \begin{scope}[tdplot_rotated_coords,scale=0.4,blue] \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'$}; \end{scope} to your code come close to a solution? – user121799 Jan 2 '18 at 23:14
  • Thanks @marmot, firstly my apologies for misspelling your name in the edit. You have solved my problem completely, please see the edit. Since this is done, I can as well forget the asymptote code. Thanks – Zilore Mumba Jan 3 '18 at 5:53
  • @Zarko I don't think this question is a duplicate, please see the edit by Zilore Mumba and my above comment, which I added because I could not post an answer. – user121799 Jan 3 '18 at 12:36

Browse other questions tagged or ask your own question.