
%&tex
\documentclass{standalone}
\usepackage{tikz}
\usepackage{siltex}
\usetikzlibrary {calc,arrows.meta,positioning,patterns,math}
%\input{graphics/tics.tikz}
        
\begin{document}
    \begin{tikzpicture}[on grid, x=0.75cm, y=0.75cm]
        % Define Drawing Box dimentions
        \def \boxheight {5};
        \def \boxwidth {6};
        \def \boxorigin {(-\boxwidth/2,-1)};
        \def \boxsize {(\boxwidth,\boxheight)};
        \def \armcolor {gray};
        \def \jointred {\draw[fill=orange] (0,0) circle(0.4);}
        \def \jointblue {\draw[fill=blue] (0,0) circle(0.4);}

        
        \def \width {0.3};
        \def \length {5};
        \def \holediameter {0.10};
        \def \floorheight {0.5};
        \pgfmathsetmacro{\floorwidth}{4};
        \def \arm {
            \draw[fill=\armcolor] (0,0)  ++(0,\width/2) arc[start angle=90, end angle=270, radius=\width/2] -- ++(\length,0) arc[start angle=-90, end angle=90, radius=\width/2] -- cycle;
            \draw[fill=white] (0,0) circle (\holediameter/2);
            \draw[fill=white] (\length,0) circle (\holediameter/2);
        }
        \def \doublescara {
            \pgfmathsetmacro{\C}{sqrt(pow(\A,2)+pow(\B,2)-2*\A*\B*cos(\c))};
            \pgfmathsetmacro{\b}{acos((pow(\A,2) + pow(\C,2) - pow(\B,2))/(2*\A*\C))};
            \pgfmathsetmacro{\d}{180-\h-\b};
            \pgfmathsetmacro{\D}{sqrt(pow(\C,2)+pow(\B,2)-2*\B*\C*cos(\d))};
            \pgfmathsetmacro{\g}{acos(\D/(2*\B))};
            \pgfmathsetmacro{\f}{acos((pow(\D,2) + pow(\B,2) - pow(\C,2))/(2*\D*\B))};
            \pgfmathsetmacro{\a}{180-\b-\c};
            \pgfmathsetmacro{\e}{180-\d-\f};
            \pgfmathsetmacro{\k}{180-\f-\g};
            \pgfmathsetmacro{\m}{180-\g-\e-\a};
            \begin{scope}[shift={(-\A/2,0)}, rotate=\c]
                \jointred
                \def \length{\B}
                \arm
                \begin{scope}[shift={(\B,0)}, rotate=-\m]
                    \def \length{\B}
                    \arm
                \end{scope}
            \end{scope}
            \begin{scope}[shift={(\A/2,0)}, rotate=\h]
                \jointblue
                \def \length{\B}
                \arm
                \begin{scope}[shift={(\B,0)}, rotate=\k]
                    \def \length{\B}
                    \arm
                \end{scope}
            \end{scope}
        };



        \tikzset{arm/.pic={
            \def \length {#1}
            \draw[fill=gray] (0,0)  ++(0,\width/2) arc[start angle=90, end angle=270, radius=\width/2] -- ++(\length,0) arc[start angle=-90, end angle=90, radius=\width/2] -- cycle;
            \draw[fill=white] (0,0) circle (\holediameter/2);
            \draw[fill=white] (\length,0) circle (\holediameter/2);
        },
        floor/.pic={
            \def \width {#1/2};
            \draw (-\width,0) -- (\width,0);
            \fill[pattern=north west lines] (-\width,-\floorheight) rectangle (\width,0);
        },
        box/.pic={
            \draw \boxorigin rectangle ++\boxsize;
        }
        };

        \pgfmathsetmacro{\B}{2.3};
        \pgfmathsetmacro{\A}{1};
        \def \nodepos {(2.4,3.4)};
        %rechts boven
        \begin{scope}[shift={(1*\boxwidth,1*\boxheight)}]
            \node at \nodepos {2.};
            \draw (0,0) pic {box};
            \draw (0,0) pic {floor=2};
            %\pgfmathsetmacro{\c}{90};
            %\pgfmathsetmacro{\h}{40};
            %\def \armcolor{lightgray};
            %\doublescara;
            \pgfmathsetmacro{\c}{130};
            \pgfmathsetmacro{\h}{60};
            \def \armcolor{gray};
            \doublescara;
        \end{scope}

        
        % Links boven
        \begin{scope}[shift={(0*\boxwidth,\boxheight)}]
            \node at \nodepos {1.};
            \draw (0,0) pic {box};
            \draw (0,0) pic {floor=2};
            \begin{scope}[shift={(0,0)}, rotate=120]
                \jointred
                \def \length{\B}
                \arm
                \begin{scope}[shift={(\B,0)}, rotate=-100]
                    \jointblue
                    \def \length{\B}
                    \arm
                \end{scope}
            \end{scope}
        \end{scope}
        
        %rechts onder
        \begin{scope}[shift={(\boxwidth,0*\boxheight)}]
            \node at \nodepos {4.};
            \draw (0,0) pic {box};
            \draw (0,0) pic {floor=2};
            \def \a {105};
            \def \b {5};
            \def \c {\b-\a};
            \def \C {1};
            \def \B {2.5};
            \def \A {3};
            \begin{scope}[shift={(0,0)}, rotate=180+\b]
                \jointblue
                \def \length{\C}
                \begin{scope}[shift={(\length,0)}, rotate=-(180+\c)]
                    \def \length{\A}
                    \arm
                    \begin{scope}[shift={(\length,0)}, rotate=\c]
                        \def \length{\B+\C}
                        \arm
                    \end{scope}
                \end{scope}
                \arm
            \end{scope}
            \begin{scope}[shift={(0,0)}, rotate=\a]
                \def \length{\A}
                \arm
            \end{scope}
            \begin{scope}[shift={(\C,0)}, rotate=\a]
                \jointred
                \def \length{\C}
                \begin{scope}[shift={(\length,0)}, rotate=-180-\a]
                    \def \length{\C}
                    \arm
                \end{scope}
                \arm
            \end{scope}
        \end{scope}

        % Links onder
        \begin{scope}[shift={(0,0)}]
            \node at \nodepos {3.};
            \draw (0,0) pic {box};
            \draw (0,0) pic {floor=2};
            \def \a {105};
            \def \b {5};
            \def \c {\b-\a};
            \def \C {1};
            \def \B {2.5};
            \def \A {3};
            \begin{scope}[shift={(0,0)}, rotate=180+\b]
                \draw[fill=blue] (0,0) circle(0.5);
                \def \length{\C}
                \begin{scope}[shift={(\length,0)}, rotate=-(180+\c)]
                    \def \length{\A}
                    \arm
                    \begin{scope}[shift={(\length,0)}, rotate=\c]
                        \def \length{\B+\C}
                        \arm
                    \end{scope}
                \end{scope}
                \arm
            \end{scope}
            \begin{scope}[shift={(0,0)}, rotate=\a]
                \jointred
                \def \length{\A}
                \arm
            \end{scope}
        \end{scope}

    \end{tikzpicture}
\end{document}
