tikz에서 전체적으로 베지어 곡선 이동

tikz에서 전체적으로 베지어 곡선 이동

제어점을 변경하지 않고 베지어 곡선 전체를 쉽게 이동할 수 있는 방법이 있습니까(예: x 방향으로 2cm, y 방향으로 1cm)?

\documentclass[11pt]{standalone}
\usepackage{tikz}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
  \draw (0,0) .. controls (1,1) and (2,-1) .. (3,0);
\end{tikzpicture}
\end{document}

xshift 및 yshift 키는 해당 용도로 사용할 수 없는 것 같습니다. 감사합니다

편집하다:Guilherme이 지적했듯이옮기다속성이 잘 작동합니다.

\documentclass[11pt]{standalone}
\usepackage{tikz}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
  \draw (0,0) .. controls (1,1) and (2,-1) .. (3,0);
  \draw[shift={(2cm,1cm)}] (0,0) .. controls (1,1) and (2,-1) .. (3,0);
\end{tikzpicture}
\end{document}

그러나 곡선의 좌표를 미리 정의하면 작동하지 않습니다.

\documentclass[11pt]{standalone}
\usepackage{tikz}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
    \coordinate (A1) at (0,0);
    \coordinate (A2) at (1,1);
    \coordinate (A3) at (2,-1);
    \coordinate (A4) at (3,0);

    \draw (A1) .. controls (A2) and (A3) .. (A4);
    \draw[shift={(2cm,1cm)}] (A1) .. controls (A2) and (A3) .. (A4);
\end{tikzpicture}
\end{document}

두 번째 곡선은 원래 위치에서 이동하지 않습니다.

답변1

좌표는 이동되지 않고 고정되어 있습니다(이것은 좋은 일이며 일반적으로 우리가 원하는 것입니다). 단지 .transform canvas={shift={(2cm,1cm)}}shift

또는 모든 좌표를 이동할 수 있습니다. c/.style={shift={(2cm,1cm)}}그런 다음:

\draw[shift={(2cm,1cm)}] ([c]A1) .. controls ([c]A2) and ([c]A3) .. ([c]A4);

둘 다 작동해야 하며 두 번째 방법이 우선되어야 합니다. 좌표계 변환을 조작하면 예상치 못한 결과가 발생할 수 있습니다(도구의 기능을 모르는 경우 예상치 못한 결과가 발생합니다...).

답변2

또 다른 아이디어(귀하의 경우에 적합할 수도 있고 적합하지 않을 수도 있음)는 필요한 모양을 pic. 내부에서는 pic명명된 좌표를 사용하여 모양을 그릴 수 있으며, 을 pic그림의 일부로 사용하면 쉽게 이동, 크기 조정 또는 회전할 수 있습니다.

\documentclass[11pt]{standalone}
\usepackage{tikz}
%\usepackage{pgfplots}

\tikzset{
mybezier/.pic = {
    \coordinate (A1) at (0,0);
    \coordinate (A2) at (1,1);
    \coordinate (A3) at (2,-1);
    \coordinate (A4) at (3,0);
    \draw (A1) .. controls (A2) and (A3) .. (A4);
    }
}
\begin{document}
\begin{tikzpicture}
\path (0,0) pic {mybezier};
\path (2,1) pic {mybezier};
\path (0,-1) pic[red, rotate=-30, scale=1.5] {mybezier};
\end{tikzpicture}
\end{document}

생산물:

결과

관련 정보