[Tex/LaTex] Triangle as constraints in structural engineering

tikz-pgf

I guess this must be quite simple, but all I've tried didn't work so far.
All I want is to get some triangles on the edge of a framework.

Something like this:

enter image description here

My code looks like this:

\documentclass[tikz]{standalone}
\usetikzlibrary{calc,decorations.markings}
\usepackage{tikz}
\begin{document}

\begin{tikzpicture}[scale=1,inner sep=0pt,thick,dot/.style={draw,circle,minimum size=4pt},
put coord sys/.style={
decoration={markings,
mark= at position 0.5
with
{
\draw[-latex,ultra thin,blue!80!black] (2pt,2pt) -- ++(5mm,0) node[above right,rotate=\pgfdecoratedangle] {$\scriptstyle x$};
\draw[-latex,ultra thin,green!80!black] (2pt,2pt) -- ++(0,5mm) node[above right,rotate=\pgfdecoratedangle] {$\scriptstyle y$};
}
},
postaction=decorate}]

%\draw [help lines] (0,0) grid (3,4);
\node[dot] (2) at (0,0) [label={[label distance=1mm]270:2}] {};
\node[dot] (3) at (0,2) [label={[label distance=1mm]180:3}] {};
\node[dot] (1) at (0,4) [label={[label distance=1mm]90:1}] {};
\node[dot] (4) at (3,2) [label={[label distance=1mm]0:4}] {};
\node[dot] (5) at (2.5,4) [label={[label distance=1mm]45:5}] {};

%\draw[gray] ++(150:0.3) -- (0,0); 
%\draw[gray] ++(-150:0.3) -- (0,0); 
%\draw[gray] ++(180:0.3) -- (-.3,0); 

%\draw[gray] ++(0,4) -- (150:1); 
%\draw[gray] ++(-150:0.3) -- (0,4); 
%\draw[gray] ++(180:0.3) -- (-.3,4); 

%\draw  (2) -- (3) node [midway,sloped,above] {3};
%\draw  (3) -- (4) node [midway,above,sloped] {4};      
%\draw  (2) -- (4) node [midway,above,sloped] {6};      
%\draw  (3) -- (1) node [midway,above,sloped] {2};  
%\draw  (1) -- (5) node [midway,above,sloped] {1};  
%\draw  (3) -- (5) node [midway,above,sloped] {5};  
%\draw  (4) -- (5) node [midway,above,sloped] {7};      

\draw[put coord sys]   (2) -- (3);
\draw[put coord sys]   (3) -- (4);      
\draw[put coord sys]   (2) -- (4);  
\draw[put coord sys]   (1) -- (3);
\draw[put coord sys]   (1) -- (5);
\draw[put coord sys]   (4) -- (5);
\draw[put coord sys]   (3) -- (5);

\end{tikzpicture}

\end{document}

The "trick" with the \draw[gray] ++(150:0.3) -- (0,0); command doesn't work very well. In fact it doesn't work at all in this way 🙂
Does anyone have any ideas how to get these triangles?

Best Answer

The solution with the library tikz-mec (documentation only in Italian, but the examples and the shape details make it quite easy to be used):

\documentclass[tikz,png,border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{backgrounds,calc,decorations.markings,mec}
\begin{document}

\begin{tikzpicture}[scale=1,thick,dot/.style={draw,circle,minimum size=4pt,inner sep=0pt,},
put coord sys/.style={
decoration={markings,
mark= at position 0.5
with
{
\draw[-latex,ultra thin,blue!80!black] (2pt,2pt) -- ++(5mm,0) node[above right,rotate=\pgfdecoratedangle] {$\scriptstyle x$};
\draw[-latex,ultra thin,green!80!black] (2pt,2pt) -- ++(0,5mm) node[above right,rotate=\pgfdecoratedangle] {$\scriptstyle y$};
}
},
postaction=decorate}]


\draw [help lines] (0,0) grid (3,4);
\node[dot] (2) at (0,0) [label={[label distance=1mm]270:2}] {};
\node[dot] (3) at (0,2) [label={[label distance=1mm]180:3}] {};
\node[dot] (1) at (0,4) [label={[label distance=1mm]90:1}] {};
\node[dot] (4) at (3,2) [label={[label distance=1mm]0:4}] {};
\node[dot] (5) at (2.5,4) [label={[label distance=1mm]45:5}] {};

\node[draw,hinge,grounded=270,scale=0.85,transform shape] (hinge-1) at (0,4){};
\node[draw,hinge,grounded=270,scale=0.85,transform shape] (hinge-2) at (0,0){};

% with a loop is easier
\foreach \source/\dest in {2/3,3/4,2/4,1/3,1/5,4/5,3/5}
\draw[put coord sys]   (\source) -- (\dest);

% background addition
\begin{scope}[on background layer]
\fill[green!70!lime!15  ] 
 ($(hinge-1.south west)+(-0.5,1)$)--
 ($(hinge-1.south west)+(4.5,1)$)coordinate (x)--
 ($(x)+(0,-3)$)coordinate (y)--
 ($(y-|hinge-1.south east)-(0.5,0)$)--
 cycle;
\draw[green!70!lime!50]($(hinge-1.south west)+(-0.5,1)$)--
 ($(hinge-1.south west)+(4.5,1)$)coordinate (x)--
 ($(x)+(0,-3)$)coordinate (y)
 ($(hinge-1.south west)+(-0.5,1)$)--($(hinge-1.south west)-(0.5,2)$);
\end{scope}

\end{tikzpicture}

\end{document}

The result:

enter image description here

A foreach loop has been implemented to avoid writing some paths and it has been introduced a background to resemble the picture posted.

Related Question