I am trying to create a '3d' image using different viewing angles in Tikz (see MWE below). The image I have created can be see at this link.
My issue is that the spiral I have created is not aligned with the black axis. Specifically, the axis of rotation of the blue spiral should be around the black line (not necessarily along the entire length of the black axis).
The spiral represents circularly polarized light, demonstrated here by @MarkWibrow. How can I align the spiral such that it rotates around the axis shown with the black line? A solution appears to be given in this post, but I have not been able to merge it here.
Also, how can I reduce the amplitude of the spirals (i.e. smaller circles)?
MWE
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{3d, shapes.multipart, angles, quotes}
\tikzset{axis/.style={black, very thick, ->}}
\newcommand{\rect}[1]{%
\begin{scope}[canvas is xz plane at y=1.2]
\draw[line join=round, thick, fill=green!50!black!40] (#1,-1.2) rectangle (#1+1.2,1.2);
\end{scope}
%
\begin{scope}[canvas is xy plane at z=1.2]
\drawline join=round, thick, fill=green!50!black!25 rectangle (#1+1.2,1.2);
\end{scope}
%
\begin{scope}[canvas is yz plane at x=#1]
\draw[line join=round, thick, fill=green!50!black!10] (-1.2,-1.2) rectangle (1.2,1.2);
\end{scope}
}
\begin{document}
\pgfdeclarelayer{layer1}
\pgfdeclarelayer{layer2}
\pgfdeclarelayer{layer3}
\pgfdeclarelayer{layer4}
\pgfdeclarelayer{layer5}
\pgfdeclarelayer{layer6}
\pgfdeclarelayer{layer7}
\pgfdeclarelayer{layer8}
\pgfsetlayers{main, layer8, layer7, layer6, layer5, layer4, layer3, layer2, layer1}
\begin{tikzpicture}[x={(1cm,0.4cm)}, y={(8mm, -3mm)}, z={(0cm,1cm)}, line cap=round, line join=round]
\draw[axis] (-1,0,0) -- (15,0,0);
\begin{pgfonlayer}{layer8}
\rect{14}
\end{pgfonlayer}
\begin{pgfonlayer}{layer8}
\draw[very thick] (13,0,0) -- (14,0,0);
\end{pgfonlayer}
\tikzset{%
xyz path/.style args={\x=#1; \y=#2; \z=#3; (#4)}{
insert path={
\foreach \step [evaluate={\x=#1; \y=#2; \z=#3;}] in {#4}{
-- (\x, \y, \z) }
}
},
cosine path/.style args={#1:#2}{
xyz path={\x=cos(\step); \y=0; \z=\step/360; (#1, 2, ..., #2)},
insert path={ coordinate (cosine path end) }
},
sine path/.style args={#1:#2}{
xyz path={\x=0; \y=sin(\step); \z=\step/360; (#1, 2, ..., #2)},
insert path={ coordinate (sine path end) }
},
spiral path/.style args={#1:#2}{
xyz path={\x=cos(\step); \y=sin(\step); \z=\step/360; (#1, 2, ..., #2)},
insert path={ coordinate (spiral path end) }
},
marker/.style={
insert path={
node [fill, circle, inner sep=0pt, minimum size=#1] {}
}
}
}
\def\lastangle{15}
\def\cycles{4}
\foreach \cycle in {0,...,\cycles}{
\tikzset{shift={(0, 0, \cycle)}}
\ifnum\cycle=\cycles
\let\endangle=\lastangle
\else
\def\endangle{360}
\fi
\draw [transform shape, blue, very thick] (1, 0, 0) [spiral path={0:\endangle}];
}
\end{tikzpicture}
\end{document}

\tdplotsetmaincoords. – John Kormylo Feb 06 '24 at 01:44