FORUMS: list search recent posts

Store the time at which a variable reaches a value

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Xavier Gomez
Store the time at which a variable reaches a value
on Oct 13, 2011 at 12:04:30 pm

Hello,

I would like to store the time of the comp at which a certain quantity reaches a given value for the first time.

I bet it is pretty elementary but, well, i'm still a beginner (I did search the Adobe After Effects Expressions forum).


Return to posts index

Dan Ebberts
Re: Store the time at which a variable reaches a value
on Oct 13, 2011 at 2:33:28 pm

Exprssions can't "store" anything. All they can do is set the value of the property hosting the expression. To do what you want to do, your expression will have to look at the property's value starting at time = 0, frame by frame, until it finds the first frame where the value reaches your target value.


Dan



Return to posts index

Xavier Gomez
Re: Store the time at which a variable reaches a value
on Oct 13, 2011 at 4:29:55 pm

Ok, i'll put it differently.

The main layer's position is given by transform.position + Delta-pos(the exact form of the expression Delta-pos is irrelevant here). But,
(1) i want it to be zero until something happens in some other layer
(a quantity, say k, reaches a threshhold value, say k_threshhold);
(2) after that i only know the expression of Delta-pos in local time (time-T) for time>T, where T is the time at which the threshhold was reached. But,... i dont know T ! and i dont know how to tell AE what is the value of T.


Return to posts index


Dan Ebberts
Re: Store the time at which a variable reaches a value
on Oct 13, 2011 at 4:40:53 pm

Like I said, you'll need to do a frame-by-frame search for the threshold crossing. It will be something like this (not tested):


k_threshold = 10;
P = (whatever property you're monitoring);
trig = false;
for (f = 0; f <= timeToFrames(); f++){
T = framesToTime(f);
if (P.valueAtTime(T) > k_threshold){
trig = true;
break;
}
if (trig){
(do something with T)
}else{
0
}



Dan



Return to posts index

Xavier Gomez
Re: Store the time at which a variable reaches a value
on Oct 13, 2011 at 5:47:40 pm

Thank you, working !

I am still wondering about optimization: this time T either doesnt exist (the threshold is never reached), either is unique (since it is the FIRST time the threshold is reached). So ideally it should be computed only once for the whole composition, and not at each frame.


Return to posts index

Dan Ebberts
Re: Store the time at which a variable reaches a value
on Oct 13, 2011 at 6:22:15 pm

Expressions can't store any data for use at later frames. So at each frame, it has to again search for a threshold crossing.

Dan



Return to posts index

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