
극좌표와 데카르트 좌표를 혼합하고 있기 때문에 비합리적인 좌표가 있는 점이 있습니다. 좌표를 한 사물의 x 값과 다른 사물의 y 값으로 지정하고 싶습니다.
이 특정 예에서는 왼쪽의 두 선이 동일한 왼쪽 끝점을 갖기를 원합니다.
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\coordinate (left) at (155:2);
\coordinate (top) at (65:2);
\coordinate (bottom) at (245:2);
\coordinate (right) at (335:2);
\coordinate (leftEdge) at ($ (left) + (-2,0) $);
\coordinate (bottomEdge) at ($ (bottom) + (0,-2) $);
\path[draw=black] (left) -- (top) -- (right) -- (bottom) -- cycle;
\path[draw=blue] (left) -- (leftEdge);
\path[draw=black] (bottom) -- (bottomEdge);
\path[draw=red] (bottom) -- ++(-2,0);
\end{tikzpicture}
\end{document}
와 같은 방법으로 이 작업을 수행할 수 있는 방법이 있다고 생각 (leftEdge.x,bottom.y)
하지만 제대로 작동시키지 못했습니다.
빨간색 가장자리를 파란색 가장자리만큼 왼쪽으로 이동하려면 어떻게 해야 합니까?
답변1
귀하의 예에서 귀하가 해야 할 일은 다음과 같이 말하는 것입니다.\path[draw=red] (bottom) -- (bottom-|leftEdge);
.이 훌륭한 답변이 구문에 대한 자세한 설명을 제공합니다.
\documentclass[tikz]{standalone}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\coordinate (left) at (155:2);
\coordinate (top) at (65:2);
\coordinate (bottom) at (245:2);
\coordinate (right) at (335:2);
\coordinate (leftEdge) at ($ (left) + (-2,0) $);
\coordinate (bottomEdge) at ($ (bottom) + (0,-2) $);
\path[draw=black] (left) -- (top) -- (right) -- (bottom) -- cycle;
\path[draw=blue] (left) -- (leftEdge);
\path[draw=black] (bottom) -- (bottomEdge);
\path[draw=red] (bottom) -- (bottom-|leftEdge);
\end{tikzpicture}
\end{document}