我卡住了,因为我尝试在两个蓝色向量之间绘制一个角度(红色),但在轴环境中却无法得到它。有人能帮我吗?
这里,代码:
\documentclass[b5paper,10pt,twoside,titlepage,final,openright]{book}
\usepackage{tikz}
\usetikzlibrary{external}
\tikzexternalize[prefix=figures/]
\newcommand{\includetikz}[1]{%
\tikzsetnextfilename{#1}%
\input{#1.tikz}%
}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
compat=newest,
colormap={mycolormap}{
color=(darkgray)
color=(gray)
color=(white)
},
axis equal image,
hide axis,
z buffer = sort,
view = {100}{45},
scale=3
]
\addplot3[
surf,
shader=interp,
samples = 30,
samples y= 60,
domain = 0:2*pi,
domain y = pi/3:2*pi,
colormap name = mycolormap,
thin
] (
{(0.55*pi+0.33*pi*cos(deg(\x)))*cos(deg(\y))},
{(0.55*pi+0.33*pi*cos(deg(\x)))*sin(deg(\y))},
{0.33*pi*sin(deg(\x))}
);
\addplot3[
surf,
shader=interp,
samples = 2,
samples y= 30,
domain = 0:0.33*pi,
domain y = 0:2*pi,
colormap name = mycolormap,
thin
] (
{(0.55*pi+\x*cos(deg(\y)))*cos(deg(0))},
{(0.55*pi+\x*cos(deg(\y)))*sin(deg(0))},
{\x*sin(deg(\y))}
);
\addplot3[
surf,
shader=interp,
samples = 2,
samples y= 30,
domain = 0:0.33*pi,
domain y = 0:2*pi,
colormap name = mycolormap,
thin
] (
{(0.55*pi+\x*cos(deg(\y)))*cos(deg(pi/3))},
{(0.55*pi+\x*cos(deg(\y)))*sin(deg(pi/3))},
{\x*sin(deg(\y))}
);
\coordinate (O) at (0,0,0);
\coordinate (A) at (0.55*pi,0,0);
\coordinate (AA) at (0.88*pi,0,0);
\coordinate (B) at (0.55*pi*0.5,0.55*pi*0.866,0);
\coordinate (BB) at (0.88*pi*0.5,0.88*pi*0.866,0);
\coordinate (C) at (1.31285, 2.27393, 0.518363);
\draw (O) -- (A);
\draw (O) -- (B);
\draw[->] (B) -- (C);
\draw[dashed] (B) -- (BB);
\draw[dashed] (A) -- (AA);
\draw[->] (1,0,0) arc [start angle=0,end angle=60,x radius=1,y radius=1];
\coordinate (X) at (axis cs: 1.3823, 2.39414, 0);
\draw (X) arc (0:90:1);
\end{axis}
\end{tikzpicture}
\end{document}
答案1
像这样吗?
\documentclass[b5paper,10pt,twoside,titlepage,final,openright]{book}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usetikzlibrary{3d}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
colormap={mycolormap}{
color=(darkgray)
color=(gray)
color=(white)
},
axis equal image,
hide axis,
z buffer = sort,
view = {100}{45},
scale=3
]
\addplot3[
surf,
shader=interp,
samples = 30,
samples y= 60,
domain = 0:2*pi,
domain y = pi/3:2*pi,
colormap name = mycolormap,
thin
] (
{(0.55*pi+0.33*pi*cos(deg(\x)))*cos(deg(\y))},
{(0.55*pi+0.33*pi*cos(deg(\x)))*sin(deg(\y))},
{0.33*pi*sin(deg(\x))}
);
\addplot3[
surf,
shader=interp,
samples = 2,
samples y= 30,
domain = 0:0.33*pi,
domain y = 0:2*pi,
colormap name = mycolormap,
thin
] (
{(0.55*pi+\x*cos(deg(\y)))*cos(deg(0))},
{(0.55*pi+\x*cos(deg(\y)))*sin(deg(0))},
{\x*sin(deg(\y))}
);
\addplot3[
surf,
shader=interp,
samples = 2,
samples y= 30,
domain = 0:0.33*pi,
domain y = 0:2*pi,
colormap name = mycolormap,
thin
] (
{(0.55*pi+\x*cos(deg(\y)))*cos(deg(pi/3))},
{(0.55*pi+\x*cos(deg(\y)))*sin(deg(pi/3))},
{\x*sin(deg(\y))}
);
\coordinate (O) at (0,0,0);
\coordinate (A) at (0.55*pi,0,0);
\coordinate (AA) at (0.88*pi,0,0);
\coordinate (B) at (0.55*pi*0.5,0.55*pi*0.866,0);
\coordinate (BB) at (0.88*pi*0.5,0.88*pi*0.866,0);
\coordinate (C) at (1.31285, 2.27393, 0.518363);
\draw (O) -- (A);
\draw (O) -- (B);
\draw[-stealth] (B) -- (C);
\draw[dashed] (B) -- (BB);
\draw[dashed] (A) -- (AA);
\begin{scope}[canvas is xy plane at z=0]
\draw[-stealth] (1,0) arc [start angle=0,end angle=60,x radius=1,y radius=1]
node[midway,below right] {$\theta$};
\end{scope}
\addplot3[
domain = 0:pi/6] (
{(0.55*pi+0.6*0.33*pi*cos(deg(\x)))*cos(60)},
{(0.55*pi+0.6*0.33*pi*cos(deg(\x)))*sin(60)},
{0.6*0.33*pi*sin(deg(\x))}
) node[midway,right] {$\varphi$};
\end{axis}
\end{tikzpicture}
\end{document}
仅使用 arc 和 3d 库即可获得相同的效果。需要小心,因为axis
环境的原点不是 Ambient 的原点tikzpicture
。
\documentclass[b5paper,10pt,twoside,titlepage,final,openright]{book}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usetikzlibrary{calc,3d}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
colormap={mycolormap}{
color=(darkgray)
color=(gray)
color=(white)
},
axis equal image,
hide axis,
z buffer = sort,
view = {100}{45},
scale=3
]
\addplot3[
surf,
shader=interp,
samples = 30,
samples y= 60,
domain = 0:2*pi,
domain y = pi/3:2*pi,
colormap name = mycolormap,
thin
] (
{(0.55*pi+0.33*pi*cos(deg(\x)))*cos(deg(\y))},
{(0.55*pi+0.33*pi*cos(deg(\x)))*sin(deg(\y))},
{0.33*pi*sin(deg(\x))}
);
\addplot3[
surf,
shader=interp,
samples = 2,
samples y= 30,
domain = 0:0.33*pi,
domain y = 0:2*pi,
colormap name = mycolormap,
thin
] (
{(0.55*pi+\x*cos(deg(\y)))*cos(deg(0))},
{(0.55*pi+\x*cos(deg(\y)))*sin(deg(0))},
{\x*sin(deg(\y))}
);
\addplot3[
surf,
shader=interp,
samples = 2,
samples y= 30,
domain = 0:0.33*pi,
domain y = 0:2*pi,
colormap name = mycolormap,
thin
] (
{(0.55*pi+\x*cos(deg(\y)))*cos(deg(pi/3))},
{(0.55*pi+\x*cos(deg(\y)))*sin(deg(pi/3))},
{\x*sin(deg(\y))}
);
\coordinate (O) at (0,0,0);
\coordinate (A) at (0.55*pi,0,0);
\coordinate (AA) at (0.88*pi,0,0);
\coordinate (B) at (0.55*pi*0.5,0.55*pi*0.866,0);
\coordinate (BB) at (0.88*pi*0.5,0.88*pi*0.866,0);
\coordinate (C) at (1.31285, 2.27393, 0.518363);
\draw (O) -- (A);
\draw (O) -- (B);
\draw[-stealth] (B) -- (C);
\draw[dashed] (B) -- (BB);
\draw[dashed] (A) -- (AA);
\begin{scope}[canvas is xy plane at z=0]
\draw[-stealth] (1,0) arc [start angle=0,end angle=60,x radius=1,y radius=1]
node[midway,below right] {$\theta$};
\end{scope}
% export the relevant coordinates
\path (0,0,0) coordinate (O) ({cos(60)},{sin(60)},0) coordinate (X)
({cos(60+90)},{sin(60+90)},0) coordinate (Y) (0,0,1) coordinate (Z);
\end{axis}
\begin{scope}[x={($(X)-(O)$)},y={($(Y)-(O)$)},z={($(Z)-(O)$)},shift={(O)}]
\begin{scope}[canvas is xz plane at y=0]
\draw (0.55*pi+0.6,0) arc[start angle=00,end angle=30,radius=0.6]
node[midway,right] {$\varphi$};
\end{scope}
\end{scope}
\end{tikzpicture}
\end{document}