다음 코드를 사용합니다.
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{intersections}
\begin{document}
\begin{tikzpicture}
\draw[help lines] (0,0) grid (10,10);
\draw[very thick,rotate around={45:(2.3,5)}] (2.3,5) rectangle ++(4,0.3) ++(0,-0.15) node[inner sep=0pt,outer sep=0pt] (p2) {};
\draw[very thick,rotate around={-10:($(2.3,5)+(45:4)$)}] (2.3,5)++(45:4) rectangle ++(4,0.3)--++(0,0.2)--++(0.7,0)--++(0,-0.15)--++(-0.55,0)--++(0,-0.4)--++(0.55,0)--++(0,-0.15)--++(-0.7,0)--++(0,0.2)++(-4,0)++(0,0.15) coordinate (p3);
\draw[name path=2nd2] (p2)--+(45:2);
\draw[name path=3rd] (p3)--+(170:2);
\path[name intersections={of=2nd2 and 3rd,by=i23}];
\fill[red] (i23) circle (0.5pt);
\end{tikzpicture}
\end{document}
출력은 다음과 같습니다.
확대해 보면 (p3)
with 와 달리 with 와 에서 시작하는 선 coordinate
사이에 거리가 있는 것을 알 수 있습니다 . 격차의 원인을 설명할 수 있는 사람이 있나요? 감사합니다.(p2)
node[inner sep=0pt,outer sep=0pt]
(p2)
답변1
빈 노드는 inner sep
및 outer sep
둘 모두에 0pt
공백이 있는 경우에도 여전히 완전히 비어 있지 않습니다. 반면에 좌표는 좌표계의 한 지점일 뿐입니다. 노드에서 동일한 동작을 얻으려면 minimum size=0pt
. 아래 예의 세 노드와 좌표를 비교해보세요.
\begin{tikzpicture}
\draw[gray!40] (0,0) grid (4,3);
\node[label=below:np] (np) at (1,2){};
\node[label=below:np2,inner sep=0pt,outer sep=0pt] (np2) at (2,2){};
\node[label=below:np3,inner sep=0pt,outer sep=0pt,minimum size=0pt] (np3) at (1,1){};
\coordinate[label=below:cp] (cp) at (2,1);
\foreach \angle in {0,45,...,315}{
\draw[very thin,red] (np.\angle) circle (0.2pt);
\draw[very thin,red] (np2.\angle) circle (0.2pt);
\draw[very thin,red] (np3.\angle) circle (0.2pt);
\draw[very thin,red] (cp.\angle) circle (0.2pt);
}
\end{tikzpicture}
왼쪽 상단에는 일반 노드가 있고, 오른쪽 상단에는 내부 및 외부 sep가 0으로 설정된 노드, 왼쪽 하단에는 minimum size
0으로 설정된 빈 노드, 오른쪽 하단에는 좌표가 있으며, 4개 모두에 작은 원이 있습니다. 모든 방향(45도 분리).
귀하의 예에서는 노드에서 (p2)
45도 방향으로 그릴 때 에서 시작하여 (p2.45)
작은 간격이 생깁니다. 다음으로 변경해 보세요.
\draw[name path=2nd2] (p2.center)--+(45:2);
또는 (p2)
로 변경하거나 coordinate
을 추가하세요 minimum size=0pt
.