Show speed graph like After Effects

Hello all,

I am wondering if there is a way in Blender to show a derivative graph (f)curve of the speed of an attribute. I have searched the forum, but was unable to find anything about this.

In After Effects, if you right click inside the Graph Editor, you can choose between “Edit Value Graph” and “Edit Speed Graph”. The speed graph really helps understanding the acceleration (or easing) of objects. Therefore I’m looking for a way to show me this info in the Blender Graph Editor.

Using the Animation Nodes add-on (which is amazing!) I already created a speedometer to show me the current speed of an object in km/h. Useful, because I’m animating cars on a highway. But it’s hard to see the slowing down and speeding up of the cars in slopes of the fcurves. Hence my question :smiley:

I did find this post about calculating the derivatives, which touches upon the subject, but does not quite goes as far as I want:

On reddit someone posted the same question, but unfortunately there was no real answer to his question there:
https://www.reddit.com/r/blender/comments/59nr5v/animation_question_how_to_get_a_speed_graph_on/

Hope someone has a genius tip on how to accomplish this!
Thanks!

Hey; PM clock, he may be able to help you

https://blenderartists.org/forum/member.php?233736-clockmender

There was also this old question… Answers to it may be relevant too:

Just read this, I have made a new AN node that lets you accelerate an object up to a given speed. I am a little bit ill at the moment so don’t rush me. I can certainly help you though. What I really need from you is what the Animation actually is, rather than “how do I get an object’s acceleration” if you see what I mean. I think Animation Nodes is the best way to go on this, we may need a new node or a script, I’ll have a think about it.

Cheers, Clock.

Thanks for the replies and suggestions.

@Clock: wonderful you are willing to have a look at it. No rush :slight_smile: hope you feel better soon though!
what the animation is are cars on a highway.
Im animating a scene with quite specific actions, like cars slowing down and overtaking each other on the highway. Im animating them now using keyframes and then reading their speed with animation curves. It works quite well, but sometimes the speeding up or slowing down is hard to see or doesnt feel right, so for thoses cases I raised my question.

I have some questions:

Are the cars using Follow Path, or parented to Armatures/objects with Curve Mods, to move along the roads?

This means they are moving in only one axis (although they are moving in more in the Real World).

Are the cars, just keyframed to specific locations, which could involve movement in multiple axes?

This will drastically alter the way we try to solve this problem - if the answer to 1 is YES and the answer to 2 is NO - that makes life mush easier. :slight_smile:

I did some experimenting using just Animation Nodes and came up with this solution:


And the node tree in more detail:


So - the node tree looks at the object’s location in the current frame, one frame ago and 2 frames ago.

To get speed we need two locations.

To get acceleration we need two speeds.

Hence, I need to know where the object was 1 and 2 frames in the past as well as where it is now - can we agree on this?

To get a speed I find the difference between two locations and multiply this by the blend file’s frame rate - this gives me a speed in units per second, you can easily convert this to Km/h, mph, furlongs per fortnight - whatever you want. I get two speeds from now and one frame ago and 1 and 2 frames ago.

To get the acceleration I subtract the previous speed from the current speed this gives me a positive value for increase in speed and a negative value for decrease in speed. I use the abs() (gives absolute value - always positive) tool to make sure it works when the object is traveling backwards towards 0,0,0 i.e distance is reducing, not increasing, otherwise the speed would be negative…

That is what the node tree above does, but some of the expression nodes might be a pain in the ass to remember, so either a script node, or a new “Clockmender Special” Node will be a better alternative, once we agree on how we proceed. The first image shows the speed and acceleration after 68 frames - I am merely moving the cube from 0,0,0 to 50,0,0 over 100 frames - then come back with a 40 frame gap in the middle. Some of the nodes are driving the two text objects to show rounded speed and acceleration - formula is 'Speed: ’ + str(round(x,3)) - this just rounds the speed to 3 sig figs and makes a string of it, adding this to the string “Speed:” :slight_smile:

I hope I haven’t over explained this, I don’t know how deep your maths knowledge goes. :stuck_out_tongue:

Let me know what you think so far.

Cheers, Clock. :slight_smile:

EDIT:

I think I may have to multiply the given acceleration by the frame rate as well, since we are dealing in units per second per second, but that is just a minor change I will think on before I do anything more, brain is not working at 100% just yet…

