我想用 tikz 在 3d 斧头和 CO2 分子上画激光。以下代码
\begin{tikzpicture}[x={(0.707cm,0.707cm)},z={(0cm,1cm)},y=
{(-0.866cm,0.5cm)},declare function={RCO=2.2;}]
\draw[->] (-3,0,0) -- (3,0,0) node[right] {z};
\draw[->] (0,-3,0) -- (0,3,0) node[left] {x};
\draw[->] (0,0,-3) -- (0,0,2*3.141592654) node[above] {y};
\draw (1,0,0)
\foreach \z in {3.141592654,3.2,...,6.28}
{ -- (0,{cos(\z*200)},{\z}) % 1 = cos(\z*400) %{sin(\z*100)}
};
\filldraw[ball color=red] (0,-2) circle (\Rh);
\filldraw[ball color=black] (0,0) circle (\Rh);
\filldraw[ball color=red] (0,2) circle (\Rh);
\end{tikzpicture}
答案1
\documentclass[tikz, border = 5pt]{standalone}
\begin{document}
\newcommand{\Rh}{0.12}
\begin{tikzpicture}[x={(0.707cm,0.707cm)},z={(0cm,1cm)},y=
{(-0.866cm,0.5cm)},declare function={RCO=2.2;}]
\draw[->] (-3,0,0) -- (3,0,0) node[right] {z};
\draw[->] (0,-3,0) -- (0,3,0) node[left] {x};
\draw[->] (0,0,-3) -- (0,0,2*3.141592654) node[above] {y};
\draw[thick, red] (0,0,3.141592654)
\foreach \z in {3.141592654,3.2,...,6.28}
{ -- (0,{cos(\z*200)},{\z}) % 1 = cos(\z*400) %{sin(\z*100)}
};
\filldraw[ball color=red] (0,-2) circle (\Rh);
\filldraw[ball color=black] (0,0) circle (\Rh);
\filldraw[ball color=red] (0,2) circle (\Rh);
\end{tikzpicture}
\end{document}
答案2
\documentclass[tikz,border=3.14mm]{standalone}
\begin{document}
\def\Rh{0.2}
\begin{tikzpicture}[x={(0.707cm,0.707cm)},z={(0cm,1cm)},y=
{(-0.866cm,0.5cm)},declare function={RCO=2.2;}]
\draw[->] (-3,0,0) -- (3,0,0) node[right] {z};
\draw[->] (0,-3,0) -- (0,3,0) node[left] {x};
\draw[->] (0,0,-3) -- (0,0,2*3.141592654) node[above] {y};
\draw plot[variable=\z,domain={pi}:{2*pi},samples=100]
(0,{cos(\z*200)},{\z});
\filldraw[ball color=red] (0,-2) circle (\Rh);
\filldraw[ball color=black] (0,0) circle (\Rh);
\filldraw[ball color=red] (0,2) circle (\Rh);
\end{tikzpicture}
\end{document}