Tikz 绘制三维桁架

Tikz 绘制三维桁架

在此处输入图片描述

下面的空间桁架怎么画?先谢谢了。

答案1

欢迎来到 TeX.SE!!

我会这么做:

  1. 首先定义所有坐标。calc库在这里会非常有用。
  2. 然后画两遍线:先画粗白线,然后再画细蓝线。这样我希望提高可见度。有些白线不是必需的,但把它们都画出来比找出我们需要哪条和不需要哪条要容易得多。在这种情况下,我更喜欢这种方法而不是库decorations

剩下的几句\foreach话是为了避免重复代码(我想我可以添加更多但是......),并且实际上将点连接起来。

注意事项:我不完全确定可见性,我可能错过了一两行,但我希望你明白了。

代码:

\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{calc,perspective}

\tikzset
{
   blue line/.style={blue},
  white line/.style={ultra thick,white},
    blue dot/.style={circle,fill=blue,inner sep=0,minimum size=1mm}
}

\begin{document}
\begin{tikzpicture}[line join=round,isometric view,rotate around z=-35]
  % coordinates
  \coordinate (V) at (0,0,12);
  \foreach[count=\j]\i in {N,W,S,E}
  {
    \coordinate (\i0) at (90*\j:0.75);
    \coordinate (\i6) at ($(0,0,7)+(90*\j:0.5)$);
    \foreach\y in {1,...,5}
      \coordinate (\i\y) at ($(\i0)!\y/6!(\i6)$);
    \foreach[count=\yy, evaluate=\yy as \yyy using int(\yy+6)]\y in {0.7,2.2,2.9}
      \coordinate (\i\yyy) at ($(\i6)+(0,0,\y)$);
    \foreach[count=\yy, evaluate=\yy as \yyy using int(\yy+9)]\y in {1,2}
      \coordinate (\i\yyy) at ($(V)!\y/3!(\i9)$);
    % base
    \foreach\ii in {0,90,180,270}% 0 not necessary for this view
      \draw[shift={($(90*\j:0.75)-(0,0,0.2)$)},fill=gray!50] (0,0,0.2) -- (\ii:0.3) -- (\ii+90:0.3) -- cycle;
  }
  \coordinate (SW6) at ($(0,0,7)  +(225:2)$) {};
  \coordinate (SW8) at ($(0,0,9.2)+(225:2)$) {};
  \coordinate (NE6) at ($(0,0,7)  + (45:2)$) {};
  % right arm (north east)
  \draw[white line] (N6) -- (NE6) -- (E6);
  \draw[white line] (N7) -- (NE6) -- (E7);
  \draw[blue  line] (N6) -- (NE6) -- (E6);
  \draw[blue  line] (N7) -- (NE6) -- (E7);
  % back (north)
  \foreach\y in {6,...,11}
  {% squares
    \draw[white line] (W\y) -- (N\y) -- (E\y);
    \draw[blue  line] (W\y) -- (N\y) -- (E\y);
  }
  \foreach[evaluate=\y as \yy using int(\y+1)]\y in {0,...,8,10}
  {
    \draw[white line]   (W\y)  -- (N\yy) -- (E\y);
    \draw[white line]   (W\yy) -- (N\y)  -- (E\yy);
    \draw[blue  line]   (W\y)  -- (N\yy) -- (E\y);
    \draw[blue  line]   (W\yy) -- (N\y)  -- (E\yy);
  }
  \foreach\y in {0,...,11}
    \node[blue  dot] at (N\y) {};
  \draw[blue line] (N0) -- (N6) -- (N9) -- (V);
  % front (south)
  \foreach\y in {6,...,11}
  {% squares
    \draw[white line] (W\y) -- (S\y) -- (E\y);
    \draw[blue  line] (W\y) -- (S\y) -- (E\y);
  }
  \foreach[evaluate=\y as \yy using int(\y+1)]\y in {0,...,8,10}
  {
    \draw[white line] (W\y)  -- (S\yy) -- (E\y);
    \draw[white line] (W\yy) -- (S\y)  -- (E\yy);
    \draw[blue  line] (W\y)  -- (S\yy) -- (E\y);
    \draw[blue  line] (W\yy) -- (S\y)  -- (E\yy);
  }
  \foreach\i in {W,S,E}
    \draw[blue line] (\i0) -- (\i6) -- (\i9) -- (V);
  % left arms (south west)
  \foreach[evaluate=\y as \yy using int(\y+1)]\y in {6,8}
  {
    \draw[white line] (S\y)  -- (SW\y) -- (W\y);
    \draw[white line] (S\yy) -- (SW\y) -- (W\y);
    \draw[blue  line] (S\y)  -- (SW\y) -- (W\y);
    \draw[blue  line] (S\yy) -- (SW\y) -- (W\yy);
  }
  \foreach\y in {0,...,11} \foreach\i in {W,S,E}
    \node[blue  dot] at (\i\y) {};
  \foreach\i in {SW6,SW8,NE6,V}
     \node[blue  dot] at (\i) {};
\end{tikzpicture}
\end{document}

还有图片(危险!!请勿触摸):

在此处输入图片描述

相关内容