generated at
Tikzは座標計算もできるぞ

(Gorira Tatsuさんの2023夏休みの自由研究が)自分の前期の実験レポートと同じ指定だtakker
自分もTeXで書いたが、理由は数式をwordで書くのがつらすぎたから
図は最初PGFPlotsで書こうとしたが、挫折してExcelに切り替えた
以降もExcelで済ませようと思ったが、学科唯一の数学系教授にTikzを極めるよう言われて火がついてしまい、データプロット以外はTikzで書ききってしまった
Tikzはいいぞ(洗脳完了)。issacさんもやろう
なんかすごいことはわかるGorira Tatsu
Tikzは数学的な図を書くのが楽しいSummer498
役立つとは言っていない
長期的に価値のあるもの(強弁)だから今すぐ役に立たなくてもいいtakker
というかコンパイルしてるんだから座標位置の計算してほしいんだよな~
できるぞtakker
三角関数使えたっけ
Rotateでなんとかするんかな
使えるtakker
コレは普通に役立つなテノヒラクルーSummer498
矩形則.tex
\tikzset{declare function={y(\x)=sqrt(5.5-cos((4/200+0.5)*\x r)-sin((4/200+0.5)*2*\x r));}, plot fill/.style={fill=white}, plot/.style={draw=black!80, thick}, bar/.style={fill=cyan!20,draw=black, thick}, marking/.style={draw=black}, axis/.style={thick, draw=black!65, stealth-stealth} } \begin{figure}[H] \centering \begin{tikzpicture}[x=0.7cm,y=1.5cm, line cap=round, line join=round] % \path [plot fill] plot [domain=0:5*pi] (\x,{y(\x)}) -| cycle; % 矩形を描く \foreach \x in {0, 1,2,5*pi-2,5*pi-1} { \path [bar] (\x,0) |- (\x+1, {y(\x)}) |- cycle; } % graphを描く \path [plot] plot [domain=-0.5*pi:(5+0.5)*pi,smooth] (\x,{y(\x)}) node[above]{$y=f(x)$}; % 辺の長さを示す矢印をつける \path [axis] (-0.3,0) -- node[left]{$f(\alpha)$} (-0.3,{y(0)}); \path [axis] (0,{y(0)+0.3/3}) -- node[above]{$\Delta x$} (1,{y(0)+0.3/3}); \path [axis] (5*pi+0.3,0) -- node[right]{$f(\beta-\Delta x)$} (5*pi+0.3,{y(5*pi-1)}); \path [axis] (0,-2/3) -- node[below]{$N$個} (5*pi,-2/3); % 座標軸を描く \path [axis] (0,3.5) node[left]{$y$} |- (5*pi+0.8,0) node[below]{$x$}; % x軸の目盛り線を引く \path [axis, -] (0,0) -- ++(0,-3pt) node [below] {$\alpha$}; \path [axis, -] (1,0) -- ++(0,-3pt) node [below=0.2] {$\alpha+\Delta x$}; \path [axis, -] (2,0) -- ++(0,-3pt) node [below] {$\alpha+2\Delta x$}; \path [axis, -] (5*pi-2,0) -- ++(0,-3pt) node [below] {$\beta-2\Delta x$}; \path [axis, -] (5*pi-1,0) -- ++(0,-3pt) node [below=0.2] {$\beta-\Delta x$}; \path [axis, -] (5*pi,0) -- ++(0,-3pt) node [below] {$\beta$}; % y軸の目盛り線を引く \path [axis, -] (0,0) -- ++(0,-3pt); \foreach \y in {0,3} { \path [axis, -] (0,\y) -- ++(-3pt, 0) node [left=0.1] {$\y$}; } % 途中の矩形を省略したことを表すdotsを入れる \node(A)[scale=2.0] at (2.5*pi,1) {$\ldots$}; \end{tikzpicture} \caption{矩形測による近似}\label{fig:rect_method} \end{figure}
globalなスタイル設定.tex
\tikzset{ indicator/.style={thick, draw=black!65, stealth-stealth}, % 寸法 subline/.style={thick, draw=black!65, dashed}, % 補助線 strain guage/.style={gray}, % ひずみゲージ legend/.style={}, % 説明用のラベルとか beam/.style={thick} % 梁 }
上にある部分のコード.tex
\subsection{実験した断面形状}\label{sec:cross-sections} 本実験では、\cref{fig:rect-projection,fig:i-projection,fig:h-projection}に示す矩形断面、I形断面、H形断面の等断面梁と、\cref{fig:rhombus-projection}に示す幅が変化する矩形断面の梁の4本について載荷実験を実施した。 以下、各梁を順に矩形梁、I形梁、H形梁、ひし形梁と呼ぶことにする。 \begin{figure}[htbp] \begin{minipage}{0.3\hsize} \begin{tikzpicture}[scale=0.4] \def\width{8.1} \def\thickness{0.5} % 梁の厚み \def\margin{1.0} % 寸法を離す距離 \def\barheight{1.4*\margin} % 寸法の両脇の点線の長さ \coordinate (O) at (0,0); % 側面図 \draw [beam] (O) rectangle ++(\width, \thickness); % 寸法 \draw [indicator, stealth-] ($(O) + (-\margin,0)$) -- ++(0, -1); \draw [indicator, stealth-] ($(O) + (-\margin,\thickness)$) -- ++(0, 1); \draw [subline] (O) -- ++(-\barheight, 0); \draw [subline] ($(O) + (0,\thickness)$) -- ++(-\barheight, 0); \path ($(O) + (-\margin,0)$) --node [legend, left, rotate=90, anchor=south]{$\SI{5}{mm}$} ++(0,\thickness); \draw [indicator] ($(O) + (0, \thickness + 1)$) --node [legend, above]{$\SI{81}{mm}$} ++(\width, 0); \draw [subline] (O) -- ++(0, \barheight); \draw [subline] ($(O) + (\width, 0)$) -- ++(0, \barheight); \end{tikzpicture} \centering \caption{矩形断面}\label{fig:rect-projection} \end{minipage} \begin{minipage}{0.3\hsize} \begin{tikzpicture}[scale=0.4] \def\l{2.7} \def\thickness{0.5} % 梁の厚み \def\margin{1.0} % 寸法を離す距離 \def\barheight{1.2*\margin} % 寸法の両脇の点線の長さ \coordinate (O) at (0,-\l/2-\thickness/2); \coordinate (P) at ($(O) + (\l, 0)$); \coordinate (Q) at ($(P) + (0, \thickness)$); \coordinate (R) at ($(Q) + (-\l/2 + \thickness/2, 0)$); \coordinate (S) at ($(R) + (0, \l)$); \coordinate (T) at ($(Q) + (0, \l)$); \coordinate (U) at ($(T) + (0, \thickness)$); \coordinate (V) at ($(U) + (-\l, 0)$); \coordinate (W) at ($(T) + (-\l, 0)$); \coordinate (X) at ($(S) + (-\thickness, 0)$); \coordinate (Y) at ($(R) + (-\thickness, 0)$); \coordinate (Z) at ($(Q) + (-\l, 0)$); % 側面図 \draw [beam] (O) -- (P) -- (Q) -- (R) -- (S) -- (T) -- (U) -- (V) -- (W) -- (X) -- (Y) -- (Z) -- cycle; % 寸法 % 上部材の厚み \def\arrowL{0.5} \draw [indicator, stealth-] ($(T) + (\margin, 0)$) -- ++(0, -\arrowL); \draw [indicator, stealth-] ($(U) + (\margin, 0)$) -- ++(0, \arrowL); \draw [subline] (T) -- ++(\barheight, 0); \draw [subline] (U) -- ++(\barheight, 0); \path ($(T) + (\margin, 0)$) --node [legend, right, rotate=-90, anchor=south]{$\SI{5}{mm}$} ++(0,\thickness); % 下部材の厚み \draw [indicator, stealth-] ($(P) + (\margin, 0)$) -- ++(0, -\arrowL); \draw [indicator, stealth-] ($(Q) + (\margin, 0)$) -- ++(0, \arrowL); \draw [subline] (P) -- ++(\barheight, 0); \draw [subline] (Q) -- ++(\barheight, 0); \path ($(P) + (\margin, 0)$) --node [legend, right, rotate=-90, anchor=south]{$\SI{5}{mm}$} ++(0,\thickness); % flangeの幅 \coordinate (M) at ($(Y) + (0, \l/2)$); \draw [indicator, stealth-] (M) -- ++(-\arrowL, 0); \draw [indicator, stealth-] ($(M) + (\thickness, 0)$) -- ++(\arrowL, 0) node [legend, right] {$\SI{5}{mm}$}; % webの幅 \draw [indicator] ($(V) + (0, \margin)$) --node [legend, above]{$\SI{27}{mm}$} ++(\l, 0); \draw [subline] (U) -- ++(0, \barheight); \draw [subline] (V) -- ++(0, \barheight); % flangeの高さ \draw [indicator] ($(W) + (-\margin, 0)$) --node [legend, left, rotate=90, anchor=south]{$\SI{27}{mm}$} ++(0, -\l); \draw [subline] (W) -- ++(-\barheight, 0); \draw [subline] (Z) -- ++(-\barheight, 0); \end{tikzpicture} \centering \caption{I形断面}\label{fig:i-projection} \end{minipage} \begin{minipage}{0.3\hsize} \rotatebox{90}{ \begin{tikzpicture}[scale=0.4] \def\l{2.7} \def\thickness{0.5} % 梁の厚み \def\margin{1.0} % 寸法を離す距離 \def\barheight{1.2*\margin} % 寸法の両脇の点線の長さ \coordinate (O) at (0,-\l/2-\thickness/2); \coordinate (P) at ($(O) + (\l, 0)$); \coordinate (Q) at ($(P) + (0, \thickness)$); \coordinate (R) at ($(Q) + (-\l/2 + \thickness/2, 0)$); \coordinate (S) at ($(R) + (0, \l)$); \coordinate (T) at ($(Q) + (0, \l)$); \coordinate (U) at ($(T) + (0, \thickness)$); \coordinate (V) at ($(U) + (-\l, 0)$); \coordinate (W) at ($(T) + (-\l, 0)$); \coordinate (X) at ($(S) + (-\thickness, 0)$); \coordinate (Y) at ($(R) + (-\thickness, 0)$); \coordinate (Z) at ($(Q) + (-\l, 0)$); % 側面図 \draw [beam] (O) -- (P) -- (Q) -- (R) -- (S) -- (T) -- (U) -- (V) -- (W) -- (X) -- (Y) -- (Z) -- cycle; % 寸法 % 上部材の厚み \def\arrowL{0.5} \draw [indicator, stealth-] ($(T) + (\margin, 0)$) -- ++(0, -\arrowL); \draw [indicator, stealth-] ($(U) + (\margin, 0)$) -- ++(0, \arrowL); \draw [subline] (T) -- ++(\barheight, 0); \draw [subline] (U) -- ++(\barheight, 0); \path ($(T) + (\margin, 0)$) --node [legend, right, rotate=-90, anchor=south]{$\SI{5}{mm}$} ++(0,\thickness); % 下部材の厚み \draw [indicator, stealth-] ($(P) + (\margin, 0)$) -- ++(0, -\arrowL); \draw [indicator, stealth-] ($(Q) + (\margin, 0)$) -- ++(0, \arrowL); \draw [subline] (P) -- ++(\barheight, 0); \draw [subline] (Q) -- ++(\barheight, 0); \path ($(P) + (\margin, 0)$) --node [legend, right, rotate=-90, anchor=south]{$\SI{5}{mm}$} ++(0,\thickness); % flangeの幅 \coordinate (M) at ($(Y) + (0, \l/2)$); \draw [indicator, stealth-] (M) -- ++(-\arrowL, 0); \draw [indicator, stealth-] ($(M) + (\thickness, 0)$) -- ++(\arrowL, 0) node [legend, left, rotate=-90, anchor=south] {$\SI{5}{mm}$}; % webの幅 \draw [indicator] ($(V) + (0, \margin)$) --node [legend, above]{$\SI{27}{mm}$} ++(\l, 0); \draw [subline] (U) -- ++(0, \barheight); \draw [subline] (V) -- ++(0, \barheight); % flangeの高さ \draw [indicator] ($(W) + (-\margin, 0)$) --node [legend, left, rotate=-90, anchor=north]{$\SI{27}{mm}$} ++(0, -\l); \draw [subline] (W) -- ++(-\barheight, 0); \draw [subline] (Z) -- ++(-\barheight, 0); \end{tikzpicture} } \centering \caption{H形断面}\label{fig:h-projection} \end{minipage} \end{figure} \begin{figure}[htbp] \begin{tikzpicture}[scale=0.3] \def\span{34} % スパン長 \def\width{8.1} \def\widtha{6} % 短い所の長さ \def\widthb{10.2} % 長い所の長さ \def\thickness{0.5} % 梁の厚み \def\margin{1.0} % 寸法を離す距離 \def\barheight{1.2*\margin} % 寸法の両脇の点線の長さ \coordinate (O) at (0,0); \coordinate (F) at ($(O) + (3, 1)$); % 正面図の原点 \coordinate (P) at ($(F) + (0, \thickness + 3)$); % 平面図の原点 \coordinate (S) at ($(F) + (\span + 3, 0)$); % 側面図の原点 % 平面図 % なぜか括弧でくくるとエラーになる \coordinate (P0) at ($(P) + (0, \width/2 - \widtha/2)$); \coordinate (P1L) at ($(P0) + (\span/2, -\widthb/2 + \widtha/2)$); \coordinate (P2) at ($(P1L) + (\span/2, \widthb/2 - \widtha/2)$); \coordinate (P1U) at ($(P1L) + (0, \widthb)$); \draw [beam] (P0) -- (P1L) -- (P2) -- ++(0, \widtha) -- (P1U) -- ($(P0) + (0, \widtha)$) -- cycle; % 寸法 \draw [indicator] ($(P0) + (-\margin, 0)$) --node [legend, left, rotate=90, anchor=south]{$\SI{60}{mm}$} ++(0, \widtha); \draw [subline] (P0) -- ++(-\barheight, 0); \draw [subline] ($(P0) + (0, \widtha)$) -- ++(-\barheight, 0); \draw [indicator] (P1L) --node [legend, left, rotate=90, anchor=south]{$\SI{102}{mm}$} (P1U); % 補助線 \draw [subline] ($(F) + (0, \thickness)$) -- (P0); \draw [subline] ($(F) + (\span/2, \thickness)$) -- (P1L); \draw [subline] ($(F) + (\span, \thickness)$) -- (P2); % 正面図 \draw [beam] (F) rectangle ++(\span, \thickness); \draw [beam] ($(F) + (\span/2, 0)$) -- ++(0, \thickness); % 寸法 \draw [indicator, stealth-] ($(F) + (-\margin, 0)$) -- ++(0, -1); \draw [indicator, stealth-] ($(F) + (-\margin, \thickness)$) -- ++(0, 1); \draw [subline] (F) -- ++(-\barheight, 0); \draw [subline] ($(F) + (0,\thickness)$) -- ++(-\barheight, 0); \path ($(F) + (-\margin,0)$) --node [legend, left, rotate=90, anchor=south]{$\SI{5}{mm}$} ++(0,\thickness); \draw [indicator] ($(F) + (0, -\margin)$) --node [legend, below]{$\SI{170}{mm}$} ++(\span/2, 0); \draw [subline] (F) -- ++(0, -\barheight); \draw [subline] ($(F) + (\span/2, 0)$) -- ++(0, -\barheight); \draw [indicator] ($(F) + (\span/2, -\margin)$) --node [legend, below]{$\SI{170}{mm}$} ++(\span/2, 0); \draw [subline] ($(F) + (\span, 0)$) -- ++(0, -\barheight); % 補助線 \draw [subline] ($(F) + (\span, 0)$) -- (S); \draw [subline] ($(F) + (\span, \thickness)$) -- ($(S) + (0, \thickness)$); % 側面図 \draw [beam] (S) rectangle ++(\widthb, \thickness); \draw [beam] ($(S) + (\widthb/2 - \widtha/2, 0)$) -- ++(0, \thickness); \draw [beam] ($(S) + (\widthb/2 + \widtha/2, 0)$) -- ++(0, \thickness); % 寸法 \draw [indicator] ($(S) + (0, -\margin)$) --node [legend, below]{$\SI{102}{mm}$} ++(\widthb, 0); \draw [subline] (S) -- ++(0, -\barheight); \draw [subline] ($(S) + (\widthb, 0)$) -- ++(0, -\barheight); \draw [indicator] ($(S) + (\widthb/2 -\widtha/2, \thickness + \barheight)$) --node [legend, above]{$\SI{60}{mm}$} ++(\widtha, 0); \draw [subline] ($(S) + (\widthb/2 -\widtha/2, \thickness + \barheight)$) -- ++(0, -\barheight); \draw [subline] ($(S) + (\widthb/2 + \widtha/2, \thickness + \barheight)$) -- ++(0, -1); \end{tikzpicture} \centering \caption{ひし形梁の三面図}\label{fig:rhombus-projection} \end{figure} \subsection{手順} 使用した材料と器具はひずみゲージを除いて\cref{sec:使用したもの}と同じものを使った。実験方法もひずみを測定しなかったこと以外\cref{sec:載荷実験}と同じなので割愛する。