Then I took it one stage further, by using a curve to drive a car along: :smiley:


The red on the wheels is so I know they are turning properly…

So I use a curve, then a plane that does not render, this has a curve modifier, I then keyframe some movements along the curve so the plane moves around - but of course I am only keyframing the X axis, so I can use this to determine speed and acceleration. :spin:

The car is then parented to the plane, so it moves with the plane. I also parented the two wheel sets to the plane and made them rotate based upon their diameter and the distance moved by the plane. Then I used some fancy Expression Nodes to make the text you see on the bottom left corner - I hope the maths is right! :rolleyes:

Herewith the node tree:


The Expression nodes do all the maths and make the text strings for the text objects, here is a sample:

str(int(x * 3.6)) + 'km/h @ ' + str(round((y*z),2)) + 'g'

And here is the one that works out the wheel rpm:

'Wheels: ' + str( int(((60 * x) / 0.3) / (2 * pi) )) + ' rpm'

I cannot be bothered to explain it all just now, but if you can’t work it out I will try. I also use the values in the node tree to turn the red dial (speed) and green dial (“g” forces, top dead centre for the needle is 0g) to represent these values as well as showing them in the text. I decided I did not have to multiply the acceleration by fps again, but I am still thinking about it, something seems wrong to me…

Hope all this makes sense! :eyebrowlift2:

Cheers, Clock. :slight_smile:

PS. Dont forget to read the previous post as well.

EDIT:

This is the car still braking as it starts to take the corner; piss-poor driving if you ask me!


EDIT 2:

I must try and wake up! equation for acceleration is a = (v-u)/t where u is initial speed, v is final speed and t is time, since I am measuring the difference in speed over 1/24th of a second (fps rate for the blend file) I must multiply the given “g” force by fps - I am happy now!

wow, what an incredible detailed response :eek: Thanks very much!
I will have a proper good look at it tomorrow when I’m at work and get back to you.

My last mistake was to quote the acceleration as “g” - I had not yet divided the value, which is in m/sec/sec, by 9.81 to convert it to multiples of the Earth’s gravitational constant. So the formula in the Expression Node that does the text should be:

str(int(x * 3.6)) + 'km/h @ ' + str(round((y * z / 9.81),2)) + 'g'

Where x is the speed in m/sec, y is the acceleration in m/sec/sec and z is the blend file frame rate.

I shall be glad once the 'flu has gone and my brain works properly again.

Cheers, Clock. :o

EDIT:

These three new nodes tilt the body, so the front rises when it accelerates and dips when it brakes: :slight_smile:


Ok, I found the time to look at your setup. My math knowledge is good enough to be able to understand your explanation, although some things have sunked deep in my brain :slight_smile: I do rely on the interwebs for finding and explaining the used formulas.

