10

Preface: I am completely unskilled and I ask my apologizes to everyone, but this question is for my students. I have not found an animated .gif or animations on the web that explains simple harmonic motion with the record player.

I don't know how to create an animated peg (pink arrow) that by rotating creates its shadow (little downarrow) on a panel (brown right arrow) where the velocity in O is the maximum and the velocity is at the point in + A (or in -A) zero.

enter image description here

Sebastiano
  • 54,118
  • 1
    https://tex.stackexchange.com/a/158741/87876 – Display Name Jan 31 '21 at 22:35
  • 1
    https://tex.stackexchange.com/a/193439/87876 – Display Name Jan 31 '21 at 22:38
  • @MoneyOrientedProgrammer I have seen now :-)..it is true that for the spring it is the same of the record player but my students have 16 years old and yet they have not studied the sinusoidal e cosinusoidal functions :-(. – Sebastiano Jan 31 '21 at 22:39
  • @MoneyOrientedProgrammer I am highly stressed: I teach a Physics class and for Math there is another colleague. I ask myself hundreds of times how to overcome this chronic stress I have. But they don't even have the concept of function which they had to learn in the first year. I explain sine and cosine and tangent in the first and third year in Physics: after 1 week they forget everything :-( – Sebastiano Jan 31 '21 at 22:44
  • Just a relevant quote for your case: "Don't waste your time with explanations. Students only hear what they want to hear. You can lead a horse to water, but you cannot make him drink." :-) – Display Name Jan 31 '21 at 22:49
  • 1
    @MoneyOrientedProgrammer The majority of students just want high scores without any studies. – Sebastiano Jan 31 '21 at 22:51
  • 2
    It is a common phenomenon that happens throughout the globe. – Display Name Jan 31 '21 at 22:53

3 Answers3

16

You seem to have very old students, who know how these record players looked like.

\documentclass[tikz,border=3mm]{standalone}
\usepackage{tikz-3dplot}
\usetikzlibrary{shadings}
\begin{document}
\tdplotsetmaincoords{70}{30}
\foreach \Angle in {180,185,...,360}
{\begin{tikzpicture}[tdplot_main_coords,line cap=round,line join=round,
    pics/cyl/.style={code={
        \draw[left color=orange,right color=orange!20] (\tdplotmainphi:0.2) arc[start angle=\tdplotmainphi,
            end angle=\tdplotmainphi-180,radius=0.2] 
            -- ($(\tdplotmainphi-180:0.2)+(0,0,1)$)
            arc[start angle=\tdplotmainphi-180,
            end angle=\tdplotmainphi,radius=0.2] -- cycle;
        \draw[fill=orange] (0,0,1) circle[radius=0.2];  
    }},pics/projected cyl/.style={code={
    \draw[gray,fill=gray!20] (-0.2,0) rectangle (0.2,1);
    }}]
 \begin{scope}[canvas is xz plane at y=5.5]
  \fill[gray] (-6,0) rectangle (6,-2);
  \fill[gray!10] (-6,0) rectangle (6,2);
  \path ({4*cos(\Angle)},0) pic[transform shape]{projected cyl};
 \end{scope}
 \begin{scope}[canvas is xy plane at z=0]
  \shade[upper left=black,upper right=gray!30,
    lower left=gray!50,lower right=black,even odd rule] circle[radius=5]
    circle[radius=2];
    \draw foreach \r in {2.1,2.2,...,4.9} {circle[radius=\r]};
    \fill[blue!50!gray] (0,0) circle[radius=2];
 \end{scope}
 \path (\Angle:4) pic{cyl};
\end{tikzpicture}}
\end{document}

enter image description here

P.S. I first did not understand what was meant by "details" but after starring long enough on the screen shot I, too, could see a duck (even though I am still not sure if it is really there).

