• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Linear expression applied to a path

New Here ,
Jul 17, 2020 Jul 17, 2020

Copy link to clipboard

Copied

Does anyone know if you can use the linear function to deform a path?

In below, the triangle goes from left to right, but its path deforms slightly.

If the triangle was moving to the right from a position of (0,0) to (100,0) ...I thought of using something like this in the Path property expression:

A=path.key(1)
B=path.key(2)

linear(position, 0, 100, A, B)

But it doesnt work because path is not an array, it's a path object. I tried using pointonpath but to no avail.

109833801_3338217656198960_1279290171218672409_n.jpg

TOPICS
Expressions

Views

944

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 17, 2020 Jul 17, 2020

Copy link to clipboard

Copied

I am confused. Are you trying to control the speed of the position change or the shape of the path? 

 

Custom speed changes are easiest to create using the Graph editor set to edit the Speed Graph. angled lines are acceleration, horizontal lines are constant velocity. It takes a while to get used to understanding what you are looking at and the AutoBezier tool is more useful than the easy ease. If you are a real math whiz you can also use the Temporal Keyframe Interpolation panel.

 

Here's a first draft of a tutorial series that I'm going to release soon. It's only fair, but maybe it will give you some ideas on how to control both the path using the pen tool and the Comp Panel and control the speed of an animation using the Graph Editor.

Rick_Gerard_0-1595032725662.gif

If you did break your expression into an interpolation method you would have to break out the values in the array for key(1) and key(2) then use a separate linear method for both. All that would do is give you a constant speed between keyframes, but that's what you already have. 

 

It's an interesting idea, but not too practical. 

 

If you want to do things like bounce to a stop or simulate gravity the interpolation method gets a lot more complicated than a simple expression. For example, this expression will launch a layer from it's starting position at an angle of 75º, and there are going to be 9 bounces.  I have about 200 of these expressions with expression controls in my Custom Presets folder. I use them all the time. Most of them are, like this one, based on layer in-point or out-point or both. Some are based on Markers. This allows me to create very complex animations without setting any keyframes.

 

elev = degreesToRadians(75);
v = 2500;
e = .6;
f = .5;
g = 5000;
nMax = 9;
tLaunch = thisLayer.inPoint;
 
vy = v*Math.sin(elev);
vx = v*Math.cos(elev);
if (time >= tLaunch){
  t = time - tLaunch;
  tCur = 0;
  segDur = 2*vy/g;
  tNext = segDur;
  d = 0; // x distance traveled
  nb = 0; // number of bounces
  while (tNext < t && nb <= nMax){
    d += vx*segDur;
    vy *= e;
    vx *= f;
    segDur *= e;
    tCur = tNext;
    tNext += segDur;
    nb++
  }
  if(nb <= nMax){
    delta = t - tCur;
    x = d + delta*vx;
    y = delta*(vy - g*delta/2);
  }else{
    x = d;
    y = 0;
  }
  value + [x,-y]
}else
  value

 

 That gives you a graph like this.

Screenshot_2020-07-17 17.13.51_geikbR.png

You can see both speed and position. If I were editing the motion path manually it would require 9 keyframes, one at each vertical velocity loss point in the timeline, adjusting the path to match the path shown in the comp panel using the pen tool, and a bunch of time. I would only be editing the speed graph and the motion path. The whole animation preset that this position expression comes from also includes and expression for scale that anticipates the launch by squeezing the layer, then distorts it every time it hits the ground again giving me an automated way to greatly improve the effectiveness of this kind of animation while following in the path Ollie Johnson and  Frank Thomas, the real fathers of modern animation. You should invest in their book or at least watch the video:

Rick_Gerard_1-1595032725662.gif

You should also look at Squash and Stretch Pro at AE Scripts. That's another tool I use almost every day and it has save me months of fiddling with keyframes and speed graphs.

 

So, once again, what are you trying to accomplish? 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jul 21, 2020 Jul 21, 2020

Copy link to clipboard

Copied

Rick is right that to do what you are explicitly asking for you would need to interpolated the vertices individually, but, depending what you are trying to accomplish, you might want to consider interpolating the time parameter of the path's valueAtTime() method instead, and letting AE handle the interpolation of the paths based on the timing you specify.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 20, 2020 Oct 20, 2020

Copy link to clipboard

Copied

LATEST

It might be a little late for me to respond, but a way you could do this easily is by:

  • Spacing key 1 and key 2 by a known value (like 1 second) then put them at the very begining of your comp
  • Use fakeTime=linear(Property, InputMin, InputMax, 0, 1)
  • Use valueAtTime(fakeTime)

 

This method should help you circumvent the limitations of linear() when it comes to arrays and paths, all you need is two keyframes which you know the temporal position of

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines