機械式車軸の設計

機械式車軸の設計

私が行ったようにすべての頂点を設定する必要がないように、長さと幅を使用してこの描画を行うより実用的な方法はありますか?

\documentclass[landscape]{article}
\usepackage{tikz}
%%%<
\usepackage{verbatim}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{10pt}%
%%%>
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\coordinate (A1) at (0,0);
\coordinate (A2) at (35,0);
\coordinate (A3) at (35,17);
\coordinate (A4) at (0,17);

\draw[thick] (A1) -- (A2);
\draw[thick] (A1) -- (A4);
\draw[thick] (A3) -- (A4);

\coordinate (A5) at (35,-2);
\coordinate (A6) at (70,-2);
\coordinate (A7) at (70,19);
\coordinate (A8) at (35,19);

\draw[thick] (A5) -- (A6);
\draw[thick] (A6) -- (A7);
\draw[thick] (A7) -- (A8);
\draw[thick] (A8) -- (A5);

\coordinate (A9) at (70,0);
\coordinate (A10) at (125,0);
\coordinate (A11) at (125,17);
\coordinate (A12) at (70,17);

\draw[thick] (A9) -- (A10);
\draw[thick] (A10) -- (A11);
\draw[thick] (A11) -- (A12);

\end{tikzpicture}
\end{document}

ここに画像の説明を入力してください

答え1

coordinateとをもっと有効活用できますcalc。ここでは車軸を描くための絶対座標がありません。

\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[x=1mm,y=1mm,>=latex]
  \coordinate (ALL); %% Lower left of 1st axle
  \coordinate (BLL) at ($(ALL) + (35,-2)$); %% Lower left of 2nd axle
  \coordinate (CLL) at ($(ALL) + (70,0)$); %% Lower left of 3rd axle
  \draw[thick] (ALL) rectangle +(35,17) coordinate (AUR); %% Upper right corner of 1st axle
  \draw[thick] (BLL) rectangle +(35,21) coordinate (BUR); %% Upper right corner of 2nd axle
  \draw[thick] (CLL) rectangle +(55,17) coordinate (CUR); %% Upper right corner of 2nd axle
\end{tikzpicture}
\end{document}

同じ座標を使用して測定値を描画できます。少し複雑になりますが、 を使用して水平方向の座標と垂直方向の(Coor1 -| Coor2)座標を取得すれば実行可能です。Coor1Coor2

\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[x=1mm,y=1mm,>=latex]
  \coordinate (ALL); %% Lower left of 1st axle
  \coordinate (BLL) at ($(ALL) + (35,-2)$); %% Lower left of 2nd axle
  \coordinate (CLL) at ($(ALL) + (70,0)$); %% Lower left of 3rd axle
  \draw[thick] (ALL) rectangle +(35,17) coordinate (AUR); %% Upper right corner of 1st axle
  \draw[thick] (BLL) rectangle +(35,21) coordinate (BUR); %% Upper right corner of 2nd axle
  \draw[thick] (CLL) rectangle +(55,17) coordinate (CUR); %% Upper right corner of 2nd axle
  %% Measures
  \coordinate (Mx1) at ($(BLL) + (-35-15,0)$);
  \coordinate (Mx2) at ($(BLL) + (-35-10,0)$);
  \coordinate (Mx3) at ($(BLL) + (35+55+10,0)$);
  \coordinate (My1) at ($(BLL) + (0,-10)$);
  %% 21
  \draw ($(BLL)+(-1,0)$) -- ($(Mx1)+(-1,0)$);
  \draw ($(BLL)+(-1,21)$) -- ($(Mx1)+(-1,21)$);
  \draw[<->] (Mx1) -- ($(Mx1)+(0,21)$) node[pos=0.5,anchor=south,rotate=90]{21};
  %% 2
  \draw ($(ALL)+(-1,0)$) -- ($(Mx2 |- ALL) + (-1,0)$);
  \draw[<-] (Mx2 |- BLL) -- +(0,-5) node[pos=0.5,anchor=south,rotate=90]{2};
  \draw[<-] (Mx2 |- ALL) -- +(0,5);
  %% 35 35 55
  \draw ($(ALL)+(0,-1)$) -- ($(My1 -| ALL)+(0,-1)$);
  \draw ($(BLL)+(0,-1)$) -- ($(My1 -| BLL)+(0,-1)$);
  \draw ($(BUR |- BLL)+(0,-1)$) -- ($(My1 -| BUR)+(0,-1)$);
  \draw ($(CUR |- CLL)+(0,-1)$) -- ($(My1 -| CUR)+(0,-1)$);
  \draw[<->] (My1 -| ALL) -- (My1 -| BLL) node[anchor=south,pos=0.5]{35};
  \draw[<->] (My1 -| BLL) -- (My1 -| CLL) node[anchor=south,pos=0.5]{35};
  \draw[<->] (My1 -| CLL) -- (My1 -| CUR) node[anchor=south,pos=0.5]{55};
  %% 17
  \draw ($(CUR) + (1,0)$) -- ($(CUR -| Mx3)+(1,0)$);
  \draw ($(CUR |- CLL) + (1,0)$) -- ($(CLL -| Mx3)+(1,0)$);
  \draw[<->] (Mx3 |- CLL) -- (Mx3 |- CUR) node [pos=0.5,anchor=south,rotate=90]{17};
\end{tikzpicture}
\end{document}

ここに画像の説明を入力してください

関連情報