\documentclass[tikz,border=3mm]{standalone}
\usepackage{tikz-3dplot}
\usepackage{tikzducks}
\usetikzlibrary{arrows.meta,bending,shadings}
\begin{document}
\tdplotsetmaincoords{70}{30}
\foreach \Angle in {5,15,...,355}
{\begin{tikzpicture}[tdplot_main_coords,line cap=round,line join=round,
    pics/cyl/.style={code={
        \draw[left color=orange,right color=orange!80,middle color=orange!10] 
        (\tdplotmainphi:0.2) arc[start angle=\tdplotmainphi,
            end angle=\tdplotmainphi-180,radius=0.2] 
            -- ($(\tdplotmainphi-180:0.2)+(0,0,1)$)
            arc[start angle=\tdplotmainphi-180,
            end angle=\tdplotmainphi,radius=0.2] -- cycle;
        \draw[fill=orange] (0,0,1) circle[radius=0.2];  
    }},pics/projected cyl/.style={code={
    \draw[gray,fill=gray!20] (-0.2,0) rectangle (0.2,1);
    }}]
 \begin{scope}[canvas is xz plane at y=5.5]
  \fill[gray] (-6,0) rectangle (6,-2);
  \fill[gray!10] (-6,0) rectangle (6,2);
  \draw[thick,-Stealth] (-6,3) -- (6,3);
  \draw[transform shape] (-4,2.8) -- ++ (0,0.4) node[above]{$x=-A$}
   (0,2.8) -- ++ (0,0.4) node[above]{$x=0$}
   (4,2.8) -- ++ (0,0.4) node[above]{$x=A$};
  \path ({4*cos(\Angle)},0) pic[transform shape]{projected cyl};
 \end{scope}
 \begin{scope}[canvas is xy plane at z=0]
  \shade[upper left=black,upper right=gray!30,
    lower left=gray!50,lower right=black,even odd rule] circle[radius=5]
    circle[radius=2];
  \draw foreach \r in {2.1,2.2,...,4.9} {circle[radius=\r]};
  \fill[blue!50!gray] (0,0) circle[radius=2];
  \path[nodes={transform shape,anchor=base,font={\large\sffamily},text=white}] 
   foreach \Char [count=\Z,
    evaluate=\Z as \myangle using {\tdplotmainphi+\Angle+\Z*8+(\Z==1?-4:0)}] 
    in {M,o,z,a,r,t}
    {(\myangle:1.5) node[rotate=\myangle+90]{\Char}};
  \duck[rotate=\Angle,xshift=-1cm,yshift=-1cm]  
  \pgflowlevelsynccm
  \draw[very thick,blue,-{Stealth[bend]}] 
    (180:5.5) arc[start angle=180,end angle=240,radius=5.5];
 \end{scope}
 \path (\Angle:4) pic{cyl};
\end{tikzpicture}}
\end{document}

enter image description here

P.S. Somehow it is not entirely trivial to use decorations.text together with projections on a plane.

  • 6
    Welcome back, marmot! – Black Mild Feb 01 '21 at 07:53
  • 3
    "You seem to have very old students, who know how these record players looked like." ahahah. This thought makes me sad and happy at the same time :) – Tasos Papastylianou Feb 01 '21 at 08:28
  • 1
    Welcome back here in TeX.SE. always (for me) and it is a pleasure to have your fantastic answers that I appreciated with enthusiasm. – Sebastiano Feb 01 '21 at 20:01
  • Hi, and excuse me very much for this addendum-comment. According to your humble opinion would it be possible to animate my drawing made with Mathcha where I inserted my long MWE https://tex.stackexchange.com/questions/581851/the-relationship-between-circular-motion-and-simple-harmonic-motion-with-mathcha? I always thank you so much for your cooperation. – Sebastiano Feb 03 '21 at 21:41
  • 1
    @Sebastiano Unfortunately I have no idea about Matcha and friends. In general, I think that, if you want to draw projections of 3d settings you are better off if you specify the 3d coordinates and let the computer (i.e. TikZ or whatever tool you are using) do the projections. Also, if you want to have really impressive animations of a sequence of pixel graphics, consider using asymptote. To the best of my knowledge this is the only tool with extensive TeX support that allows you to get realistic shading, automatic 3d ordering etc. (but just not in vector graphics). –  Feb 04 '21 at 03:36
  • Always very kind and friendly with me. I always consider all this indispensable and fundamental even for comments on TeX or other communities your suggestion was very useful and I always wish you all the best always and everywhere. – Sebastiano Feb 04 '21 at 12:34
10

