Page 1 of 1

### Layer markers driving position (compress motion with easing)

Posted: May 24th, 2008, 3:25 am
Inspired by Lloyd Alvarez's recent expressions, I'm trying to create an interactive way to compress position based on sets of markers. Here's the process I'm trying to work through, though not much success with my basic knowledge of iterative loops:

1. start with 2 linear-interpolation position keyframes to indicate start and end position of the layer
2. somewhere between these keyframes, add 4 markers - marker.key(1) and marker.key(4) indicate the positional values where the compression of the motion will take place; marker.key(2).time indicates the new time of marker.key(1).value; marker.key(3).time indicates the new time of marker.key(4).value (see image attached)
3. add easing out at marker.key(2) and easing in at marker.key(3) to create the overall effect of constant velocity -> speed ramp -> constant velocity
4. if there are multiple compressions within the start and end keyframes, perform an iterative check for sets of 4 markers [1,2,3,4] and [5,6,7,8] and remap values accordingly, keeping motion linear outside these sets of 4 markers.

I know this can be done by precomposing and time-remapping, I'd prefer to keep it on one layer and have it done with markers.

markers_ramp.jpg (84.87 KiB) Viewed 9250 times

### Re: Layer markers driving position (compress motion with easing)

Posted: May 24th, 2008, 3:49 am
ps...upon further research, it appears that I may have to go to the scripting route to take advantage of the "setValueAtTime" method - does this sound about right? Thanks, Peter

### Re: Layer markers driving position (compress motion with easing)

Posted: May 27th, 2008, 1:54 pm
Hey Peter,

I can't test this code right now, but it goes something like this:

Code: Select all

``````k1 = marker.key(1).time;
k2 = marker.key(2).time;
k3 = marker.key(3).time;
k4 = marker.key(4).time;

if (time < k1) { value}
if (time >= k1 && time <k2) {linear(time,k1,k2,value,value2)}
if (time >=k2 && time <k3) {ease(time,k2,k3,value2,value3)}
if (time >=k3 && time < k4) {linear(time,k3,k4,value3,value4)}
if (time >= k4) {value4}``````

There's various ways you can build those conditionals but that should give you a general idea of how to get started.

-Lloyd

### Re: Layer markers driving position (compress motion with easing)

Posted: May 27th, 2008, 11:07 pm
Thanks very much Lloyd, I took your suggestion and got this to work:

Code: Select all

``````k1 = marker.key(1).time;
k2 = marker.key(2).time;
k3 = marker.key(3).time;
k4 = marker.key(4).time;

sValue = key(1).value;
eValue = key(2).value;
value1 = position.valueAtTime(k1);
value4 = position.valueAtTime(k4);

if (time < k2) {linear(time,key(1).time,k2,sValue,value1)}
if (time >= k2 && time <= k3) {ease(time,k2,k3,value1,value4)}
if (time > k3) {linear(time,k3,key(2).time,value4,eValue)}
``````
I get a stutter at k2 and k3 if I don't compress the motion by a certain amount, have no idea if that's a limitation of the ease interpolation method or linear to ease interpolation in AE in general.

thanks again for your help, Peter

### Re: Layer markers driving position (compress motion with easing)

Posted: May 28th, 2008, 4:34 am
hmm.. interesting.. what happens if you move the = to the linear part:

Code: Select all

``````if (time <= k2) {linear(time,key(1).time,k2,sValue,value1)}
if (time > k2 && time < k3) {ease(time,k2,k3,value1,value4)}
if (time >= k3) {linear(time,k3,key(2).time,value4,eValue)}``````

### Re: Layer markers driving position (compress motion with easing)

Posted: May 28th, 2008, 6:00 am
Thanks Lloyd, I tried your suggestion, then tried keying it manually, and it seems by default one gets a speed dip when going from linear interpolation to an easing keyframe, expression or no expression.

I had to set the 'ease out' and 'ease in' keys to continuous as well as match the incoming and outgoing speeds.

I don't suppose you know of any way to set speedAtTime or 'continuous' properties for a property - these are read-only, yes?

thanks, Peter
smoothing.jpg (63.57 KiB) Viewed 9155 times

### Re: Layer markers driving position (compress motion with easing)

Posted: May 28th, 2008, 6:15 am
aha! looks like you';ll have to do this:

Code: Select all

``````if (time < k1) { value}
if (time >= k1 && time <k2) {easeOut(time,k1,k2,value,value2)}
if (time >=k2 && time <k3) {ease(time,k2,k3,value2,value3)}
if (time >=k3 && time < k4) {easeIn(time,k3,k4,value3,value4)}
if (time >= k4) {value4}``````
I seem to remember that easeOut and easeIn are reversed in expression to their Animation Assistant counterparts so you might need to flip them if I am wrong..

-Lloyd