その他一覧へ戻る

バネ

鉄TeX機能紹介/TikZサンプル/バネ.tex鉄TeX機能紹介 / TikZhybrid

レンダリング結果

1ページ / 同名PDFあり
バネ preview
PDFを開く
TeXソース
TeXソース
入力コード
\documentclass[b4j,10pt,twoside,landscape]{tetsujsarticle}
\usepackage{tetsuryoku}
\begin{document}

\def\屋根の厚み{0.2}
\def\屋根の高さ{7}
\def\t座標の縮尺{0.04}
\def\振幅{4}

\begin{center}
\begin{tikzpicture}
%% 屋根
\coordinate (屋根の左下) at (-0.5,\屋根の高さ);
\coordinate (屋根の右上) at ($(屋根の左下) + (360*\t座標の縮尺+1.5,\屋根の厚み)$);
\fill [pattern = north east lines] (屋根の左下) rectangle (屋根の右上);
\draw[thick] (屋根の左下) -- (屋根の右上 |- 屋根の左下);
%% サインカーブ
\draw[domain=0:360*\t座標の縮尺,samples=200,line width=2pt,color=blue] plot (\x,{\振幅*sin(\x/\t座標の縮尺)});
%% 円
\coordinate (円の中心) at (360*\t座標の縮尺 + 5 + \振幅,0);
\draw[line width=2pt,color=blue] (円の中心) circle[radius=\振幅];
%%% \omega t の説明
\draw[line width=1pt,color=red]
  (円の中心) -- +(0:\振幅)
  (円の中心) -- +(60:\振幅);
\draw[-stealth,line width=2pt,color=red] ($(円の中心) + (0:0.3*\振幅)$) arc[start angle=0, end angle=60, radius=0.3*\振幅] node[midway,shift={(30:0.4)}] {$\omega t$};
%% 各瞬間について
\foreach \t in {0,30,...,360}{
  % おもり
  \node[circle,shade,outer color=black!90!white,inner color=white,inner sep=2.5mm] (a) at (\t*\t座標の縮尺,{\振幅*sin(\t)}) {};
  % バネ
  \FPeval\a{2-sin(\t*3.14/180)}
  \coordinate (b) at (a |- 屋根の左下);
  \draw[decoration={aspect=0.4, segment length=\a mm, amplitude=2mm,coil},decorate]  ($(b) + (0,-2mm)$) -- ($(a.north) + (0,1mm)$);%% バネ
  \draw ($(b) + (0,-2mm)$) -- (b) %% 屋根とバネを接続する直線部
  ($(a.north) + (0,1mm)$) -- (a)  %% おもりとバネを接続する直線部
  ;
  %% 円上のおもり
  \node[circle,shade,outer color=black!90!white,inner color=white,inner sep=2.5mm] (c) at ($(円の中心) + ({\振幅*cos(\t)},{\振幅*sin(\t)})$) {};
  %% 点線
  \begin{scope}[on background layer]
  \draw[dotted, line width=1pt,color=black!50!white] (a) -- (c);
  \end{scope}
}
\end{tikzpicture}
\end{center}

\end{document}