If you only need the GIF, is LaTeX necessarily required? If you consider another alternative and my answer isn't considered as spam, there's a ConTeXt example (compile it here when an installation isn't feasible in your case). Unfortunately no fancy 3D:

\starttext
%#1: start; #2: end; #3: step; #4: content
\dostepwiserecurse{0}{330}{30}{%
\startMPpage
labeloffset := 5bp;
numeric u;  u := 1cm;
numeric alpha; alpha := \recurselevel;
pair peg, lilshadow; 
path stick;
stick := fullsquare xscaled 0.2u yscaled 2.2u shifted (1.5u*right);
peg := u*dir alpha;
lilshadow := (1.5u,ypart peg);
fill fullsquare scaled 2.2u withcolor .75[blue,white];
fill stick withcolor 0.75;
fill fullcircle scaled 2u;
fill fullcircle scaled 1/2u withcolor darkblue;
for i = 1/2 step 1/4 until 2:
    draw fullcircle scaled (i*u) withcolor 0.25; 
endfor
fill fullcircle scaled 1/8u withcolor (1,4/5,0);
%Comment the next line if you don't want a dashed line connecting the peg and its shadow
draw peg -- lilshadow dashed evenly withcolor (1,1,0);
drawdot lilshadow withpen pencircle scaled 4 withcolor 0.4;
drawdot peg withpen pencircle scaled 4 withcolor (1,1/2,0);
drawarrow (urcorner stick -- lrcorner stick) shifted (3bp*right);
label.rt("$\tfxx x=-A$", urcorner stick);
label.rt("$\tfxx x=+A$", lrcorner stick);
label.rt("$\tfxx x=0$", 1/2[urcorner stick, lrcorner stick]);
setbounds currentpicture to (fullsquare xscaled 4u yscaled 2.5u shifted (0.75u*right));
\stopMPpage%
}
\stoptext

I've chosen simple colors, but additional tuning is up to your taste. Using the following in the command line (my file is 104.pdf in the example):

convert -density 200 104.pdf 104-%02d.png
convert -delay 15 -dispose 2 104-*.png 104.gif

I finally get this GIF:

enter image description here

EDIT: As pointed out above, changing the step as well as the ending point we have a GIF which moves faster or slower. If we use

\dostepwiserecurse{0}{345}{15}{%

instead, and with the same settings for convert, we get this:

enter image description here

7

A PSTricks solution only for either fun or comparison purposes.

\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pst-node}
\begin{document}
\foreach \i in{0,10,...,350}{%
\begin{pspicture}(-5,-5)(6.5,5)
    \pscircle(0,0){4}
    \psline(5,-5)(5,5)
    \pnodes(4;\i){P}(!5 4 \i\space sin mul){Q}(5,-4){B}(5,0){O}(5,4){T}
    \psset{linecolor=gray,labelsep=12pt}
    \psline(0,0)(P)
    \qdisk(B){2pt}
    \qdisk(O){2pt}
    \qdisk(T){2pt}  
    \uput[0](B){$y=-A$}
    \uput[0](O){$y=0$}
    \uput[0](T){$y=A$}
    %
    \pcline[linestyle=dashed](P)(Q)
    \psset{linecolor=red}
    \qdisk(P){5pt}
    \qdisk(Q){5pt}
    %
    \pnode[!0 \i\space cos 1.5 mul](Q){Qy}
    \psLine[linecolor=blue,linewidth=4pt,arrowinset=0]{->}(Q)(Qy)
\end{pspicture}}
\end{document}

enter image description here

Display Name
  • 46,933
  • I have read into your mind ahahahah. Why is it more fast? +1 for the great efforts and thank you very much for your cooperation. – Sebastiano Feb 01 '21 at 21:37
  • The slower the movement of the red disc ball is better. I am scarce in English language, sorry. – Sebastiano Feb 01 '21 at 21:39
  • 1
    @Sebastiano: Velocity vectors are now depicted. – Display Name Feb 01 '21 at 21:57
  • Great! Now it is better...just an humble suggestion. I will put the blue arrow below the red circle. I have voted also the others :-) – Sebastiano Feb 01 '21 at 22:01
  • @Sebastiano: I don't understand your humble suggestion. :-) – Display Name Feb 01 '21 at 22:04
  • The tail of the blue color vector I would put under the red color circle or in the background in relation to the red circle. :-( I hope that with the traslator it is more clear. – Sebastiano Feb 01 '21 at 22:22
  • 1
    +1 Good gif file. PSTricks is still alive. –  Feb 02 '21 at 02:08
  • 1
    It is just a trivial re-phrasing, but I think @Sebastiano's suggestion is that the red ball might look better if it were 'above' (higher z-coordinate with the z-axis coming out of the screen) the blue arrow. – LSpice Feb 02 '21 at 04:29
  • 1
    @LSpice Hi, you have read my thoughts correctly :-)...Thank you very much to have understood my poor English language. – Sebastiano Feb 03 '21 at 21:31
  • @justonly If you see for the tags I have put PSTricks. :-) – Sebastiano Feb 03 '21 at 21:32