在 3D 中使用 TikZ spy

在 3D 中使用 TikZ spy

我正在尝试使用该spy库来放大 3D TikZ 绘图的一部分。考虑这个最小的例子:

在此处输入图片描述

\documentclass[tikz,margin=0.5cm]{standalone}
\usetikzlibrary{3d,spy}

\begin{document}

\begin{tikzpicture}[y={(1cm,-0.5cm)},x={(1cm,0.5cm)}, z={(0cm,1cm)},spy using outlines={rectangle, magnification=4, size=2cm, connect spies}]

\coordinate (O) at (1, -1 -0.5);
\draw[->] (O) -- +(0.5, 0,  0) node [right] {$x$};
\draw[->] (O) -- +(0,  0.5, 0) node [below] {$y$};
\draw[->] (O) -- +(0,  0, 0.5) node [above] {$z$};

\draw [fill=blue!20] (0,0,0) -- (3,0,0) -- (3,2,0) -- (0,2,0) -- cycle;

\begin{scope}[canvas is yx plane at z=0,transform shape,every node/.style={scale=0.2}]
\node [align=center] (Text) at (1,1.5) {Make me\\ big!};
\end{scope}

\spy on (Text) in node at (1,1,3);

\end{tikzpicture}
\end{document}

这按预期工作,但我希望小方框具有 3D 视角。像这样:

在此处输入图片描述

因此,放大后的图片看起来就像是正面的:

在此处输入图片描述

这可能吗?

答案1

有一个lens选项允许你对小“间谍”图片应用转换(参见第 68.3 段)。蒂克/PGF 手册 [v 3.0.1a]):

\documentclass[tikz,margin=0.5cm]{standalone}
\usetikzlibrary{3d,spy}

\begin{document}

\begin{tikzpicture}[y={(1cm,-0.5cm)},x={(1cm,0.5cm)}, z={(0cm,1cm)},spy using outlines={rectangle, magnification=4, size=2cm, connect spies}]

\coordinate (O) at (1, -1 -0.5);
\draw[->] (O) -- +(0.5, 0,  0) node [right] {$x$};
\draw[->] (O) -- +(0,  0.5, 0) node [below] {$y$};
\draw[->] (O) -- +(0,  0, 0.5) node [above] {$z$};

\draw [fill=blue!20] (0,0,0) -- (3,0,0) -- (3,2,0) -- (0,2,0) -- cycle;

\begin{scope}[canvas is yx plane at z=0,transform shape,every node/.style={scale=0.2}]
\node [align=center] (Text) at (1,1.5) {Make me\\ big!};
\end{scope}

\spy[lens={xslant=-1,yslant=.5,scale=3}] on (Text) in node at (1,1,3);

\end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

与 Jasper Habicht 的回答非常相似,只是您不必手动调整镜头变换。因此,无论您为 3D 坐标系选择哪个向量,这都可以正常工作。

\documentclass[tikz,margin=0.5cm]{standalone}
\usetikzlibrary{3d,spy}

\begin{document}

\begin{tikzpicture}[y={(1cm,-0.5cm)},x={(1cm,0.5cm)}, z={(0cm,1cm)},spy using outlines={rectangle, magnification=4, size=2cm, connect spies}]

\coordinate (O) at (1, -1 -0.5);
\draw[->] (O) -- +(0.5, 0,  0) node [right] {$x$};
\draw[->] (O) -- +(0,  0.5, 0) node [below] {$y$};
\draw[->] (O) -- +(0,  0, 0.5) node [above] {$z$};

\draw [fill=blue!20] (0,0,0) -- (3,0,0) -- (3,2,0) -- (0,2,0) -- cycle;

\begin{scope}[canvas is yx plane at z=0,transform shape,every node/.style={scale=0.2}]
\node [align=center] (Text) at (1,1.5) {Make me\\ big!};
\pgfgettransform{\mytrafo} % read off transformation
\xdef\mytrafo{\mytrafo} % globalize macro
\end{scope}

\spy[lens={/utils/exec={\pgfsettransform{\mytrafo} % reinstall and invert trafo
\pgftransforminvert},scale=3}] on (Text) in node at (1,1,3);

\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容