# Mohr’s circle

Draws Mohr’s circle for given stress – values before and after rotation.

Inputs are the stress – values and the angle of rotation.

Version 1, 29.07.2023

\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{calc}
\tikzset{prerot/.style = {line width = 1.5pt, color = gray},
postrot/.style = {line width = 1.5pt, color = red},
reflineprerot/.style = {line width = 1.pt,  color = gray, dashed},
reflinepostrot/.style = {line width = 1.pt,  color = black, dashed}}
\begin{document}
\begin{tikzpicture}[scale=0.6]
%Choose stress values
\def\sigmax{9} % upper normal-stress value before rotation
\def\sigmay{3} % lower normal-stress value before rotation
\def\tauxy{4}  % shear-stress value before rotation
\def\phi{13}   % angle for rotation
\pgfmathsetmacro\sigmam{0.5*(\sigmax+\sigmay)} % compute center of circle
% compute upper normal-stress value after rotation:
% compute lower normal-stress value after rotation:
% compute shear-stress value after rotation:
\def\s{0.5} % parameter for small offsets
\pgfmathsetmacro\w{\sigmam+\r+\s} % parameter for width
\pgfmathsetmacro\h{\r+\s} % parameter for height
%
%\draw[step=0.5,gray] (-4*\s,-\h) grid (\w+\s,\h+\s);% turn on grid if wanted
%
% coordinate system
\draw[line width = 1pt,-latex] (0,-\h)--(0,\h)
node[at end, anchor = south] {$\tau$};
\draw[line width = 1pt,-latex] (0,0)--(\w,0)
node[at end, anchor = west] {$\sigma$};
%
% draw circle
\draw[color = blue, line width = 1pt] (\sigmam,0) circle (\r);
%
% draw system before rotation
% draw connecting line
\draw[prerot](\sigmax,\tauxy) - -(\sigmay,-\tauxy);
\node at (\sigmax,\tauxy)  [anchor=south west, prerot] {$P_1$};
\node at (\sigmay,-\tauxy) [anchor=north east, prerot] {$P_2$};
%
% draw stress values
\draw[reflineprerot] (\sigmax,0) -- +(0,\tauxy)  -- (0,\tauxy);
\draw[reflineprerot] (\sigmay,0) -- +(0,-\tauxy) -- (0,-\tauxy);
\draw[prerot](0,\tauxy)     -- +(-0.3,0) node[anchor = east] {$\tau_{xy}$};
\draw[prerot](0,-\tauxy)    -- +(-0.3,0) node[anchor = east] {$-\tau_{xy}$};
\draw[prerot](\sigmax,0)    -- +(0,-0.3) node[anchor = north] {$\sigma_x$};
\draw[prerot](\sigmay,-0.3) -- +(0,0.3)  node[anchor = south] {$\sigma_y$};
\draw (\sigmam,0) --+(0,-0.3) node[anchor = north] {$\sigma_m$};
% draw system before rotation
%
% draw connecting line
\draw[line width = 1.5pt,color=orange] (\sigmau,\tauuv) -- (\sigmav,-\tauuv);
\node at (\sigmau,\tauuv) [anchor=south west] {$P_1^{\prime}$};
\node at (\sigmav,-\tauuv) [anchor=north east] {$P_2^{\prime}$};
%
% draw stress values
\draw[reflinepostrot] (\sigmau,0) -- +(0,\tauuv)  -- (0,\tauuv);
\draw[reflinepostrot] (\sigmav,0) -- +(0,-\tauuv) -- (0,-\tauuv);
\draw[postrot] (0,\tauuv)     -- +(-0.3,0) node[anchor = east]  {$\tau_{uv}$};
\draw[postrot] (0,-\tauuv)    -- +(-0.3,0) node[anchor = east]  {$-\tau_{uv}$};
\draw[postrot] (\sigmau,0)    -- +(0,-0.3) node[anchor = north] {$\sigma_u$};
\draw[postrot] (\sigmav,-0.3) -- +(0,0.3)  node[anchor = south] {$\sigma_v$};
\draw (\sigmam,0) -- +(0,-0.3) node[anchor = north] {$\sigma_m$};
%
% mark angle
\draw[line width=1pt, color = black,->] ($(\sigmam,0)+(\psi:0.65*\r)$)
node[anchor=center] at ($(\sigmam,0)+(\alpha:0.5*\r)$) {$2\varphi$};
\end{document}