\documentclass[fleqn]{book}
\usepackage{amsmath, amssymb}
\usepackage{amsthm}
\usepackage{xcolor}
\definecolor{nord0}{HTML}{2E3440}
\definecolor{nord4}{HTML}{D8DEE9}
\definecolor{nord5}{HTML}{E5E9F0}
\usepackage{tikz}
\usepackage{tikz-3dplot}
\usetikzlibrary{shapes.geometric, arrows.meta, decorations.markings}
\usepackage{pagecolor}
\pagecolor{nord0}
\tdplotsetmaincoords{60}{120}
\begin{document}
\begin{figure}[ht] % ’ht’ tells LaTeX to place the figure ’here’ or at the top of the page
\centering % centers the figure
\begin{tikzpicture}[tdplot_main_coords]% tikz code goes here
% Axes
\draw [-latex, color=nord4] (0,0,0) -- (4,0,0) node [below left] {$x$};
\draw [-latex, color=nord4] (0,0,0) -- (0,4,0) node [right] {$y$};
\draw [-latex, color=nord4] (0,0,0) -- (0,0,4) node [above] {$z$};
\draw[color=nord5] (0,0,0) ellipse (3cm and 1cm);
\draw[color=nord5] (0,0,0) ellipse (3.55cm and 1.2cm);
\draw[color=nord5] (0,0,1) ellipse (3cm and 1cm);
\draw[color=nord5] (0,0,1) ellipse (3.55cm and 1.2cm);
\draw[color=nord5, thick, decoration={markings, mark=at position 0.75 with {\arrow{stealth'}}}, postaction={decorate}] (0,0,0.5) ellipse (3.27cm and 1.1cm);
\end{tikzpicture}
\end{figure}
\end{document}
答案1
如果你想用 tikz 绘制圆环,我认为最好在平面上画一些圆圈canvas
,然后让 tikz 为你计算透视图。
以下代码有一个 tikz 绘图和一个可能的解决方案(如果我正确理解了您想要实现的目标)。然后我添加了另一个 pgfplots 绘图,可能更简单,看起来更好(对我来说)。
\documentclass[border=2mm]{standalone}
\usepackage{pgfplots}
\usepackage{tikz-3dplot}
\usetikzlibrary{shapes.geometric, arrows.meta, decorations.markings}
\pgfplotsset{compat=1.17}
\tdplotsetmaincoords{60}{120}
\begin{document}
\begin{tikzpicture}[tdplot_main_coords]
% Axes
\draw [-latex] (-3,0,0) -- (4,0,0) node [below left] {$x$};
\draw [-latex] (0,-3,0) -- (0,4,0) node [right] {$y$};
\draw [-latex] (0,0,0) -- (0,0,3) node [above] {$z$};
% Main circles
\begin{scope}[canvas is xy plane at z=0]
\draw (0,0) circle (2);
\draw[thick, red, decoration={markings, mark=at position 0.15 with {\arrow{stealth'}}}, postaction={decorate}] (0,0) circle (2.5);
\draw (0,0) circle (3);
\end{scope}
\begin{scope}[canvas is xy plane at z=0.5]
\draw (0,0) circle (2.5);
\end{scope}
\begin{scope}[canvas is xy plane at z=-0.5]
\draw (0,0) circle (2.5);
\end{scope}
\foreach\z in {10,20,...,80}
{
\pgfmathsetmacro\r{0.5*cos(\z)};
\begin{scope}[canvas is xy plane at z=0.5*sin(\z)]
\draw[very thin,gray] (0,0) circle (2.5+\r);
\draw[very thin,gray] (0,0) circle (2.5-\r);
\end{scope}
\begin{scope}[canvas is xy plane at z=-0.5*sin(\z)]
\draw[very thin,gray] (0,0) circle (2.5+\r);
\draw[very thin,gray] (0,0) circle (2.5-\r);
\end{scope}
}
\begin{scope}[canvas is xz plane at y=0]
\draw[dashed] (2.5,0) circle (0.5);
\draw[dashed] (-2.5,0) circle (0.5);
\end{scope}
\begin{scope}[canvas is yz plane at x=0]
\draw[dashed] (2.5,0) circle (0.5);
\draw[dashed] (-2.5,0) circle (0.5);
\end{scope}
\end{tikzpicture}
\begin{tikzpicture}
\begin{axis}[
axis equal,
axis lines=middle,
xmax=5,ymax=5,zmax=3,
ticks=none,
axis line style={draw=none}
]
\draw (0,0,0) -- (2,0,0);
\draw (0,0,0) -- (0,-2,0);
\draw[dashed] (2,0,0) -- (3,0,0);
\draw[dashed] (0,-2,0) -- (0,-3,0);
\addplot3[mesh, draw=gray!50, domain=0:360,y domain=0:360, samples=36]
({(2.5+0.5*cos(x))*cos(y)}, {(2.5+0.5*cos(x))*sin(y)}, {0.5*sin(x)});
\draw[-latex] (0,-3,0) -- (0,-4,0) node [left] {$x$};
\draw[-latex] (3,0,0) -- (4,0,0) node [right] {$y$};
\draw[-latex] (0,0,0) -- (0,0,3) node [above] {$z$};
\end{axis}
\end{tikzpicture}
\end{document}