我正在尝试根据之前在另一个级别上定义的节点的( x
, ) 坐标在 3D 中定位节点。但是,我不知道如何让它工作:y
z
\documentclass{article}
\usepackage{tikz}
\usepackage[utf8]{inputenc}
\usepackage[pdftex, active, tightpage]{preview}
\usetikzlibrary{calc, 3d, backgrounds, positioning}
\setlength\PreviewBorder{2mm}
\begin{document}
\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{background,main,foreground}
\begin{preview}
\begin{tikzpicture}[scale = 1, x = {(-0.2cm, -0.5cm)},
y = {(0.9659cm, -0.05882cm)},
z = {(0cm, 1cm)}]
\begin{scope}[canvas is yx plane at z = 0]
\draw (2, 3) node[inner sep = 0pt, outer sep = 0pt, color = black!60, circle, minimum size = 0.2pt] (1) {};
\draw (3, 3) node[inner sep = 0pt, outer sep = 0pt, color = black!60, circle, minimum size = 0.2pt] (2) {};
\draw (3, 2) node[inner sep = 0pt, outer sep = 0pt, color = black!60, circle, minimum size = 0.2pt] (3) {};
\draw (1.center) -- (2.center) -- (3.center) -- cycle;
\end{scope}
\begin{scope}[canvas is yx plane at z = 1.5]
\draw (2, 3) node[inner sep = 0pt, outer sep = 0pt, color = red!60, circle, fill, text width = 0.2pt] {};
\draw node[inner sep = 0pt, outer sep = 0pt, color = blue!60, circle, fill, text width = 0.2pt] at (1) {};
\end{scope}
\end{tikzpicture}
\end{preview}
\end{document}
红色节点是他应该在的位置,具有明确的(x
,y
)坐标(就在第一个节点的“上方”),但蓝色节点位于z = 0
实现这一目标的有效方法是什么,即让蓝色节点覆盖红色节点?(是否可以避免使用第二个参数scope
,而只使用at (1) ++ some magic relative displacement in 3D here
甚至一些隐藏的(*)zshift
参数?)
(*)我在手册中找不到这个
答案1
我不确定我是否理解了您的代码。我做了一些修改,但如果我走错了方向,我会更新我的答案。
首先minimum size = 0.2pt
,它不够大,无法看到圆圈。默认情况下,线宽为0.4 pt
,如果要看到节点,则需要增加宽度!然后,您可以避免一些重复并使用styles
节点。创建第二个范围时,如果您用来(2,3)
放置节点,则使用画布,并且节点放置正确。但是,当您想要将蓝色节点放置在 (1) 处时,您将节点放置在定义的坐标 (1) 处,该坐标定义在此范围之外,因此 (1) 的坐标不会改变!
我不明白text width = 0.2pt
你的代码。这是一个错误吗?
这也许是最简单的代码:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc, 3d, backgrounds, positioning}
\begin{document}
\begin{tikzpicture}[scale = 1,
x = {(-0.2cm, -0.5cm)},
y = {(0.9659cm, -0.05882cm)},
z = {(0cm, 1cm)},
every node/.style ={draw,
circle, minimum size = 1.8pt,
inner sep = 0pt, outer sep = 0pt}]
\begin{scope}[canvas is yx plane at z = 0,
every node/.append style ={ color = black!60}]
\node (1) at (2, 3) {};
\node (2) at (3, 3) {};
\node (3) at (3, 2) {};
\draw (1.center) -- (2.center) -- (3.center) -- cycle;
\end{scope}
\begin{scope}[every node/.append style ={ color = blue} ]
\node[yshift=1.5 cm] at (1) {};
\node[yshift=1.5 cm] at (2) {};
\node[yshift=1.5 cm] at (3) {};
\end{scope}
\end{tikzpicture}
\end{document}