TikZ를 사용하여 나선 이미지 재현

TikZ를 사용하여 나선 이미지 재현

아래 그림의 나선형 모양을 TikZ에서 재현하려고 하는데 원자와 텍스트에는 관심이 없고 나선형에만 관심이 있습니다. 이미지처럼 나선형을 녹색으로 표시하고 싶습니다.

재현할 사진

여러 개의 부비동 곡선을 어떻게든 조합하는 것을 고려하고 있었지만 이는 정말 비효율적인 방법인 것 같았고 그 방법을 사용하여 모양을 어떻게 색칠할지 모르겠습니다.

답변1

가능한 해결책은 다음과 같습니다.

여기에 이미지 설명을 입력하세요

\documentclass[tikz]{standalone}

\begin{document}
\begin{tikzpicture}
  \colorlet{color 2}{lime!50!gray}
  \colorlet{color 1}{white}
  \foreach \dx in {0,2,4}{
    \begin{scope}[xshift=\dx cm]
      \draw[draw=gray,top color=color 2,bottom color=color 1]
      (0,0) -- ++(1,0) cos ++(.5,1) sin ++(.5,1) -- ++(-1,0) cos ++(-.5,-1) sin ++(-.5,-1) -- cycle;
    \end{scope}
  }
  \foreach \dx in {0,2,4}{
    \begin{scope}[xshift=1cm + \dx cm]
      \draw[draw=gray,top color=color 1,bottom color=color 2]
      (0,2) -- ++(1,0) cos ++(.5,-1) sin ++(.5,-1) -- ++(-1,0) cos ++(-.5,1) sin ++(-.5,1) -- cycle;
    \end{scope}
  }
\end{tikzpicture}
\end{document}

답변2

Paul로부터 영감(및 코드)을 받아 여기 에 다른 방법을 보여주기 위해 비좁은 나선형 in과 각도를 사용했습니다.out

\documentclass[tikz,border=5]{standalone}
\begin{document}
\begin{tikzpicture}[x=3cm,y=0.8cm]
  \colorlet{color 2}{lime!50!gray}
  \colorlet{color 1}{white}
  \foreach \dx in {0,6,12}{
    \begin{scope}[xshift=\dx cm]
      \draw[draw=gray,top color=color 2,bottom color=color 1]
      (0,0) -- ++(1,0) to[out=0,in=180] ++(1,3) -- ++(-1,0) to[out=180,in=0] ++(-1,-3) -- cycle;
    \end{scope}
  }
  \foreach \dx in {0,6,12}{
    \begin{scope}[xshift=3cm + \dx cm]
      \draw[draw=gray,top color=color 1,bottom color=color 2]
      (0,3) -- ++(1,0) to[out=0,in=180] ++(1,-3) -- ++(-1,0) to[out=180,in=0] ++(-1,3) -- cycle;
    \end{scope}
  }
\end{tikzpicture}
\end{document}

여기에 이미지 설명을 입력하세요

답변3

다음은 Paul Gaborit의 코드를 foreach더 짧게 만들기 위해 트리플로 다시 작성한 것입니다.)

\begin{tikzpicture}
  \colorlet{color 1}{lime!50!gray}
  \colorlet{color -1}{white}
  \foreach \s [evaluate=\s as \w using int(-\s)] in {1,-1} {
    \foreach \t in {0,1,2} {
      \draw[draw=gray,top color=color \s,bottom color=color \w, xshift=2*\t cm, xscale=\s]
      (-1.5,-1) \foreach \i in {1,-1} {cos ++(\i/2,\i) sin ++(\i/2,\i) -- ++(\i,0)};
    }
  }
\end{tikzpicture}

메모:나는 (-1.5,-1) cos ++(.5,1) sin ++(.5,1) -- ++(1,0)cos ++(-.5,-1) sin ++(-.5,-1) -- cycle번째 \foreach.

관련 정보