# How to draw a phasor animation with Mathematica?

I wonder if (and how) one could draw such animation with Mathematica?

I'm not necessary interested in the code required to draw the exact same animation, but at least to hints and suggestions to point me in the right direction. Especially to synchronize and properly align the rotating phasor with its sinusoidal trace scrolling vertically.

• You certainly can do it. Look at Manipulate. You can step the parameter or click play. The following example shows part of what you are asking for Manipulate[Plot[Sin[u + t], {u, 0, 2 Pi}], {t, 0, 2 Pi}] – mikado Dec 12 '19 at 21:38
• Yes, @Mikado. I tried a couple of things like that before asking. But I can't manage (in Wolfram Cloud) to put two animated graphs one right on top of the other--and with some line to connect them as it is done with the animation showed in the question. – Sylvain Leroux Dec 12 '19 at 21:49

Trying to do this with plots may end up being very difficult. I tend to use the plot as a base and then add ancillary graphics around it, e.g. with Show:

With[{center = {-1.5, 0}, radius = 1},
Animate[
Show[
Plot[
Sin[omega + phi], {omega, 0, 2 Pi},
Ticks -> None, AspectRatio -> Automatic,
AxesOrigin -> {0, 0}, PlotStyle -> Blue
],
Graphics[{
Blue, Thick,
Arrow[{center, {Cos[phi] + center[[1]], Sin[phi]}}],
Dashed, Circle[center],
PointSize[0.02],
Through[
{Point, Line}[{
{center[[1]], Sin[phi]},
{0, Sin[phi]}
}]
]
}],
PlotRange -> All
],
{phi, 0, 2 Pi}
]
]


• This is quite impressive Marco. I didn't expect such an complete solution. You gave me many new things to study. Thanks a lot! – Sylvain Leroux Dec 12 '19 at 23:06
f[t_] := Module[{circ = {Blue, Dashed, Circle[]},
ax = {Black, Line[{{-1.1, 0}, {1.1, 0}}],
Line[{{-1.1, 1.5}, {1.1, 1.5}}], Line[{{0, -1.1}, {0, 1.1}}],
Line[{{0, 1.5}, {0, 1.5 + Pi}}]}, tr = {0, 1.5},
p = {Cos[t], Sin[t]}},
Graphics[{circ, ax, Blue, Arrow[{{0, 0}, p}], PointSize[0.03],
Point[{{p[[1]], 0}, {p[[1]], 1.5}}], Line[{{p[[1]], 0}, p}],
Line@Table[{0, 1.5} + {Cos[j + t], j}, {j, 0, Pi, 0.1}], Dashed,
Line[{p, {p[[1]], 1.5}}]}]]


Animating:

Animate[f[t], {t, 0, 2 Pi}]