Page 1 of 1

offsetting start time of pendulum

Posted: June 24th, 2008, 12:59 pm
by jetcityj
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!

Re: offsetting start time of pendulum

Posted: June 24th, 2008, 1:03 pm
by Dan Ebberts
Try this:

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

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


Dan

Re: offsetting start time of pendulum

Posted: June 24th, 2008, 1:49 pm
by jetcityj
Thanks Dan!

Works perfect.

Re: offsetting start time of pendulum

Posted: July 30th, 2008, 6:08 am
by mljohn
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

Re: offsetting start time of pendulum

Posted: July 31st, 2008, 4:25 am
by kobyg
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.

Re: offsetting start time of pendulum

Posted: July 31st, 2008, 6:15 am
by mljohn
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.

Re: offsetting start time of pendulum

Posted: July 31st, 2008, 6:43 am
by kobyg
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.

Re: offsetting start time of pendulum

Posted: July 31st, 2008, 8:51 am
by mljohn
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

Re: offsetting start time of pendulum

Posted: July 31st, 2008, 9:34 am
by lloydalvarez
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

Re: offsetting start time of pendulum

Posted: July 31st, 2008, 10:48 am
by mljohn
that did it.......Thanks!