# Merging two 2D wave animations into one 3D animation?

I have an electric field,

Elec[d_, w_, q_, r_, t_] = -((q accel)/(4 \[Pi] Subscript[\[Epsilon], 0] r c^2))
Subscript[\[Epsilon], 0] :=  8.85*10^-12
c := 3*10^8

Where accel is a vector shown as below

{0, 1/4 Sqrt[3] d w^2 Cos[t w], -(1/4) d w^2 Cos[t w]}

This is how my output looks:

This is how my animation looks

Animate[Plot[Elec[1, 1, 1 , 1000, t + l], {t, 0, 10},
PlotRange -> 0.0000000001], {l, 0, 10} ]

I want to make it so that I get one single wave to show up, but in 3D. The wave should be the average of the two in both magnitude and direction. I was wondering what function or set of functions I could use to achieve my goal?

Another question if i may, I have a magnetic field,

B[d_, w_, q_, r_, t_] = R \[Cross]Elec[d, w, q, r, t]/c

Where R is:

R =  {0, 1/2, \[Sqrt]3/2}

Here's a picture of my code

How can I made this into a 3D wave from my current animation?

Animate[Plot[B[1, 1, 1 , 1000, t + l], {t, 0, 10},
PlotRange -> 0.0000000000000000003], {l, 0, 10} ]

These waves are all travelling in the Z direction, with the Magnetic wave propagating in the X and the electric wave between Y,Z.

My ultimate goal is this picture, but animated

Thanks for any help!

• Can these be a set of points ? You could discretize it and then make a line out of them according to what you are wanting. Dec 16, 2019 at 19:20
• Also, welcome to mma.SE! Check out our Code of Conduct. This is a great question, but I would like to make some edits to show you better syntax to use (using SetDelayed versus Set, for example). I'm working to answer it, but I do not think that your graphic properly represents what you want to show? Dec 16, 2019 at 19:40
• Dec 16, 2019 at 23:59
• @MichaelE2 that is an actual duplicate, wow! chaelim should merge the two if they can, perhaps? Dec 17, 2019 at 4:24

ClearAll[f1, f2]
f1[t_] := Sin[t];
f2[t_] := Sin[3 t];

Animate[ParametricPlot3D[{{t, f1[t], 0}, {t, 0, f2[t]}, {t, 0, 0}}, {t, 0, tmax},
PlotStyle -> {Red, Green, Gray},
PlotRange -> {{0, 3 Pi}, {-1, 1}, {-1, 1}},
ViewPoint -> {2.5, -1.3, 2}], {tmax, .1, 3 Pi}]

frames = Table[ParametricPlot3D[{{t, f1[t], 0}, {t, 0, f2[t]}, {t, 0, 0}}, {t, 0, tmax},
PlotStyle -> {Red, Green, Gray},
PlotRange -> {{0, 3 Pi}, {-1, 1}, {-1, 1}},
ViewPoint -> {2.5, -1.3, 2}], {tmax, .1, 3 Pi, 3 Pi/100}];

Export["anim.gif", frames]

You can embellish the content styling the lines as tubes and showing additional elements:

ClearAll[show]
show[tm_] := Show[ParametricPlot3D[{{t, f1[t], 0}, {t, 0, f2[t]}}, {t, 0, tm},
PlotStyle -> {Directive[Red, Tube[.05]],
PlotRange -> {{0, 3 Pi}, {-1, 1}, {-1, 1}},
ViewPoint -> {2.5, -1.3, 2}],
Graphics3D[{ Opacity[.2, Red], EdgeForm[],
InfinitePlane[{0, 0, 0}, {{1, 0, 0}, {1, 1, 0}}], Green,
InfinitePlane[{0, 0, 0}, {{1, 0, 0}, {1, 0, 1}}] , Opacity[1],
Black, Thin, InfiniteLine[{{0, 0, 0}, {3 Pi, 0, 0}}]}]]

Animate[show[tmax], {tmax, .1, 3 Pi}]

frames = Table[show[tmax], {tmax, .1, 3 Pi, 3 Pi/100}];
Export["anim.gif", frames]

• Nice one! OP's plot specifications are a little weird (to me) I can't parse out what is time and what is whatever else. I hope they can answer, else this is a good method to follow, @chae-lim Dec 16, 2019 at 19:59
• Hey! Thank for this! Another quick question if you don't mind answering: If you see my electric field and magnetic fields? they have very small values. When I plug my wave functions into the code you've showed me, the wave is not even visible. I can change the range of the graph, but I am not able to change the Zoom. I was wondering if there was a function for that? Dec 16, 2019 at 20:24
• @chaelim, try changing PlotRange -> {{0, 3 Pi}, {-1, 1}, {-1, 1}} to PlotRange -> {{0, 3 Pi}, All, All}.
– kglr
Dec 16, 2019 at 20:37
• The usual way to handle this is to change units---multiply all equalities by 4πε and plot (4πεE) against time. Dec 16, 2019 at 20:38
• Thank you both! I got it working. Dec 16, 2019 at 20:47