% Author: Izaak Neutelings (October 2020)
% Inspiration: https://tex.stackexchange.com/questions/25531/adding-underbrace-in-tikz
\documentclass[border=3pt,tikz]{standalone}
\usepackage{physics}
\usepackage{siunitx}
\usepackage{ifthen}
\usepackage{tikz}
\usepackage[outline]{contour} % glow around text
\usetikzlibrary{calc}
\usetikzlibrary{angles,quotes} % for pic
\usetikzlibrary{patterns}
\tikzset{>=latex} % for LaTeX arrow head
\contourlength{1.4pt}

\colorlet{xcol}{blue!70!black}
\colorlet{vcol}{green!60!black}
\colorlet{myred}{red!65!black}
\colorlet{acol}{red!50!blue!80!black!80}
\tikzstyle{ground}=[preaction={fill,top color=black!10,bottom color=black!5,shading angle=20},
                    fill,pattern=north east lines,draw=none,minimum width=0.3,minimum height=0.6]
\tikzstyle{mass}=[line width=0.6,red!30!black,fill=red!40!black!10,rounded corners=1,
                  top color=red!40!black!20,bottom color=red!40!black!10,shading angle=20]
\tikzstyle{faded mass}=[dashed,line width=0.1,red!30!black!40,fill=red!40!black!10,rounded corners=1,
                        top color=red!40!black!10,bottom color=red!40!black!10,shading angle=20]
\tikzstyle{rope}=[brown!70!black,very thick,line cap=round]
\def\rope#1{ \draw[black,line width=1.4] #1; \draw[rope,line width=1.1] #1; }
\tikzstyle{force}=[->,myred,very thick,line cap=round]
\tikzstyle{velocity}=[->,vcol,very thick,line cap=round]

\begin{document}


% PENDULUM + BLOCK
\def\L{2.6} % length
\def\ang{-32} % length
\def\R{0.25} % ball radius
\def\y{-1.14*\L} % mass
\begin{tikzpicture}
  \coordinate (M) at (\ang-90:\L);
  \coordinate (M') at (0,-\L);
  \coordinate (O) at (0,0);
  \coordinate (B) at (0,\y);
  \draw[ground] (-0.7*\L,\y) rectangle++ (1.2*\L,-\R);
  \draw (-0.7*\L,\y) --++ (1.2*\L,0);
  \draw[faded mass] (M') circle(\R);
  \draw[dashed] (O) -- (B);
  \rope{(O) -- (M)} \path (O) -- (M) node[midway,left=1] {$L$};
  \fill[black] (O) circle(0.04);
  \draw[mass] (M) circle(\R) node {$m$};
  \draw[mass] (\R,\y) rectangle++ (3.2*\R,2.5*\R) node[midway] {$M$};
  \draw pic[<-,"\,$\theta$",draw,angle radius=29,angle eccentricity=1.3] {angle=M--O--B};
\end{tikzpicture}


% PENDULUM SOLUTION
\begin{tikzpicture}
  \coordinate (M) at (\ang-90:\L);
  \coordinate (M') at (0,-\L);
  \coordinate (O) at (0,0);
  \coordinate (B) at (0,\y);
  \draw[ground] (-0.7*\L,\y) rectangle++ (1.2*\L,-\R);
  \draw (-0.7*\L,\y) --++ (1.2*\L,0);
  \draw[faded mass] (M') circle(\R);
  \draw[dashed] (O) -- (B);
  \draw[dashed] (M')++(0.7*\R,0) --++ ({0.5*\L*sin(\ang)},0) coordinate (A);
  \draw[dashed] (M')++(0.7*\R,{\L-\L*cos(\ang)}) --++ ({1.1*\L*sin(\ang)},0);
  \draw[<->] (A)++(0.12*\R,0) --++ (0,{\L-\L*cos(\ang)}) node[midway,left=-1] {$h$};
  \rope{(O) -- (M)} \path (O) -- (M) node[midway,left=1] {$L$};
  \fill[black] (O) circle(0.04);
  \draw[mass] (M) circle(\R) node {$m$};
  \draw[mass] (\R,\y) rectangle++ (3.2*\R,2.5*\R) node[midway] {$M$};
  \draw pic[<-,"\,$\theta$",draw,angle radius=29,angle eccentricity=1.3] {angle=M--O--B};
\end{tikzpicture}


\end{document}