# Cross in particular plane in 3D

I'm creating tikz graphics in (x,y,z) Cartesian coordinate system. I'm defining objects (circle in my WE) in some plane using \tikzset{xyplane/.style={canvas is yx plane at z=#1}}. I noticed it doesn't work for cross marking some point (cross is always in yz plane in my WE). I'm affraid my skill isn't enough to define cross/.style so that it would render cross in particular plane. Is it possible?

MWE:

\documentclass[a4paper,fleqn,leqno]{article}
\usepackage{tikz,tikz-3dplot}
\usetikzlibrary{arrows.meta,decorations.markings,shapes.misc,3d}
\DeclareMathSizes{12}{12}{6}{12}
\tikzset{cross/.style={cross out,draw=black,minimum size=2*(#1-\pgflinewidth),inner sep=0pt,outer sep=0pt},cross/.default={3pt}}
\tikzset{xyplane/.style={canvas is yx plane at z=#1,very thin}}
\tikzset{xzplane/.style={canvas is zx plane at y=#1,very thin}}
\tikzset{yzplane/.style={canvas is zy plane at x=#1,very thin}}
\begin{document}
\begin{tikzpicture}[cm={-1,-1,1,0,(0,0)},x=3.85mm,z=-1cm]
\def\Sx{0} \def\Sy{0} \def\Sz{2}
\pgfmathsetmacro\Sρ{"sqrt((\Sx)^(2)+(\Sy)^(2)+(\Sz)^(2))"}
\pgfmathsetmacro\Sθ{ifthenelse(\Sx==0&&\Sy==0&&\Sz==0,0,"acos(\Sz/(sqrt((\Sx)^(2)+(\Sy)^(2)+(\Sz)^(2))))")}
\pgfmathsetmacro\SΦ{ifthenelse(\Sx==0&&\Sy==0,0,ifthenelse(\Sy<0,"-acos(\Sx/(sqrt((\Sx)^(2)+(\Sy)^(2))))","acos(\Sx/(sqrt((\Sx)^(2)+(\Sy)^(2))))"))}
\tdplotsetcoord{S}{\Sρ}{\Sθ}{\SΦ}
\draw[xyplane=\Sz,color=black,semithick] (S) circle (2cm) node[cross] {};
\draw[dashdotted,color=black] ($(S)-(0,0,2.5)$) -- ($(S)+(0,0,2.5)$) node[anchor=south,color=black] {$o$};
\end{tikzpicture}
\end{document}


Surprisingly there is a very easy way to do so. Adding transform shape into your cross/.style results the right "X" instead of the left "X". (I set cross/.default={6pt} so they are larger.)

Thinking that an X is nothing but lines connecting corners of the rectangular node. So the remaining problem is to apply current transformation on nodes. It then became less magical.

## Edit

As required, this is a MWE

\documentclass[tikz]{standalone}
\usepackage{tikz,tikz-3dplot}
\usetikzlibrary{arrows.meta,shapes.misc}

\tikzset{cross/.style={cross out,draw,minimum size=2*(#1-\pgflinewidth),inner sep=0pt,outer sep=0pt},cross/.default={6pt}}
\tikzset{xyplane/.style={canvas is yx plane at z=#1,very thin}}
\tikzset{xzplane/.style={canvas is zx plane at y=#1,very thin}}
\tikzset{yzplane/.style={canvas is zy plane at x=#1,very thin}}
\begin{document}
\begin{tikzpicture}[cm={-1,-1,1,0,(0,0)},x=3.85mm,z=-1cm]
\def\Sx{0} \def\Sy{0} \def\Sz{2}
\pgfmathsetmacro\Sρ{"sqrt((\Sx)^(2)+(\Sy)^(2)+(\Sz)^(2))"}
\pgfmathsetmacro\Sθ{ifthenelse(\Sx==0&&\Sy==0&&\Sz==0,0,"acos(\Sz/(sqrt((\Sx)^(2)+(\Sy)^(2)+(\Sz)^(2))))")}
\pgfmathsetmacro\SΦ{ifthenelse(\Sx==0&&\Sy==0,0,ifthenelse(\Sy<0,"-acos(\Sx/(sqrt((\Sx)^(2)+(\Sy)^(2))))","acos(\Sx/(sqrt((\Sx)^(2)+(\Sy)^(2))))"))}
\tdplotsetcoord{S}{\Sρ}{\Sθ}{\SΦ}
\draw[xyplane=\Sz,color=black,semithick](S)circle(2cm)node[cross]{};
\draw[dashdotted,color=black]($(S)-(0,0,2.5)$)--($(S)+(0,0,2.5)$)node[anchor=south,color=black]{$o$};
\end{tikzpicture}
\begin{tikzpicture}[cm={-1,-1,1,0,(0,0)},x=3.85mm,z=-1cm]
\def\Sx{0} \def\Sy{0} \def\Sz{2}
\pgfmathsetmacro\Sρ{"sqrt((\Sx)^(2)+(\Sy)^(2)+(\Sz)^(2))"}
\pgfmathsetmacro\Sθ{ifthenelse(\Sx==0&&\Sy==0&&\Sz==0,0,"acos(\Sz/(sqrt((\Sx)^(2)+(\Sy)^(2)+(\Sz)^(2))))")}
\pgfmathsetmacro\SΦ{ifthenelse(\Sx==0&&\Sy==0,0,ifthenelse(\Sy<0,"-acos(\Sx/(sqrt((\Sx)^(2)+(\Sy)^(2))))","acos(\Sx/(sqrt((\Sx)^(2)+(\Sy)^(2))))"))}
\tdplotsetcoord{S}{\Sρ}{\Sθ}{\SΦ}
%\draw[xyplane=\Sz,color=black,semithick](S)circle(2cm)node[cross]{};
\draw[xyplane=\Sz,color=black,semithick](S)circle(2cm)node[transform shape,cross]{};
\draw[dashdotted,color=black]($(S)-(0,0,2.5)$)--($(S)+(0,0,2.5)$)node[anchor=south,color=black]{$o$};
\end{tikzpicture}
\end{document}

• It would be nice for TikZ noobs like me if you put together a MWE together with the output. – Svend Tveskæg Mar 3 '15 at 9:57
• @SvendTveskæg here you are. – Symbol 1 Mar 3 '15 at 10:02