# Animate a travelling wave - graph view like an oscilloscope

I am looking for some guidance and suggestions as to the best approach towards animating some elements of my goal - before I jump in and hack around in "the wrong" or awkward direction.

WHAT I AM TRYING TO ACHIEVE

I want to animate a travelling sine wave - with a graph view like an oscilloscope.

In other words unlike:

• where the leading point of a wave travels forwards
• (to the right)
• from the 0 point on the time axis
• a typical "history" graph

For the end result, I want:

• the wave to travel from right to left
• the leading edge of the wave to remain at a fixed point on the time axis
• (on the far right edge)
• which is effectively the current time
• so it's more of a "live view" - like an oscilloscope
• (or the machine that goes ping!)

Here is a sample target end result:

(modified) animated GIF image that I culled from Wikipedia

[ Thank you User:LucasVB/Gallery ]

WHAT I AM COMFORTABLE WITH

I should be fine with:

• the stationary frame
• pretty trivial/straight-forward
• the leading edge plot point - the red dot
• add a red sphere element of an apropriate size
• use a location driver to move it up and down the Z-axis

ASSUMPTIONS

What is the simplest approach you suggest I should use for the:

1. The moving red sine wave

I'm thinking of:

• generating a long stationary sine wave element
• (length as long as the number of cycles as I need for the animation time)
• use an X-axis location driver
• current_frame
• to move the element from right to left

Then I would need to:

• mask the portions of the sine wave that lie outside the graph frame
• left & right

2. The moving graph background

Pretty much the same approach as above.

• generate a long background axis "strip"
• move it as above with a driver
• mask the portions of the background axis that lie outside the graph frame
• left & right

1 & 2 Together

I could combine the two elements above into a single moving strip

• and mask the portions of the single moving strip that lie outside the graph frame
• left & right

REQUEST

Does anyone have any better suggestions for me ?

Simpler, faster, neater ?

As usual, I'm happy to read up if I am given some pointers.

I just want to make sure I use the best or most effective technique to skin the proverbial cat.

Thanks

• Always a sinus or configurable for other functions ? – lemon Feb 9 '17 at 15:32
• @lemon : Always a sine wave - I don't need a solution that is flexible for other math functions. I am animating a physics illustration - where a sphere expands and contracts, with radius = sine(time). So the graph required is a math plot to explain the radius expansion and contraction cycle. – TaoRich Feb 9 '17 at 15:38
• So you just need to shift left or right a static texture (with sinus on it) along time ? By shift, I mean shift the UV coordinates – lemon Feb 9 '17 at 15:41
• Yes - that pretty much sums it up - provided that I find a way to only show what is necessary in the graph frame, and hide/mask the rest of the static that is outside of the desired view. – TaoRich Feb 9 '17 at 15:44
• I wont have time to write an answer but this is basically what you need to have UV Warp modifier youtube.com/watch?v=PnF6XdmNhCs. For the dot, make so the dot movement leads the warping of the UV. – lemon Feb 9 '17 at 15:50

UV Warp modifier (first approach) shifts, scales or rotates the UV map of an object depending of the relative positions, scales or rotations of 2 other objects (generally, you can use empties for these two objects).

So here, if we move one empty, the UV map shifts and so the texture of the plane looks like it was moving.

Here is the setup :

• Create two empties : place one of them on X=0 (that will be easier later) and the second one elsewhere
• Add the UV Warp modifier to you plane, like this :

And here is the setup of the plane material :

• UV unwrap the plane and adjust the UV map to the sinusoid shape on the texture
• Use this texture to mix two shaders : one for the red line and the other one for transparency

The transparency is need to show some grid behind the curve when rendered :

At this step, you can move one of the empty and see that the curve seems to move on the plane.

Now the red dot :

• Create the dot (a plain circle for instance)
• Place it on the border of the plane
• Add a driver to its Y position
• The driver need to be dependent on the X position of the empty, and to follow a sinus function

As the UV map is 0 to 1, the UV map shifts of 1 when the empty moves of 1 unit. So we need to multiply the X value by 2 PI.

The setup is the following (can be seen in the graph editor, in drivers editing context) :

Edit : another approach You can also set up Cycles nodes to draw the curve directly. The main interest here, there is no need of a "static" texture.

Here is an example, made rapidly and so to enhance (using more calculation via drivers, instead of doing it with nodes, surely).

The principle is the following (quickly described) :

• Add a keyframe to an input value (to define the speed of the curve)
• Use it in the node editor to calculate where the sinus is depending on this value
• Use the result on a mix shader node to output red or white, and so draw the curve

Here is this second blend file :

This is to enhance : more calculations need to be done outside of the nodes (using drivers probably), so that math expressions are more accurate and the nodes setup simplified.

