2

How to draw the rectangle with round corner representing the beam as in the picture?

\documentclass[tikz,border=.1mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric,calc, angles}
\usetikzlibrary{shapes.geometric,calc, intersections}
\usetikzlibrary{decorations.pathmorphing,patterns}
\usetikzlibrary{decorations.markings}


\begin{document}
\begin{tikzpicture}
    \begin{scriptsize}
        \coordinate(P) at(0,4);
        \coordinate(Q) at(4,4);
        \coordinate(R) at(0,-1);
        \draw[line width=.6pt, blue](R)--(Q);
        \draw(P)node[above]{$P$}--(Q);
        \fill[yellow!33](0,5) rectangle(-.3,-2);
        \draw(0,5)--(0,-2);
        \draw[->](Q)node[above] {$Q$}--++(0,-3.5) node[right]{4.0 kN} ;
        \draw[fill=gray!33](3.8,1.3) rectangle(4.2,1.6);
        
    \draw(P)--(Q)--(R)pic[draw=blue,->,angle eccentricity=1,angle radius=1.75cm] {angle=P--Q--R};
    
    \end{scriptsize}
\end{tikzpicture}
\end{document}

enter image description here

2 Answers 2

3

As a starting point, you could make use of the double style in combination with line cap=round (note that I optimized your code a bit):

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{angles}

\begin{document}
\begin{tikzpicture}\scriptsize
    \coordinate (P) at (0,4);
    \coordinate (Q) at (4,4);
    \coordinate (R) at (0,-1);
    
    \fill[yellow!33] (0,5) rectangle (-.3,-2);
    \draw (0,5) -- (0,-2);
        
    \draw (P) node[above] {$P$} -- (Q);

    \draw[double, line cap=round, double distance=5pt] (R) -- (Q);
    \draw[line width=.6pt, blue] (R) -- (Q);

    \pic[draw=blue, ->, angle eccentricity=1, angle radius=1.75cm] 
            {angle={P--Q--R}};
        
    \draw[->] (Q) node[above] {$Q$} -- ++(0,-3.5) node[right] {4.0 kN} ;
    \draw[fill=gray!33] (3.8,1.3) rectangle (4.2,1.6);
        
\end{tikzpicture}
\end{document}

enter image description here


With the help of the decorations library, you can also create you custom style that adds the small dots at both ends of the beam. I'd also recomment using the siunitx package:

\documentclass[border=10pt]{standalone}
\usepackage{tikz, siunitx}
\usetikzlibrary{angles, arrows.meta, decorations.markings}

\tikzset{
    beam/.style={
        draw=none,
        preaction={
            draw,
            double, 
            line cap=round, 
            double distance=5pt,
        },
        postaction={
            decorate,
            decoration={
                markings,
                mark=at position 0 with {
                    \arrow{Circle[width=1pt, length=1pt]}
                },
                mark=at position 1 with {
                    \arrow{Circle[width=1pt, length=1pt]}
                }
            }
        }
    }
}

\begin{document}
\begin{tikzpicture}\scriptsize
    \coordinate (P) at (0,4);
    \coordinate (Q) at (4,4);
    \coordinate (R) at (0,-1);
    
    \fill[yellow!33] (0,5) rectangle (-.3,-2);
    \draw (0,5) -- (0,-2);
    
    \draw (P) node[above right] {$P$} -- (Q);

    \pic[draw=blue, angle radius=1cm] {angle={P--Q--R}};
    \node[blue] at ([shift={(25:-0.7)}]Q) {\qty{30}{\degree}};

    \draw[->] (Q) node[above right] {$Q$} -- ++(0,-3.5) 
        node[right] {\qty{4.0}{\kilo\newton}} ;
    \draw[fill=gray!33] (3.8,1.3) rectangle (4.2,1.6);

    \draw[beam] (R) -- (Q);

\end{tikzpicture}
\end{document}

enter image description here

2

After the Jasper's excellent answers (accepted and upvoted) I propose another very modest one:

\documentclass[border=10pt]{standalone}
\usepackage{tikz}

\begin{document}
    \begin{tikzpicture}[scale=1.5]
        \fill[gray!40] (-1,2) rectangle (0,8);
        \draw[line width=2pt] (0,2)--(0,8);
        \draw (-.5,4)--(-1.5,5) node[above] () {vertical wall};
        \draw[line width=1pt] (0,7)--(6,7) node[pos=-.02] () {P};
        
        \draw (0,6.8)--(.2,6.8)--(.2,7);
        \draw[double, line cap=round, double distance=8pt] (-.1,4)--(5.8,6.8) node[pos=-.03] () {R};
        \draw[-latex] (5,7) arc(-180:-150:1) node[pos=.5,fill=white] () {30°};
        \draw (6,6.8)--(6,4);
        \draw (5.75,3.5) rectangle (6.25,4);
        \draw[-latex,line width=2pt] (6,3.75)--(6,2.75) node[right] () {\bfseries 4.0 kN};
        \fill[gray] (5.8,6.8) circle(.3);
        \fill (5.8,6.8) circle(.05) node[right] () {Q};
        \fill (-.1,4) circle(.05);
    \end{tikzpicture}
\end{document}

Output:

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .