![如何使小圆圈看起来就像投影在 xyz 坐标上的平面上?](https://linux22.com/image/474204/%E5%A6%82%E4%BD%95%E4%BD%BF%E5%B0%8F%E5%9C%86%E5%9C%88%E7%9C%8B%E8%B5%B7%E6%9D%A5%E5%B0%B1%E5%83%8F%E6%8A%95%E5%BD%B1%E5%9C%A8%20xyz%20%E5%9D%90%E6%A0%87%E4%B8%8A%E7%9A%84%E5%B9%B3%E9%9D%A2%E4%B8%8A%EF%BC%9F.png)
我使用 xyz 坐标系绘制 3D 轴和平面。我用圆圈标记了平面。但是,由于圆圈没有投影到平面上,而是“面向”观察者,因此破坏了 3D 视角。
有什么方法可以将圆投影到平面上吗?即使只使用一个仅适用于这种特定情况的巧妙椭圆,我也会很高兴。
\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}[x=0.5cm,y=0.5cm,z=-0.25cm]
% plane
\filldraw[fill=lightgray!50] (0,0) -- (xyz cs:y=3,z=0) -- (xyz cs:y=3,z=3) -- (xyz cs:y=0,z=3) -- cycle;
% axis
\draw[-stealth] (xyz cs:x=0) -- (xyz cs:x=4);
\draw[-stealth] (xyz cs:y=0) -- (xyz cs:y=4);
\draw[-stealth] (xyz cs:z=0) -- (xyz cs:z=4);
% plane label+marker
\node[circle, fill=black, inner sep=0pt, minimum size=6pt] at (xyz cs:y=1,z=1.5) (plane marker) {};
\node[anchor=north west] at (xyz cs:x=0,y=-1,z=0) (plane label) {plane};
\draw (plane label.west) to[out=180,in=-90] (plane marker);
\end{tikzpicture}
\end{document}
答案1
您可以利用该3d
库,而不是使用节点(不会受到 3D 转换的影响)绘制一个真实的圆圈并在其中心放置一个坐标:
\documentclass[tikz, border=10pt]{standalone}
\usetikzlibrary{3d}
\begin{document}
\begin{tikzpicture}[x=0.5cm,y=0.5cm,z=-0.25cm]
% plane
\filldraw[fill=lightgray!50] (0,0) -- (xyz cs:y=3,z=0) -- (xyz cs:y=3,z=3) -- (xyz cs:y=0,z=3) -- cycle;
% axis
\draw[-stealth] (xyz cs:x=0) -- (xyz cs:x=4);
\draw[-stealth] (xyz cs:y=0) -- (xyz cs:y=4);
\draw[-stealth] (xyz cs:z=0) -- (xyz cs:z=4);
% plane label+marker
% \node[circle, fill=black, inner sep=0pt, minimum size=6pt] at (xyz cs:y=1,z=1.5) {};
\begin{scope}[canvas is yz plane at x=0]
\fill (1,1.5) circle[radius=6pt]
coordinate (plane marker);
\end{scope}
\node[anchor=north west] at (xyz cs:x=0,y=-1,z=0) (plane label) {plane};
\draw (plane label.west) to[out=180, in=-90] (plane marker);
\end{tikzpicture}
\end{document}
答案2
另一种代码如下。3D 库已加载,可以使用画布yz
平面x=0
:
\documentclass[tikz]{standalone}
\usetikzlibrary{3d} % Load the 3d TikZ library
\begin{document}
\begin{tikzpicture}[x=0.5cm,y=0.5cm,z=-0.25cm]
% plane
\filldraw[fill=lightgray!50] (0,0) -- (xyz cs:y=3,z=0) -- (xyz cs:y=3,z=3) -- (xyz cs:y=0,z=3) -- cycle;
% axis
\draw[-stealth] (xyz cs:x=0) -- (xyz cs:x=4);
\draw[-stealth] (xyz cs:y=0) -- (xyz cs:y=4);
\draw[-stealth] (xyz cs:z=0) -- (xyz cs:z=4);
% plane label+marker
\coordinate (plane marker) at (xyz cs:y=1,z=1.5);
\node[anchor=north west] at (xyz cs:x=0,y=-1,z=0) (plane label) {plane};
% Projecting the circle onto the plane
\begin{scope}[canvas is yz plane at x=0]
\coordinate (proj) at (1,1.5);
\filldraw[fill=black] (proj) circle (4pt);
\end{scope}
\draw (plane label.west) to[out=180,in=-90] (proj);
\end{tikzpicture}
\end{document}