FORUMS: list search recent posts

Undertanding property speed

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Miguel de Mendoza
Undertanding property speed
on Sep 19, 2016 at 1:41:39 pm
Last Edited By Miguel de Mendoza on Sep 19, 2016 at 1:42:23 pm

HI, I'm working on gear system simulation. I have some comps that are gears with diferent teeth number.
Each gear rotation is driven by a driver gear rotation speed. I have a master gear that rotates at constant speed, and in the other gears I have this expression:

driver = effect("Driver")("Layer");
nSplit =driver .name.split("_");
driverTeeth = nSplit[nSplit.length -1];
nSplit = name.split("_");
selfTeeth = nSplit[nSplit.length -1];
dSpeed = driver .transform.rotation.speed;
transmision = driverTeeth/selfTeeth;
dir = (driver.effect("Reversed")("Checkbox").value)? -1 : 1;
time * transmision *dSpeed * dir + value


Here is a screenshot of the layers:

Each gear is driven by the below gear layer.
With the 2 and 3 gears, it works fine, but the gear 3 speed is returning extreme changing values like -1087, 56, 523... so the gear 4 makes very fast wiggly rotations. Someone can figure out wy is this happening?


Return to posts index

Xavier Gomez
Re: Undertanding property speed
on Sep 19, 2016 at 3:40:15 pm

Hi Miguel,
i tried and observed the same starting from third child.
It seems that AE needs some guiding otherwise it gets lost.
This expression seems to work fine:

curLayer = thisLayer;
multiplier = 1;
n=0;
do{
try {
driver = curLayer.effect("Driver")("Layer");
multiplier *= - driver.name.split("_")[1]/curLayer.name.split("_")[1];
curLayer = driver;
++n;
}
catch(e){driver = null;};
}while(driver!=null);
if (n===0) value else {
leadRot = curLayer.rotation;
thisLayer.rotation.valueAtTime(inPoint)-leadRot.valueAtTime(inPoint) + multiplier* (leadRot.value-leadRot.valueAtTime(inPoint));
};


Xavier

Xavier


Return to posts index

Xavier Gomez
Re: Undertanding property speed
on Sep 19, 2016 at 3:44:46 pm

Hum, just realized that the expression works because i didnt put a Layer Control on the leading gear.
If you put one, you'll get an infinite loop and a time out error.
It would be better to change the break condition to :

while(driver!=null && driver.name!==curLayer.name)


Return to posts index


Miguel de Mendoza
Re: Undertanding property speed
on Sep 19, 2016 at 5:35:57 pm

I Works for me like the first example. But I found another problema for the setup. I'm controling the speed of the lead gear with this expression:

thisComp.layer("Controls").effect("Master_Speed")("Slider") * time


Because I'm triggering the speed of the driver when I increase the speed of the Master_Speed with keyframes, the gears go so fast. So I need to implement an acceleration formula to the expression. I have the formula for acceleration:

deltaTime = 1/25;
iv = thisComp.layer("gear_5").transform.rotation.speedAtTime(time - deltaTime ); //Initial velocity
fv = thisComp.layer("gear_5").transform.rotation.speed; //Final velocity
(iv - fv)/dT


But I don't know how to implement it on the expression. Any Idea?


Return to posts index

Miguel de Mendoza
Re: Undertanding property speed
on Sep 20, 2016 at 9:15:16 am

Finally I found a simplest way to make all the teeth fint on the gears while moving. Simply I multiply the transmisiĆ³n by the position of the driver:

driver = effect("Driver")("Layer");
nSplit =driver .name.split("_");
driverTeeth = nSplit[nSplit.length -1];
nSplit = name.split("_");
selfTeeth = nSplit[nSplit.length -1];
dSpeed = driver .transform.rotation;//.speed;
transmision = driverTeeth/selfTeeth;
dir = (driver.effect("Reversed")("Checkbox").value)? -1 : 1;
transmision *dSpeed * dir + value


It works for all the gears. I still have the problem with the acceleration. My Master gear rotation is driven by the expression :

thisComp.layer("Controls").effect("Master_Speed")("Slider") * time

But when I add keyframes to the slider to increase the speed, the gear start to rotate very fast till the interpolation ends. Is posible to get an incremental amount of the speed with keyframes on the slider?


Return to posts index

Xavier Gomez
Re: Undertanding property speed
on Sep 21, 2016 at 6:43:47 am

If the leading gear is driven by a speed slider, you should use for that gear an expression as explained in Dan's website http://motionscript.com/articles/speed-control.html

For all other gears, i think that the expression i posted will work.

For these gears, you dont need a "inverse" checkbox, since a gear necesserily rotates the way opposite to its "parent".
And the expression for these gears should not mention a "speed" variable either, otherwise you'll need to integrate that speed, which can be super slow, and not necessary. (Overall, the rotation variation is a multiple of the rotation variation of the leader rotation, and that multiple is only determined by size ratios).

Xavier


Return to posts index


Miguel de Mendoza
Re: Undertanding property speed
on Sep 21, 2016 at 10:04:59 am

Thanks Xavier, that was one of those posts that I read time ago and I forget XD. Pretty usefull!


Return to posts index

Miguel de Mendoza
Re: Undertanding property speed
on Sep 19, 2016 at 5:03:17 pm

Thanks Xavier, it works perfect! Yes, it seems some stacking expression problem.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]