FORUMS: list search recent posts

# Constant speed along one axis. More complex than it seems...

FAQ   •   VIEW ALL
 Constant speed along one axis. More complex than it seems... on Jun 27, 2020 at 1:03:53 pmLast Edited By James Hamilton on Jun 27, 2020 at 6:12:31 pm

Hello

I am trying to replicate an ECG heart monitor that displays cardiac rhythms.

I have an object moving from left to right along a motion path resembling a graph.

As the object travels from left to right it travels up and down the curves, which slows horizontal speed down.

How can the object be made to travel from left to right at a constant speed, regardless of the ups and downs of the motion path?

Here is an image that may help explain: https://ibb.co/FnsRWNH

I'd be super grateful for any suggestions at all!

 Re: Constant speed along one axis. More complex than it seems...on Jun 27, 2020 at 10:02:56 pm

The speed of the object moving along the heart monitor outlines is technically at a constant speed. It just has more ground to cover due to the higher peaks. What you actually would need is increased speed.

An alternative to messing with speed could be to use something like a Light Sweep. You can keyframe the Light Sweep to move across the outlines and have it appear just on the outlines, thereby having it appear on the peaks without needing to "spend time" traveling up the peaks like your box/dot does.

-------------------------------------------------
Video Producer / Digital Marketer / Gear Reviewer / Author
-- http://www.AndyFordVideo.com --

 Re: Constant speed along one axis. More complex than it seems...on Jun 27, 2020 at 10:48:00 pm

Thanks for suggesting your idea. However the dot does need to be a shape object as I need it to look a particular way and a light sweep will not allow for that.

I do understand what you are saying about the fact that the object is technically travelling at a constant speed already, in terms of its XY axes.

However the speed in relation to a particular axis varies. It’s an interesting problem, and deceptively complex. And I have no idea how to solve it.

 Re: Constant speed along one axis. More complex than it seems...on Jun 27, 2020 at 11:22:02 pm

Maybe someone here has a more automatic method to help you, but the old-school way is math. If you know how long you want it to take to go across the screen, then you basically know the speed (in this case, horizontal pixels traveled in a given time). So in your peaks, you need to calculate how much faster to make it move over the small section so that it ends up where it would be if it was a straight path. This is realistic to many heart monitors I've seen, where it draws the big peaks and valleys faster because it moves across the screen at what appears to be a static speed.

-------------------------------------------------
Video Producer / Digital Marketer / Gear Reviewer / Author
-- http://www.AndyFordVideo.com --

 Re: Constant speed along one axis. More complex than it seems...on Jun 28, 2020 at 1:13:02 am

Hi. May not be the quickest/easiest method (?) but... create a vertical stroke/line at the beginning of the graph and keyframe it's X position to travel to the end in the time you need. Now keyframe the object to match the stroke/line's position.

 Re: Constant speed along one axis. More complex than it seems...on Jun 28, 2020 at 11:10:31 am

You might be thinking along the right line...

But I have 5 more graphs to make and I believe a solution exists that could avoid all the key framing, and if a solution is found it’s something that I think could be helpful for people in other projects.

If there was a way to automatically create keyframes at the intersection of two objects (the vertical line and the curve) that would be ideal.

Or, if the moving object could automatically reference the Y value of the curve, but the X value of the moving line.

 Re: Constant speed along one axis. More complex than it seems...on Jun 29, 2020 at 5:38:32 pm

In case anyone else needs a solution to this, enter the below code into the Position property of your keyframed object.

Many thanks to the brain of Filip Vandueren who came up
with this solution.

t1= key(1).time;
t2= key(numKeys).time;

x1=key(1).value[0];
x2=key(numKeys).value[0];

linear_x=linear(time, t1, t2, x1, x2);

precision = 3; // make this higher (16) if you need Motion blur
fd = thisComp.frameDuration/precision;

y=key(1).value[1];

for (t=t1; !(t>t2); t+=fd) {
v=valueAtTime(t);
if (v[0]>=linear_x) {
y=v[1];
break;
}
}

[linear_x,y];