3D 空间中的“漂亮”2D 椭圆

3D 空间中的“漂亮”2D 椭圆

我想使用 tikz 在 3D 空间中绘制一个“漂亮的”2D 椭圆。我使用的是 tikz 包和 tikz 库 arrows.meta

\usepackage{tikz}
\usetikzlibrary{arrows.meta}

这是我目前的代码:

\begin{tikzpicture}[scale=2.0, line cap=round, line join=round, >=Triangle]
\draw [->] (0,-1.75) -- (0,1.75); %z
\draw [->] (0.81,1.05) -- (-0.81,-1.05); %x
\draw [->] (-2.35,0) -- (2.35,0); %y
\draw (-1.15,-1.01) node[anchor=north west] {\Large $ {x}$};
\draw (2.40,0.15) node[anchor=north west] {\Large $ {y}$};
\draw (-0.05,2.20) node[anchor=north west] {\Large $ {z}$};
\draw[color=red, rotate around={25:(0,0)}] (0,0) ellipse (2.5cm and 1.00cm);
\draw [fill] (0,0) circle (1.5pt);
\end{tikzpicture}

此代码生成以下图表 在此处输入图片描述

有没有什么办法可以提高3D空间中椭圆的3D效果呢?

答案1

这里有两种可能性,取决于椭圆平面是否被假定在坐标有没有飞机。

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{tikzpicture}[scale=2.0, line cap=round, line join=round, >=Triangle]
\draw [->] (0,-1.75) -- (0,1.75); %z
\draw [->] (0.81,1.05) -- (-0.81,-1.05); %x
\draw [->] (-2.35,0) -- (2.35,0); %y
\draw (-1.15,-1.01) node[anchor=north west] {\Large $ {x}$};
\draw (2.40,0.15) node[anchor=north west] {\Large $ {y}$};
\draw (-0.05,2.20) node[anchor=north west] {\Large $ {z}$};
\draw[color=red, rotate around={25:(0,0)}] (0,0) ellipse (2.5cm and 1.00cm);
\draw [fill] (0,0) circle (1.5pt);
\draw [->, red] (0,0) -- (0,0.5); %z
\draw (0.05,0.70) node[anchor=north west] {\Large $ {\hat n}$};
\end{tikzpicture}

\begin{tikzpicture}[scale=2.0, line cap=round, line join=round, >=Triangle]
\draw [->] (0,-1.75) -- (0,1.75); %z
\draw [->] (0.81,1.05) -- (-0.81,-1.05); %x
\draw [->] (-2.35,0) -- (2.35,0); %y
\draw (-1.15,-1.01) node[anchor=north west] {\Large $ {x}$};
\draw (2.40,0.15) node[anchor=north west] {\Large $ {y}$};
\draw (-0.05,2.20) node[anchor=north west] {\Large $ {z}$};
\draw[color=red, rotate around={25:(0,0)}] (0,0) ellipse (2.5cm and 1.00cm);
\draw [fill] (0,0) circle (1.5pt);
\draw [->, red] (0,0) -- (-.2,0.5); %z
\draw (-0.47,0.70) node[anchor=north west] {\Large $ {\hat n}$};
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

您只需使用 即可tikz-3dplot

\documentclass[tikz,border=3.14pt]{standalone}
\usepackage{tikz-3dplot}
\usetikzlibrary{arrows.meta}
\begin{document}
\tdplotsetmaincoords{70}{30}
\begin{tikzpicture}[scale=2.0, line cap=round, line join=round, >=Triangle,tdplot_main_coords]
\draw[->] (0,0,0) -- (3,0,0)node[below]{$x$};
\draw[->] (0,0,0) -- (0,3,0)node[left]{$y$};
\draw[->] (0,0,0) -- (0,0,3)node[left]{$z$};
\draw[color=red] (0,0,0) ellipse (2.5cm and 1.00cm);
\draw [fill] (0,0,0) circle (1.5pt);
\end{tikzpicture}
\end{document}

在此处输入图片描述

然后调整视角和/或在旋转的平面上绘制椭圆。

编辑:只是为了好玩:一个旋转的椭圆。

\documentclass[tikz,border=3.14pt]{standalone}
\usepackage{tikz-3dplot}
\usetikzlibrary{arrows.meta}
\begin{document}
\tdplotsetmaincoords{70}{30}
\begin{tikzpicture}[scale=2.0, line cap=round, line join=round, >=Triangle,tdplot_main_coords]
\draw[->] (0,0,0) -- (3,0,0)node[below]{$x$};
\draw[->] (0,0,0) -- (0,3,0)node[left]{$y$};
\draw[->] (0,0,0) -- (0,0,3)node[left]{$z$};
\draw [fill] (0,0,0) circle (1.5pt);
\tdplotsetrotatedcoords{0}{20}{0}
\begin{scope}[tdplot_rotated_coords]
\draw[color=red] plot[variable=\x,domain=0:360,samples=360]
({2.5*cos(\x)},{sin(\x)});
\end{scope}
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容