I don’t follow why you would need the gravitational constant for the acceleration, and why you use the earth gravity force, instead of the number I find when I look up ‘gravitational constant’ (https://en.wikipedia.org/wiki/Gravitational_constant). Easy to mix them up, I guess. Earth’s gravity constant is written as ‘g’, the gravitational constant (or Newton’s constant) is written as ‘G’. Again, I’m (re-)learning this now!

But I do understand you want to convert the numbers into a logical values for acceleration. Which is already more detailed then I was trying to find, but is probably sometimes that’s good to take into account when building upon.

Below are screenshots of my setup, in which I did very similar things, including a trick to make the cars rotate when speeding up and slowing down. I’m using the same derivatives, but I ‘hacked’ it with subtract and clamp nodes to push the rotations into a value I was happy with. I look forward seeing your solution though, because my setup was a little jittery (the car rotation jumps slightly from frame to frame).



So I was already using principles you are addressing too. But it seems that my question to plot the acceleration as a curve in the graph editor might be a little wishful thinking within Blender.

Really appreciate your help and explaining additional things like the automatic rotating wheels, which was also something still on my list. Although I’m actually only animating the overall animation of the cars. The secondary animation will be done in Houdini (using similar setups!). It does make me happy to know how to create this in Blender too.

Did I say G or g, I forget now… I mean Earth’s gravity, which is 9.81 m/sec/sec and to all intents and purposes, constant. :eyebrowlift2:

So why have it, well the initial speed is in m/frame - which gets converted to m/sec by multiplying by fps as you say. Difference in speed between two frame widths is speed1 - speed2 again this is m/sec. Acceleration is difference in speed divided by time, so we must subtract the two speeds this gives us m/sec/frame, then multiply by fps to get m/sec/sec. But in order to express this as a “g” factor, like “its 1g acceleration and 2g braking” we must divide the m/sec/sec by 9.81, thus giving us a figure relative the Earth’s gravity.:slight_smile:

Incidentally, to convert m/sec to Km/h just multiply by 3.6. :slight_smile:

Progress, I said that all these fancy Expression Nodes are not good for my ageing memory, so I made a Node to do it, it will be on my GitHub shortly - find link on my website:


This setup does the same as most of the nodes in my previous posts. :eyebrowlift:

So we can then use these to measure two objects, one moving, one rotating, note the torus speed is rad/sec and the acceleration is rad/sec/sec you can use these to work out centripetal forces:


Here is the node tree to do all that along with the four text objects parented to the camera:


The new node does all the tedious work, sets the “sig figs” for the readouts, works in Metric (9.81m/sec/sec) or Imperial (32 ft/sec/sec). It then outputs the three things we want. As for the wheels, the thing to remember is to work in Radians not degrees, a wheel of 1 unit radius travelling forward 1 unit will rotate 1 Radian - brilliant for us. So a wheel of 2 units radius travelling forward 1 unit will rotate 1/2 a Radian and so on. So, if you set the object to rotate it’s moved distance divided by its radius, you get the right answer.

Now to make the info into a curve as the animation progresses would be an interesting exercise wouldn’t it… Maybe this would be better than trying to show the speed/acceleration in the Graph Editor. :spin:

Cheers, Clock.

PS. Let me know if you want my original blend file, I can make it available - the new one uses one of my AN nodes, so you would need the node, along with a heads up of where to put it, as well.

I am on the track here to your curves:


These two lines of vertices are speed and acceleration, I need to learn how to make them into edges… :smiley:

Cheers, Clock. :slight_smile:

I rest my laurels, feeling pleased with myself:


Orange line is speed, yellow is acceleration. :smiley:

Now I need to make it into a node, or add it to the existing new node, but it can wait until tomorrow.

Cheers, Clock. :slight_smile:

Now we have a new node to draw the curves in the 3D view: :eek:


More once I have fully checked it - is this what you want by any chance, you can see three curves there, each taken from the respective outputs of the Object Speed Acceleration Node, the latest is still being constructed. You can see quite clearly the speeds and accelerations at any point in the animation, you have quite a lot of control as to how they are drawn. They consist of just edges, I think this is better for now.

Cheers, Clock. :confused:

EDIT:

I forgot to say that the node switches itself off after processing so it doesn’t repeat the operation every time you run the animation. It also only processes the curves inside the frame range specified so you can just look at a little bit if you like.

in this one I have moved the Keyframe handles to show a different speed graph:


And you could drive this from any input, not just the Speed Acceleration node…

Wow! That is really amazing!! :cool::smiley: Can’t wait to try it out!

btw, I realized I was thinking waaaay to difficult and get your ‘g’ acceleration now (brainfart!).
I would love to see your old Blender file, if your happy to share it. Always best to learn from the work of the master!

Now you have embarrassed me :o

I made this basic curve using the nodes shown, then just extruded the curve to get the shape:


The node on the left is a “Clockmender Special”.

I have sent you a PM by the way…

Cheers, Clock. :slight_smile:

Made this in SEVEN minutes using the new node, beat that by hand! :stuck_out_tongue:


I made all the curves using sine and cosine methods, then just joined and/or extruded them to make the shapes.

I will try to get this on my Github tonight, if I stay awake long enough.

Cheers, Clock. :slight_smile:

work of art!

Thank you!

Both new nodes (Speed Acceleration and Graph Plotter) are now on my GitHub in the latest release (2.0.1) here - also see links in my website along with instructions of how to install my nodes on this page Instructions for the Speed Acceleration on this page Instructions for the Graph Plotter on this page.

Enjoy and if you have any questions, just ask!

Cheers, Clock.

PS. I hope I got the links right, brain still not at 100% yet…

EDIT:

Only tested on Blender 2.79 official release and AN 2.0 official release - I understand AN will not work on build-bot versions.