• Thank you for all the effort - a clear and detailed answer. I will look at both approaches today; learn and understand some new techniques. I think my final solution may very well be a combination of the two - First approach: UV Warp modifier to move a static texture for the graphing background. Another approach: Cycles nodes to draw the sinus. When I have made progress I'll report back with an edit, and tick your answer as my accepted solution. – TaoRich Feb 10 '17 at 8:16
• I've got your sinus.blend open in one Blender instance, and am trying to recreate it myself from scratch in another Blender instance. I'm getting stuck at assigning the material=curve and the texture=tex When I add a material I see these properties [Surface][Wire][Volume][Halo] which I don't see in your sinus.blend. I've spent an hour on this and just don't seem to know enough to work out what to do. I'm quite new Blender and this is my first attempt to use textures - so there's obviously a gap in my understanding or knowledge. – TaoRich Feb 19 '17 at 11:51
• Hi. I don't get what you mean above. Which approach are you attempting to do? And... my setting are Cycles settings and [Surface][Wire][Volume][Halo] are for Blender Internal. But for the first approach the principle is the same for both renderers – lemon Feb 19 '17 at 12:00
• Hi & thanks. Working on UV Warp modifier (first approach). Started with default (empty) .blend. First, I created the 2 empties empty.static and empty.move then added the location transformation for empty.move to emulate your sample. I then added the plane and its UV Modifier From:empty.move & To:empty.static and the behaviour follows what your sample does. I have the plane selected and chose data properties Material & add new material which I named curve`. That's where the material data property options differ. [screenshots] (pasteall.org/pic/index.php?id=112713) – TaoRich Feb 19 '17 at 13:07
• After taking a break to clear my head, I've gone back to basics and am reading up on how to add an image to a plane, and will come back at the problem with some more understanding. Appreciate the help - really didn't mean to bug you for step-by-step hand holding. – TaoRich Feb 19 '17 at 13:13

Another way of doing this task is to use F-Curve Sine Modifier.

1. Create a cube and scale it down to your needs. Apply the scale.
2. Insert a location keyframe at frame 0
3. Go to frame 100 and move the cube on the x axis about 10 units and add another location keyframe.
4. Now go in Graph Editor and delete the Y location channel and leave X and Z Location channels.
5. Select the X Location channel and execute Channel-> Extrapolation Mode -> Linear Extrapolation.
6. Select Z Location channel and go in Properties-> Modifiers Tab.
7. Choose Add Modifier -> Built-In Function and Select Sine.
8. Adjust the parameters of the Sine modifier as needed. For example: Amplitude 2.5; Phase Multiplier: 0.1; Phase Offset: -0.1
9. Create a vertex inside the Cube. For example: In edit mode select all vertices then Shift+D to duplicate and Alt+M-> At Center to merge the duplicates into one vertex. Still selected that vertex - press Ctrl+G to add it in a vertex group.
10. Add particle system to the cube, that should emit from vertices and from vertex group that you've just created - see the attached file.
11. Subdivide (Subsurf Modifier) the cube to make it more rounder.
12. Add material to the cube and particles - A halo material will suffice - see the attached file.
13. Finally Make the camera look at the cube and create a Copy Location constraint to it so that the camera should follow th X location of the cube with offset.

This short description took longer than making the solution :)

The blend file:

And Simplified Version if there is no need of Sine accuracy. Simple Sphere and Cylinder animated with Sine like Bezier Curve as constraint and modifier:

• Ooh, I like this one, super simple. – 3pointedit Jun 19 '17 at 22:42
• @3pointedit There is even simpler if you don't insist much on precision. Just Create a Bezier Curve and shape it as closely to sine curve as possible. Then Add it to the Sphere as Clamp To constraint. Also create a Cylinder object with lots of horizontal loops and add Curve Modifier to it using the sine curve as deforming object. Moving the Sphere and the Cylinder will create similar motion tho the given above. – Rumen Belev Jun 21 '17 at 14:15
• Needs to be a proper answer with illustrations or it never happened Rumen ;-) – 3pointedit Jun 21 '17 at 20:42
• @3pointedit I know :) But I'll be glad if somebody finds it useful by reading and exploring the blend files. I don't like visual learning too much - it makes the brain lazy. – Rumen Belev Jun 22 '17 at 7:56
• @RumenBelev : Thanks for this alternative approach. I did manage to solve my requirement using lemon's UVWarp solution which I accepted as my preferred answer. I need a fairly precise illustration for a physics animation - four different fundamental sine waves are superposed to produce a composite model. I will try to explore your suggestion when I have some time ... always good to learn ! – TaoRich Jul 13 '17 at 12:16

You could also do this mechanically so to speak. Remember to use an Ortho camera to eliminate distortion.

Make a rotating vertex object and spawn particles from it. More particles = smoother drawn line.

Create a plane then shrink all vertices to 0 and Remove Duplicate vertices. Off set this vertex by 1 Unit in the Y direction, make sure that the vertex is selected when you leave edit mode. This will be the Tracer.

Create a Sphere object, add a colored emission material (red), then select it followed by the Tracer. Parent by Vertex. Offset the object by -1 Y units to line up with the Tracer Vertex.

Select the Tracer object Go to the first frame and set a rotation keyframe at 0.0, move 1 second and rotate the object around the X axis 180deg, make another keyframe. In the F-curve window select the rotation curve and set it to Linear Extrapolation with a Cycle modifier.

Then add a Particle modifier. Set it to emit 2000 particles from the -X direction at value 1.0 and turn of Field Gravity (set to 0). Select the Red sphere object as Render Object.

Now particles will stream away in a sine wave.

Create a plane and scale it to fill the screen. Apply a Simple Subdivide modifier to split into a grid. Add an array modifier to expand the grid coverage across the screen. Apply a Displace modifier, set Direction to X and keyframe it's strength to 0.0 at the first frame, then -1.0 a second later.

Go to the modifiers F-curve and apply a cycle modifier, this will make the grid appear to travel right to left for ever.

Add a Wireframe modifier and change the thickness to taste.

• Same thanks as above ... I did manage to solve my requirement using lemon's UVWarp solution which I accepted as my preferred answer. I need a fairly precise illustration for a physics animation - four different fundamental sine waves are superposed to produce a composite model. I will try to explore your suggestion when I have some time ... always good to learn ! – TaoRich Jul 13 '17 at 12:18
• Damn, I also see that I got the period wrong based on your example. Drat – 3pointedit Jul 14 '17 at 3:23