我有一个类似的问题,关于粒子轨迹的圆环与圆弧相结合这里。在薛定谔猫的大力支持下,我成功绘制出了所需的图。现在,我尝试用圆锥体绘制相同的图,灵感来自以下草图:
\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[dvipsnames]{xcolor}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usetikzlibrary{3d,backgrounds,calc}
\begin{document}
\begin{tikzpicture}[thkline/.style={thick, blue, >=stealth},font=\sffamily]
\begin{axis}[anchor=origin,
xmax=15, ymax=15, zmax=10, axis lines = none,
domain=0:15,
colormap={green}{color=(green) color=(green)},
clip=false]
%background stuff
\draw[ultra thick] (0,0,0) coordinate(O) -- (-25,0,0)
node[pos=2/3,above,sloped]{acceleration};
\path let \p1=($(1,0,0)-(0,0,0)$),\p2=($(0,1,0)-(0,0,0)$),
\p3=($(0,0,1)-(0,0,0)$) in
\pgfextra{\xdef\myxx{\x1}\xdef\myxy{\y1}
\xdef\myyx{\x2}\xdef\myyy{\y2}
\xdef\myzx{\x3}\xdef\myzy{\y3}};
% torus
\addplot3[surf, y domain=0:360]
( {x/20*cos(y)},
-{x},
{x/20*sin(y)} );
% foreground
\begin{scope}[canvas is xy plane at z=0,>=stealth]
\end{scope}
\end{axis}
\begin{scope}[x={(\myxx,\myxy)},y={(\myyx,\myyy)},z={(\myzx,\myzy)},
canvas is xy plane at z=0,>=stealth,on background layer]
\pgflowlevelsynccm
\draw[thick,blue] (0,30) -- (0,0);
\draw[->,blue] (0,30) -- (0,20);
\draw[->] (0,0) coordinate(O) -- (0,-7);
\draw[thick,dashed,gray] (0,0) arc(0:-30:50);
\end{scope}
% foreground
\begin{scope}[x={(\myxx,\myxy)},y={(\myyx,\myyy)},z={(\myzx,\myzy)},
canvas is xy plane at z=0,>=stealth]
\pgflowlevelsynccm
\draw[->] (0,-7) -- (0,-30);
\draw[ultra thick,red,->] (0,0) -- (-10,0);
\draw[thkline,->,overlay] (-50,0)+(-8:50) arc(-8:-20:50) node [above right] {$e^-$};
\end{scope}
\end{tikzpicture}
\end{document}
不过,我想知道是否有可能让圆锥体的形状更接近上面的图片。最终这只是一个细节,但可能有人知道这是否可行以及如何实现。
提前谢谢您!
答案1
这里有个建议。您只需在圆锥体的前端添加一个半椭圆体,即可使图像更接近。此外,我还有另外两个提示。如果您使用z buffer=sort
,圆锥体看起来确实像圆锥体。而在示波器中,这background
实际上意味着“被图覆盖”。
\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[dvipsnames]{xcolor}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usetikzlibrary{3d,backgrounds,calc}
\begin{document}
\begin{tikzpicture}[thkline/.style={thick, blue, >=stealth},font=\sffamily]
\begin{axis}[anchor=origin,
xmax=15, ymax=15, zmax=10, axis lines = none,
colormap={green}{color=(green) color=(green)},
clip=false]
%background stuff
\draw[ultra thick] (0,0,0) coordinate(O) -- (-25,0,0)
node[pos=2/3,above,sloped]{acceleration};
\path let \p1=($(1,0,0)-(0,0,0)$),\p2=($(0,1,0)-(0,0,0)$),
\p3=($(0,0,1)-(0,0,0)$) in
\pgfextra{\xdef\myxx{\x1}\xdef\myxy{\y1}
\xdef\myyx{\x2}\xdef\myyy{\y2}
\xdef\myzx{\x3}\xdef\myzy{\y3}};
% cone
\addplot3[surf,domain=0:15,y domain=0:360,z buffer=sort]
( {x/20*cos(y)},
-{x},
{x/20*sin(y)} );
\addplot3[surf,domain=0:360, y domain=0:180,samples y=13]
( {0.75*cos(x)*sin(y)},
{-15-1.25*cos(y)},
{0.75*sin(x)*sin(y)} );
% foreground
\begin{scope}[canvas is xy plane at z=0,>=stealth]
\end{scope}
\end{axis}
\begin{scope}[x={(\myxx,\myxy)},y={(\myyx,\myyy)},z={(\myzx,\myzy)},
canvas is xy plane at z=0,>=stealth,on background layer]
\pgflowlevelsynccm
\draw[thick,blue] (0,30) -- (0,0);
\draw[->,blue] (0,30) -- (0,20);
\draw[->] (0,0) coordinate(O) -- (0,-7);
\draw[thick,dashed,gray] (0,0) arc(0:-30:50);
\draw[->] (0,-7) -- (0,-30);
\draw[thkline,->,overlay] (-50,0)+(-8:50) arc(-8:-20:50) node [above right] {$e^-$};
\end{scope}
% foreground
\begin{scope}[x={(\myxx,\myxy)},y={(\myyx,\myyy)},z={(\myzx,\myzy)},
canvas is xy plane at z=0,>=stealth]
\pgflowlevelsynccm
\draw[ultra thick,red,->] (0,0) -- (-10,0);
\draw[->] (0,-16.25) -- (0,-30);
\end{scope}
\end{tikzpicture}
\end{document}
生成的pdf文件的相关部分:
也可以使用 一次性绘制该物体ifthenelse
。
\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[dvipsnames]{xcolor}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usetikzlibrary{3d,backgrounds,calc}
\begin{document}
\begin{tikzpicture}[thkline/.style={thick, blue, >=stealth},font=\sffamily]
\begin{axis}[anchor=origin,
xmax=15, ymax=15, zmax=10, axis lines = none,
colormap={green}{color=(green) color=(green)},
clip=false]
%background stuff
\draw[ultra thick] (0,0,0) coordinate(O) -- (-25,0,0)
node[pos=2/3,above,sloped]{acceleration};
\path let \p1=($(1,0,0)-(0,0,0)$),\p2=($(0,1,0)-(0,0,0)$),
\p3=($(0,0,1)-(0,0,0)$) in
\pgfextra{\xdef\myxx{\x1}\xdef\myxy{\y1}
\xdef\myyx{\x2}\xdef\myyy{\y2}
\xdef\myzx{\x3}\xdef\myzy{\y3}};
% cone
\addplot3[surf,domain=0:360, y domain=0:190,z buffer=sort,samples y=20]
( {ifthenelse(y>=180,0.75*(190-y)/10*cos(x),0.75*cos(x)*sin(y))},
{ifthenelse(y>=180,-15+1.5*(y-180),-15-1.25*cos(y))},
{ifthenelse(y>=180,0.75*(190-y)/10*sin(x),0.75*sin(x)*sin(y))} );
% foreground
\begin{scope}[canvas is xy plane at z=0,>=stealth]
\end{scope}
\end{axis}
\begin{scope}[x={(\myxx,\myxy)},y={(\myyx,\myyy)},z={(\myzx,\myzy)},
canvas is xy plane at z=0,>=stealth,on background layer]
\pgflowlevelsynccm
\draw[thick,blue] (0,30) -- (0,0);
\draw[->,blue] (0,30) -- (0,20);
\draw[->] (0,0) coordinate(O) -- (0,-7);
\draw[thick,dashed,gray] (0,0) arc(0:-30:50);
\draw[->] (0,-7) -- (0,-30);
\draw[thkline,->,overlay] (-50,0)+(-8:50) arc(-8:-20:50) node [above right] {$e^-$};
\end{scope}
% foreground
\begin{scope}[x={(\myxx,\myxy)},y={(\myyx,\myyy)},z={(\myzx,\myzy)},
canvas is xy plane at z=0,>=stealth]
\pgflowlevelsynccm
\draw[ultra thick,red,->] (0,0) -- (-10,0);
\draw[->] (0,-16.25) -- (0,-30);
\end{scope}
\end{tikzpicture}
\end{document}