FORUMS: list search recent posts

# Calculating speed during deceleration

FAQ   •   VIEW ALL
 Calculating speed during deceleration on Oct 20, 2017 at 7:05:02 am

Hey everyone. I should have paid more attention in math class. This project has been a doozy.

Using expressions, I'm trying to make a speed counter that says the mph at a given time (time being a value I'm defining, not the actual time of the comp) where my speed is decelerating from 55mph to 0 over the course of 5 or so seconds.

I have all of the variables and just need to figure out how to work the expression/equation.

I know: Speed = Distance /Time which gives me the average for the whole distance but not the speed at a specific moment.

There's also the equation A= (V^2-U^2)/2*S
Where:
A= Rate of Deceleration
V=Final Velocity (0)
U= initial velocity (55mph)
S=Distance covered

In the rig all of these variables are adjustable to update the results.

I tried the if/else pointA, pointB approaches but I worry they wont be accurate enough . I think I'll end up using this rig like a calculator to plug in variables to find answers while also Driving the animation. Like knowing how much distance was traveled over the amount of time it takes the vehicle to stop. The time it takes to stop is part of the data I can plug in (Luckily it stops linearly).

I am actually moving a null accross the screen at x number of pixels per (keyframed)second. At a point the null begins to slow down. There are 3 counters tied to it via expressions, being: Time, Speed, Distance. Currently the counter for speed is the only one I don't have working yet. I will be adding more later though and some of those will get even trickier.

Thanks!

 Re: Calculating speed during decelerationon Oct 20, 2017 at 9:47:08 am

I'm not sure I understand what you're ultimately trying to achieve, but if you're looking to measure the speed and acceleration of a layer in your scene, this should help.

After Effects can tell you the speed of a moving layer with a built-in expression:
`thisComp.layer("Object").transform.position.speed`

Since acceleration is a change in speed over time, we can represent the formula this way:

accel = (speed2 - speed1) / (time2 - time1)

To calculate the acceleration from the previous frame to the current frame, we could use this expression:
`accel = ( thisComp.layer("Object").transform.position.speed - thisComp.layer("Object").transform.position.speedAtTime(time-thisComp.frameDuration) ) / thisComp.frameDuration;`

Quick sample project:
11778_speedacceleration.aep.zip

If you're trying to do something else, please provide more information and I'm sure someone can help.

Walter Soyka