KTUG 한국 텍 사용자 그룹

Menu

KTUG :: Q&A 마당

\path coordinate로 고정된 좌표에 대하여 shift, scale, rotate와 같은 변형으로 점이 옮겨지지 않기 때문입니다.

(1) 새로운 coordinate를 얻어서 내부 사각형 그리기

(위의 aud 님이 보여주신 코드와 발상이 같습니다.)

\path coordinate (A1) at ($(A)!0.5!(B)$)
      coordinate (B1) at ($(B)!0.5!(C)$)
      coordinate (C1) at ($(C)!0.5!(D)$)
      coordinate (D1) at ($(D)!0.5!(A)$);

\draw (A1)--(B1)--(C1)--(D1)--cycle;

(2) \draw를 별도의 scope에 넣고 변형하기

\begin{scope}[shift={(2,0)},rotate around={45:(0,0)},scale={1/sqrt(2)}]
    \path coordinate (A) at (0,0) coordinate (B) at (4,0) 
          coordinate (C) at (4,4) coordinate (D) at (0,4);
    \draw (A)--(B)--(C)--(D)--cycle;
\end{scope}

이 경우에는 scope 내부에서 coordinate들을 한번 정의해주어야 합니다. 그래서 그다지 효율적으로 보이지 않는데 \draw한 오브젝트에 대하여 변형을 가하는 방법을 보여주기 위해서 제시합니다. (A)등의 이름은 재정의되므로 혼선을 줄이기 위해서라면 별도의 이름을 주는 것이 더 좋을 수도.

(3) 단순 매크로 치환

\def\pA{0,0}\def\pB{4,0}\def\pC{4,4}\def\pD{0,4}
\foreach \L in {A,B,C,D} { \coordinate (\L) at (\csname p\L\endcsname); }
\draw(A)--(B)--(C)--(D)--cycle;
\draw[shift={(2,0)},scale={1/sqrt(2)},rotate=45] (\pA)--(\pB)--(\pC)--(\pD)--cycle;

(4)  2와 3을 합쳐서 전체를 써보면 다음처럼 되겠습니다.

\def\pA{0,0}\def\pB{4,0}\def\pC{4,4}\def\pD{0,4}
\foreach \L in {A,B,C,D} { \coordinate (\L) at (\csname p\L\endcsname); }

\draw (A)--(B)--(C)--(D)--cycle;

\begin{scope}[shift={(2,0)},rotate around={45:(0,0)},scale={1/sqrt(2)}]
    \foreach \L in {A,B,C,D} { \coordinate (\L1) at (\csname p\L\endcsname); }    
    \draw (A1)--(B1)--(C1)--(D1)--cycle;
\end{scope}

 

KTUG 한국 텍 사용자 그룹