4

Unfortunately I have yet to figure out how to get things done in Tikz and I wanted to ask if someone could help me doing this picture in TeX-Code (Tikz preferably). I think I could manage to get the circle done but whenever it comes to angles I just screw up massively and I can't figure it out.

enter image description here

i would highly appreciate any help. ty very much

  • 3
    Welcome! Please edit your question to provide the code for a complete minimal document showing the bit you can do. Please also avoid abbreviating words texting-style, which makes your post more difficult for those less fluent in English. Are you aware that capital letters are no longer subject to government rationing in most jurisdictions? Also the quotas which previously applied to the use of full stops (periods) and commas have recently been abolished network-wide. – cfr Mar 19 '18 at 2:31
  • 1
    I'm not aware of a zykloid. Are you talking about a cycloid? The wikipedia page also has several equations that can get you started. Or googling "tikz cycloid" led me to this question. – Teepeemm Mar 19 '18 at 2:42
  • GeoGebra can export TikZ code (though the resulting code can be a bit of a mess, at times). – Torbjørn T. Mar 19 '18 at 11:29
6

UPDATE: Removed the calc library and added an animation.

 \documentclass[tikz,border=4pt]{standalone}
 \usetikzlibrary{intersections}
 \makeatletter % from https://tex.stackexchange.com/a/20864/121799
 \newcommand{\tikzAngleOfLine}{\tikz@AngleOfLine}
    \def\tikz@AngleOfLine(#1)(#2)#3{
    \pgfmathanglebetweenpoints{
        \pgfpointanchor{#1}{center}}{
        \pgfpointanchor{#2}{center}}
    \pgfmathsetmacro{#3}{\pgfmathresult}
  }
 \makeatother 
 \begin{document}
 \begin{tikzpicture}[scale=5,font=\sffamily]
  \draw[-latex] (0,-0.2) -- (0,2.2);
  \draw[-latex] (-0.1,0) -- (2.4,0);
  \coordinate[label=45:{$O$}] (O) at (0,0);
  \coordinate[label=45:{$M$}] (M) at (1.1,1);
  \coordinate[label=45:{$T$}] (T) at (M|-O);
  \draw[name path=circle] (M) circle (1);
  \draw[name path=cycloid,green!50!black] (O) plot[variable=\x,domain=0:5*pi/6] ({\x-sin(\x*180/pi)}
  ,{1-cos(\x*180/pi)});
  \path [name intersections={of=cycloid and circle,by={P,Q}}];
  \coordinate[label=45:{$R$}] (R) at (P-|M);
  \tikzAngleOfLine(M)(R){\AngleStart}
  \tikzAngleOfLine(M)(P){\AngleEnd}
  \filldraw[red,fill opacity=0.3]  (M) -- (M)+(\AngleStart:4pt)
   arc (\AngleStart:\AngleEnd:4pt) node[pos=0.3,above,opacity=1]{$t$} -- (M)  --cycle;
  \filldraw[green,fill opacity=0.3]  (R) -- ++(-4pt,0) arc (180:90:4pt) -- (R) -- cycle;
  \draw[name path=line] (T) -- (M) -- (P) node[above,midway,sloped]{$r$} -- (R);
  \node[label=above:{$P$}] at (P){};
  \foreach \X in {O,T,M,P,R}
  {\draw[fill=blue] (\X) circle (0.4pt);}
 \end{tikzpicture}
 \end{document}

enter image description here

\documentclass{article}

\usepackage{animate}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[active,tightpage]{preview}
\makeatletter
\def\@anim@@newframe{\@ifstar\@anim@newframe\@anim@newframe}
\def\@anim@newframe{\end{preview}\begin{preview}}
\renewenvironment{animateinline}[2][]{%
  \let\newframe\@anim@@newframe%
  \let\multiframe\@anim@multiframe%
  \begin{preview}}{%
  \end{preview}}
\makeatother
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \usepackage{tikz}
 \usetikzlibrary{intersections}
 \makeatletter % from https://tex.stackexchange.com/a/20864/121799
 \newcommand{\tikzAngleOfLine}{\tikz@AngleOfLine}
    \def\tikz@AngleOfLine(#1)(#2)#3{
    \pgfmathanglebetweenpoints{
        \pgfpointanchor{#1}{center}}{
        \pgfpointanchor{#2}{center}}
    \pgfmathsetmacro{#3}{\pgfmathresult}
  }
 \makeatother 
 \begin{document}
 \begin{animateinline}[autoplay,loop]{2}
 \multiframe{62}{i=1+1}{\pgfmathsetmacro{\X}{\i/10}
 \begin{tikzpicture}[scale=2,font=\sffamily]
  \draw[-latex] (0,-0.2) -- (0,2.2);
  \draw[-latex] (-1,0) -- (7.2,0);
  \path[use as bounding box] (-1,-0.4) rectangle (7.4,2.5);
  \coordinate[label=45:{$O$}] (O) at (0,0);
  \coordinate[label=45:{$M$}] (M) at (\X,1);
  \coordinate[label=45:{$T$}] (T) at (M|-O);
  \draw[name path=circle] (M) circle (1);
  \draw[name path=cycloid,green!50!black] (O) plot[variable=\x,domain=0:0.01+\X] ({\x-sin(\x*180/pi)}
  ,{1-cos(\x*180/pi)});
  % \Disc discriminates between the cases of one and two intersections
  \pgfmathtruncatemacro{\Disc}{ifthenelse(\i>31,1,0)}
  \ifnum\Disc=0
  \path [name intersections={of=cycloid and circle,by={P}}];
  \else
  \path [name intersections={of=cycloid and circle,by={Q,P}}];
  \fi
  \coordinate[label=45:{$R$}] (R) at (P-|M);
  \tikzAngleOfLine(M)(R){\AngleStart}
  \tikzAngleOfLine(M)(P){\AngleEnd}
  \filldraw[red,fill opacity=0.3]  (M) -- (M)+(\AngleStart:4pt)
   arc (\AngleStart:\AngleEnd:4pt) node[pos=0.3,above,opacity=1]{$t$} -- (M)  --cycle;
  \tikzAngleOfLine(R)(P){\AngleStart}
  \tikzAngleOfLine(R)(M){\AngleEnd}
  \ifnum\Disc=0
  \filldraw[green,fill opacity=0.3]  (R) -- ++(-4pt,0) arc (180:\AngleEnd:4pt) -- (R) -- cycle;
  \else
  \filldraw[green,fill opacity=0.3]  (R) -- ++(4pt,0) arc (0:\AngleEnd:4pt) -- (R) -- cycle;
  \fi
  \draw[name path=line] (T) -- (M) -- (P) node[above,midway,sloped]{$r$} -- (R)
  --cycle;
  \node[label=above:{$P$}] at (P){};
  \foreach \X in {O,T,M,P,R}
  {\draw[fill=blue] (\X) circle (1pt);}
 \end{tikzpicture}}
 \end{animateinline}
 \end{document}

Using this trick one can create an animated gif.

enter image description here

  • (+1) Note that the calc library isn't needed, you're not using it. – Torbjørn T. Mar 19 '18 at 11:38
  • wow! thank you so much for this. i really appreciate your help. i will use it immediately and try to get a good grasp of how do do it myself. thank you 1000x – Zest Mar 19 '18 at 12:30
  • @TorbjørnT. You're right (as always;-). I added it before I stole \tikzAngleOfLine from this post, and forgot to drop it. – user121799 Mar 19 '18 at 14:52
  • @marmot Congratulations. – Tarass Mar 19 '18 at 17:46
  • @marmot sorry! i didnt know answers can be accepted. thank you for your help :-) i really appreciate it! – Zest Mar 19 '18 at 22:03
3

enter image description here

\documentclass[dvipsnames,tikz,margin=5mm]{standalone}
\usepackage{luatex85}
\usetikzlibrary{%
    calc,
    backgrounds,
    quotes,
    angles,
    }


% 3 couches de dessin
\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{background,main,foreground}


\tikzset{% Angle droit
    angle droit/.style={very thin},
    angle droit size/.store in=\AngleDtLgth,
    angle droit size=5pt,
    pics/.cd,
    angle droit/.style args={#1-#2-#3}{%
        code = {%
        \draw[angle droit] ($(#2)!\AngleDtLgth!(#1)$)
        --($(#2)!2!($($(#2)!\AngleDtLgth!(#1)$)!.5!($(#2)!\AngleDtLgth!(#3)$)$) $)
        --($(#2)!\AngleDtLgth!(#3)$) ; ;
        }
    }}


\begin{document}

\foreach \x [count=\n from 0] in {0,5,...,360} {%

\begin{tikzpicture}

\draw[-stealth] (-1.1,0) -- (7.5,0) ;
\draw[-stealth] (0,-.5)--(0,2.5) ;
\coordinate (O) at (0,0) ;

\begin{scope}[shift={(\x/180*3.14159,1)}]

\draw[blue, semithick] circle (1) ;

\coordinate (A\n) at (-\x-90:1) ;

\draw[thin] (0,0) coordinate (M) -- (A\n) ;

\draw[red,smooth] (A0) \foreach \p in {0,...,\n} {--(A\p)} ;

\draw[thin,-stealth] (0,-1) coordinate (A) 
    -- (0,1.5) coordinate (B) ;

\draw[thin,dashed] (A\n) -- ($(A)!(A\n)!(B)$) coordinate (R);

\begin{pgfonlayer}{background}
\draw pic[%
    "\tiny\x",
    draw=green,
    fill=green!15,
    angle eccentricity=2,
    angle radius=.2cm
    ] {angle=A\n--M--A} ;
\end{pgfonlayer}

\pgfmathsetmacro{\Rangle}{ifthenelse(\x<180,"0","180")}

\foreach \Coor/\Text/\Pos in 
    {O/$O$/225,
    M/$M$/0,
    A/$T$/-45,
    A\n/$P$/225-\x,
    R/$R$/\Rangle%
    } {%
    \draw[fill=blue] (\Coor) circle (1pt);
    \node[shift=(\Pos:6pt),anchor=center] at (\Coor) {\tiny\Text} ;
    }

\path pic[angle droit size=4pt] {angle droit=A\n-R-M} ;


\fill[red] (A\n) circle (1pt) ;

\end{scope}

\end{tikzpicture}}

\end{document}
  • Very nice!!! (+1) But now I also have to add an animation. ;-) – user121799 Mar 19 '18 at 16:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.