offsetting start time of pendulum

Moderators: Disciple, zlovatt

Post Reply
jetcityj
Posts: 2
Joined: July 7th, 2006, 10:03 am

I was wondering how to go about offsetting the start time of D. Ebbert's Pendulum expression.
Currently it starts at the beginning of the comp, even if the layer begins later in the comp.

Code: Select all

veloc = 7; 
amplitude = 80; 
decay = .7;
 
amplitude*Math.sin(veloc*time)/Math.exp(decay*time)
Thanks for the help!
Dan Ebberts
Posts: 320
Joined: June 26th, 2004, 10:01 am
Location: Folsom, CA
Contact:

Try this:

veloc = 7;
amplitude = 80;
decay = .7;

t = time - inPoint;
amplitude*Math.sin(veloc*t)/Math.exp(decay*t)


Dan
jetcityj
Posts: 2
Joined: July 7th, 2006, 10:03 am

Thanks Dan!

Works perfect.
mljohn
Posts: 4
Joined: July 29th, 2008, 1:02 pm

Here's what I'm trying to do, and the above solution isn't working for me.

I have a still image that I have some type hanging underneath (both 3D layers). I'm trying to use this expression on the type (x axis only) so that when I move the still (I'm trying to do this all in a precomp and then put it in my main comp and time it all out properly) the type swings with the expression. My problem is the still will move 3 or 4 times. My plan of attack is to apply the expression to a series of nulls. The offset described above doesn't seem to work with the null. If I slide the first null 2 sec. in, it gets really crazy until the layer starts. Then add two more on top of that and it just get useless.

I could be there's a better way to go about what I want to do, but being newish to expression I thought I would try to use ones that already exist. Any help would be great.......


Mark Johnson
kobyg
Posts: 128
Joined: December 7th, 2007, 10:11 am

If you want to repaet the bounce movement at specific times,
you could try this:

Code: Select all

my_times = [1, 5, 9.5];

veloc = 7; 
amplitude = 80; 
decay = .7;

inTime = -500;
for (i=0; i<my_times.length; i++){
   if (time>=my_times[i])
   inTime = my_times[i];
}

t = time - inTime;
amplitude*Math.sin(veloc*t)/Math.exp(decay*t);

Just write in the "my_times" array (at the begining of the expression) the times you want the pendulum movement to begin, in an ascending order.
You can write as many values as you want.

It is also possible to triger the bounce motion automaticaly by using a threshold on the velocity, using a more sophisticated expressions.
But if you only want the bounce movement at a few constant points in time, this expression would be enough.

Koby.
mljohn
Posts: 4
Joined: July 29th, 2008, 1:02 pm

That did the trick. Thanks.

The idea of using different nulls was so that I could vary the swinging, so the move didn't look the same every time. But I can put this on the different nulls also, and it's working like a champ. My next task is to work on triggering via the threshold of the velocity. But one step at a time.......


Thanks again.
kobyg
Posts: 128
Joined: December 7th, 2007, 10:11 am

If you want to use a threshold on the velocity, check out first Dan Ebberts's page:
http://www.motionscript.com/design-guid ... igger.html

If you want to tweak the last expression, so you will have different amplitude at each bounce, you could use:

Code: Select all

my_times = [1, 5, 9.5];
my_amp   = [80, 40, 60];

veloc = 7; 
//amplitude = 80; 
decay = .7;

inTime = -500;
for (i=0; i<my_times.length; i++){
   if (time>=my_times[i]){
      inTime = my_times[i];
      amplitude = my_amp[i]; 
   }
}

t = time - inTime;
amplitude*Math.sin(veloc*t)/Math.exp(decay*t);
In the "my_amp" array write the corresponding desired amplitudes of each bounce time.
mljohn
Posts: 4
Joined: July 29th, 2008, 1:02 pm

If you haven't guessed by now, I don't know a lot about scripting. But there is something in last expression that keeps crashing AE. The one before had no problem. I can't quite figure out why because it crashed before it tells me what it doesn't like about the expression..


Mark
User avatar
lloydalvarez
Enhancement master
Posts: 460
Joined: June 17th, 2004, 9:27 am
Location: New York City, NY
Contact:

try this:

Code: Select all

my_times = [1, 5, 9.5];
my_amp   = [80, 40, 60];

veloc = 7; 
amplitude = my_amp[0]; 
decay = .7;

inTime = -500;
for (i=0; i<my_times.length; i++){
   if (time>=my_times[i]){
      inTime = my_times[i];
      amplitude = my_amp[i]; 
   }
}

t = time - inTime;
amplitude*Math.sin(veloc*t)/Math.exp(decay*t);

-Lloyd
mljohn
Posts: 4
Joined: July 29th, 2008, 1:02 pm

that did it.......Thanks!
Post Reply