0

I have searched aimlessly for a prototype of my work but to no avail. Please, I would need help in plotting this. Can anyone please, help me out? Thanks.

Remark: There would be a thick line between M and M1, denoted by \Delta s.

enter image description here

  • see https://tex.stackexchange.com/questions/401225/how-to-draw-a-tangent-line-to-the-following-curve , https://tex.stackexchange.com/questions/290241/how-to-draw-a-tangent-line-to-an-arbitrary-addplot , https://tex.stackexchange.com/questions/394368/how-to-draw-general-functions-and-tangent-lines – ian May 28 '19 at 14:02

1 Answers1

5

The tangents come from this answer and the thick stretch is achieved via dash pattern.

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{decorations.markings,calc,angles,quotes,bending}
\begin{document}
\begin{tikzpicture}[tangent/.style={% from https://tex.stackexchange.com/a/25940/121799
        decoration={
            markings,% switch on markings
            mark=
                at position #1
                with
                {
                    \coordinate (tangent point-\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}) at (0pt,0pt);
                    \coordinate (tangent unit vector-\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}) at (1,0pt);
                    \coordinate (tangent orthogonal unit vector-\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}) at (0pt,1);
                }
        },
        postaction=decorate
    },
    use tangent/.style={
        shift=(tangent point-#1),
        x=(tangent unit vector-#1),
        y=(tangent orthogonal unit vector-#1)
    },
    use tangent/.default=1,declare function={t1=0.34;t2=0.5;}]
 \draw[stealth-stealth] (0,6) node[left]{$y$} |- (6,0) coordinate(X) node[below]{$x$};
 \draw [preaction={decorate,decoration={markings,mark=at position 0 with
     {\pgfmathsetmacro{\myoff}{t1*\pgfdecoratedpathlength}
     \pgfmathsetmacro{\myon}{(t2-t1)*\pgfdecoratedpathlength}
     \xdef\myoff{\myoff}\xdef\myon{\myon}}}},
     tangent=t1,
     tangent=t2,
     postaction={draw,very thick,dash pattern=on 0pt off \myoff pt on \myon pt
     off 3cm}] (2,t2)
     to [out=70,in=-190]  node[pos=t1,below right] {$M$} 
     node[pos=t2,below right] {$M_1$}(6,4);
 \path [use tangent] (-3,0) coordinate (t11) -- (3,0) coordinate (t12);
 \path [use tangent=2] (-3,0) coordinate (t21) -- (3,0) coordinate (t22);
 \path (intersection cs:first line={(0,0)--(6,0)},second line={(t11)--(t12)})
   coordinate (i1)
   (intersection cs:first line={(0,0)--(6,0)},second line={(t21)--(t22)})
   coordinate (i2)
   (intersection cs:first line={(t11)--(t12)},second line={(t21)--(t22)})
   coordinate (i3);
 \draw[thin,blue] (i1) -- (t12);
 \draw[thin,red] (i2) -- (t22);
 \draw[>=latex]  let \p1=($(t12)-(t11)$),\p2=($(t22)-(t21)$),
   \n1={(atan2(\y1,\x1)+atan2(\y2,\x2))/2} in 
   pic["$\alpha$" anchor=west, draw,->, angle eccentricity=1,angle radius=4mm] {angle=X--i2--t22}
   pic["$\alpha+\Delta\alpha$" anchor=west, draw,->, angle eccentricity=1,angle radius=4mm] {angle=X--i1--t12}
   pic["$\Delta\alpha$" {anchor=east,rotate=\n1}, draw,->, angle eccentricity=1,angle
   radius=18mm] {angle=i2--i3--i1}
   pic["$\Delta\alpha$" {anchor=west,rotate=\n1}, draw,->, angle eccentricity=1,angle
   radius=18mm] {angle=t22--i3--t12};
\end{tikzpicture}
\end{document}

enter image description here

Of course, the tangent positions t1 and t2 can be adjusted at will.

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{decorations.markings,calc,angles,quotes,bending}
\tikzset{tangent/.style={% from https://tex.stackexchange.com/a/25940/121799
        decoration={
            markings,% switch on markings
            mark=
                at position #1
                with
                {
                    \coordinate (tangent point-\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}) at (0pt,0pt);
                    \coordinate (tangent unit vector-\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}) at (1,0pt);
                    \coordinate (tangent orthogonal unit vector-\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}) at (0pt,1);
                }
        },
        postaction=decorate
    },
    use tangent/.style={
        shift=(tangent point-#1),
        x=(tangent unit vector-#1),
        y=(tangent orthogonal unit vector-#1)
    },
    use tangent/.default=1}
\begin{document}
\foreach \X in {0.48,0.49,...,0.56,0.55,0.54,...,0.49}
{\begin{tikzpicture}[declare function={t1=0.34;t2=\X;}]
 \draw[stealth-stealth] (0,6) node[left]{$y$} |- (6,0) coordinate(X) node[below]{$x$};
 \draw [preaction={decorate,decoration={markings,mark=at position 0 with
     {\pgfmathsetmacro{\myoff}{t1*\pgfdecoratedpathlength}
     \pgfmathsetmacro{\myon}{(t2-t1)*\pgfdecoratedpathlength}
     \xdef\myoff{\myoff}\xdef\myon{\myon}}}},
     tangent=t1,
     tangent=t2,
     postaction={draw,very thick,dash pattern=on 0pt off \myoff pt on \myon pt
     off 3cm}] (2,t2)
     to [out=70,in=-190]  node[pos=t1,below right] {$M$} 
     node[pos=t2,below right] {$M_1$}(6,4);
 \path [use tangent] (-3,0) coordinate (t11) -- (3,0) coordinate (t12);
 \path [use tangent=2] (-3,0) coordinate (t21) -- (3,0) coordinate (t22);
 \path (intersection cs:first line={(0,0)--(6,0)},second line={(t11)--(t12)})
   coordinate (i1)
   (intersection cs:first line={(0,0)--(6,0)},second line={(t21)--(t22)})
   coordinate (i2)
   (intersection cs:first line={(t11)--(t12)},second line={(t21)--(t22)})
   coordinate (i3);
 \draw[thin,blue] (i1) -- (t12);
 \draw[thin,red] (i2) -- (t22);
 \draw[>=latex]  let \p1=($(t12)-(t11)$),\p2=($(t22)-(t21)$),
   \n1={(atan2(\y1,\x1)+atan2(\y2,\x2))/2} in 
   pic["$\alpha$" anchor=west, draw,->, angle eccentricity=1,angle radius=4mm] {angle=X--i2--t22}
   pic["$\alpha+\Delta\alpha$" anchor=west, draw,->, angle eccentricity=1,angle radius=4mm] {angle=X--i1--t12}
   pic["$\Delta\alpha$" {anchor=east,rotate=\n1}, draw,->, angle eccentricity=1,angle
   radius=18mm] {angle=i2--i3--i1}
   pic["$\Delta\alpha$" {anchor=west,rotate=\n1}, draw,->, angle eccentricity=1,angle
   radius=18mm] {angle=t22--i3--t12};
\end{tikzpicture}}
\end{document}

enter image description here

You can embed this in any LaTeX document.

\documentclass[11pt,article]{elsarticle}
\usepackage{tikz}
\usetikzlibrary{decorations.markings,calc,angles,quotes,bending}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}[tangent/.style={% from https://tex.stackexchange.com/a/25940/121799
        decoration={
            markings,% switch on markings
            mark=
                at position #1
                with
                {
                    \coordinate (tangent point-\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}) at (0pt,0pt);
                    \coordinate (tangent unit vector-\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}) at (1,0pt);
                    \coordinate (tangent orthogonal unit vector-\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}) at (0pt,1);
                }
        },
        postaction=decorate
    },
    use tangent/.style={
        shift=(tangent point-#1),
        x=(tangent unit vector-#1),
        y=(tangent orthogonal unit vector-#1)
    },
    use tangent/.default=1,declare function={t1=0.34;t2=0.5;}]
 \draw[stealth-stealth] (0,6) node[left]{$y$} |- (6,0) coordinate(X) node[below]{$x$};
 \draw [preaction={decorate,decoration={markings,mark=at position 0 with
     {\pgfmathsetmacro{\myoff}{t1*\pgfdecoratedpathlength}
     \pgfmathsetmacro{\myon}{(t2-t1)*\pgfdecoratedpathlength}
     \xdef\myoff{\myoff}\xdef\myon{\myon}}}},
     tangent=t1,
     tangent=t2,
     postaction={draw,very thick,dash pattern=on 0pt off \myoff pt on \myon pt
     off 3cm}] (2,t2)
     to [out=70,in=-190]  node[pos=t1,below right] {$M$} 
     node[pos=t2,below right] {$M_1$}(6,4);
 \path [use tangent] (-3,0) coordinate (t11) -- (3,0) coordinate (t12);
 \path [use tangent=2] (-3,0) coordinate (t21) -- (3,0) coordinate (t22);
 \path (intersection cs:first line={(0,0)--(6,0)},second line={(t11)--(t12)})
   coordinate (i1)
   (intersection cs:first line={(0,0)--(6,0)},second line={(t21)--(t22)})
   coordinate (i2)
   (intersection cs:first line={(t11)--(t12)},second line={(t21)--(t22)})
   coordinate (i3);
 \draw[thin,blue] (i1) -- (t12);
 \draw[thin,red] (i2) -- (t22);
 \draw[>=latex]  let \p1=($(t12)-(t11)$),\p2=($(t22)-(t21)$),
   \n1={(atan2(\y1,\x1)+atan2(\y2,\x2))/2} in 
   pic["$\alpha$" anchor=west, draw,->, angle eccentricity=1,angle radius=4mm] {angle=X--i2--t22}
   pic["$\alpha+\Delta\alpha$" anchor=west, draw,->, angle eccentricity=1,angle radius=4mm] {angle=X--i1--t12}
   pic["$\Delta\alpha$" {anchor=east,rotate=\n1}, draw,->, angle eccentricity=1,angle
   radius=18mm] {angle=i2--i3--i1}
   pic["$\Delta\alpha$" {anchor=west,rotate=\n1}, draw,->, angle eccentricity=1,angle
   radius=18mm] {angle=t22--i3--t12};
\end{tikzpicture}
\caption{Tangents and curvature from the change of slopes.}
\end{figure}
\end{document}
  • If I had more votes, I would have given you. Thanks a lot! – Omojola Micheal May 28 '19 at 15:07
  • Sorry, I was trying to implement the remark I gave earlier on, but couldn't do it. This was the remark I gave. Remark: There would be a thick line between M and M1, denoted by \Delta s. Sorry to bother you! – Omojola Micheal May 28 '19 at 15:30
  • @OmojolaMicheal Just add node[pos={(t1+t2)/2},below right] {$\Delta s$} before (6,4) (and after node[pos=t2,below right] {$M_1$}). –  May 28 '19 at 15:45
  • Thanks a lot! I am grateful. – Omojola Micheal May 28 '19 at 15:54
  • @marmot How did you do the gif? Great job. Congratulations – Moura May 28 '19 at 17:58
  • 1
    @Moura https://tex.stackexchange.com/a/136919/121799 : convert -density 300 -delay 24 -loop 0 -alpha remove <file.pdf> <file.gif>. –  May 28 '19 at 18:00
  • @marmot I couldn't do the convertion. I've been installed ImageMagick (windows) ..\uteis\latex>convert -density 300 -delay 24 -loop 0 -alpha remove animate3.pdf animate3.gif Could you help me? – Moura May 29 '19 at 21:03
  • 1
    @Moura Short answer: no, I do not use Windows, so you are asking the wrong being, sorry. –  May 29 '19 at 21:18
  • @marmot I'll try in Linux. Thanks again – Moura May 30 '19 at 22:43