如何使小圆圈看起来就像投影在 xyz 坐标上的平面上?

如何使小圆圈看起来就像投影在 xyz 坐标上的平面上?

我使用 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}

在此处输入图片描述

相关内容