I am drawing the cartesian coordinate system in XYZ coordinate system and would like to illustrate a point in the 3d space by drawing the projections on each plane. A simple version would be as follows: obtained with this code:

\documentclass{article} \usepackage{tikz} \usetikzlibrary{calc} %: isometric South West (-150): Y , East : X , North : Z \tikzset{isometricYXZ/.style={x={(1cm,0cm)}, y={(-1.299cm,-0.75cm)}, z={(0cm,1cm)}}} \begin{document} \begin{tikzpicture}[inner sep=0.2cm] \def \radi{3} \def \x{2} \def \y{2} \def \z{2} \begin{scope}[isometricYXZ] % the grid \begin{scope}[color=gray!50, thin] \foreach \xi in {0,...,\radi}{ \draw (\xi,\radi,0) -- (\xi,0,0) -- (\xi,0,\radi); }% \foreach \yi in {1,...,\radi}{ \draw (0,\yi,\radi) -- (0,\yi,0) -- (\radi,\yi,0); }% \foreach \zi in {0,...,\radi}{ \draw (0,\radi,\zi) -- (0,0,\zi) -- (\radi,0,\zi); }% \end{scope} \draw[-latex, ultra thick, color=blue] (0,0,0) -- (4,0,0) node[anchor=west] {X};% \draw[-latex, ultra thick, color=red] (0,0,0) -- (0,4,0) node[anchor=north] {Y};% \draw[-latex, ultra thick, color=green] (0,0,0) -- (0,0,4) node[anchor=east] {Z};% \fill[color=magenta, opacity=0.2] (0,0,0) -- (\x,0,0) -- (\x,\y,0) -- (0,\y,0) -- cycle; % \fill[color=yellow, opacity=0.2] (0,0,0) -- (0,0,\z) -- (0,\y,\z) -- (0,\y,0) -- cycle; % \fill[color=cyan, opacity=0.2] (0,0,0) -- (\x,0,0) -- (\x,0,\z) -- (0,0,\z) -- cycle; \draw[color=gray, thick]% (0,\y,\z) -- (\x,\y,\z) -- (\x,\y,0) (\x,\y,\z) -- (\x,0,\z);% \end{scope} \shade[ball color=yellow] ($\y*(-1.299cm,-0.75cm)+(\x,\z)$) circle (0.1);% \end{tikzpicture} \end{document}

To make the drawing nicer, I want to shade these projections, what I managed to do for the XZ plane:

This is the code for the shaded part:

\begin{scope}[isometricYXZ] \def \h{{0.5*sqrt(\x*\x + \z*\z)}} \clip (0,0,0) -- (\x,0,0) -- (\x,0,\z) -- (0,0,\z) -- cycle; % \begin{scope}[transform canvas={shift={(\x/2,0,\z/2)}, rotate=45}] \fill[top color=green!30, bottom color=blue!30] (-\x,0,-\h) -- (\x,0,-\h) -- (\x,0,\h) -- (-\x,0,\h) -- cycle; \end{scope} \end{scope}

Now, when I am trying to do the same for the other planes, it does not work, as it seems that rotate always rotates as usually in the 2-dimensional case (in my case around the Y axis, in the XZ plane). This is the code:

\begin{scope} \def \h{{0.5*sqrt(\x*\x + \y*\y)}} \clip (0,0,0) -- (\x,0,0) -- (\x,\y,0) -- (0,\y,0) -- cycle; % \begin{scope}[transform canvas={shift={(\x/2,\y/2,0)}, rotate=-45}] \fill[top color=blue!30, bottom color=red!30] (-\x,-\h,0) -- (\x,-\h,0) -- (\x,\h,0) -- (-\x,\h,0) -- cycle; \end{scope} \end{scope}

And the result:

So, my question is whether it is possible and if yes, then how to tell Tikz to rotate around an arbitrary axis? Or in my case, in the XY and YZ planes?

A solution with fading which does not require rotating would be also fine.

In the end, I guess I could translate everything to 2d and get what I want, but may be there is a cleaner solution to this.

You are watching: How to rotate around arbitrary axis in XYZ coordinate system. Info created by GBee English Center selection and synthesis along with other related topics.