Mailing List AE-List@media-motion.tv ? Message #48125
From:
Andrew Embury <aembury@gmail.com>
Subject:
Re: [AE] Divide by Zero Errors...
Date:
Wed, 13 Mar 2013 22:06:39 -0400
To:
After Effects Mail List <AE-List@media-motion.tv>
Hey Bruce!
What would I replace "Math.exp(decay*t)" with exactly?
I'm sorry, I'm not very programming minded when it comes to matters such as this. I've dabbled before but those days are far behind me.
Thank you for your time.
- Andrew
On Wed, Mar 13, 2013 at 10:00 PM, Bruce Wainer <brwainer@gmail.com> wrote:
Andrew,
The only thing I can think of is that the Math.exp() method is returning 0 or infinity when a large number is passed in. So if e^(decay*t) is too large of a number, the result becomes 0 or infinity (not sure which it would be but either way division would be impossible). With exponents this is really easy to do, as the numbers get very large very quickly.
Just to test, if you replace the "Math.exp(decay*t)" with something else, do the errors go away? If so you've found the problem code. I think it has to be though because it's the only divisor that is variable. The only solution would be to protect that code by creating a variable to hold that result. If it is 0 or infinity, reassign that variable to a very very large number (preferably the maximum value that the datatype can hold).
Sorry for using general programming terms, I've done much more Java, PHP, and SQL lately than Javascript (which the After Effects expression engine is based on). Oh the joys of being a Media Arts and Telecommunications dual major.
Bruce Wainer
On Wed, Mar 13, 2013 at 8:55 PM, Andrew Embury <aembury@gmail.com> wrote:
Hey guys/ gals!
Quick question....
Whilst animating in AE tonight I was using the following expression:
amp = .03;
freq = 4.0;
decay = 12.0;
n = 0;
if (numKeys > 0){
n = nearestKey(time).index;
if (key(n).time > time){
n--;
}}
if (n == 0){ t = 0;
}else{
t = time - key(n).time;
}
if (n > 0){
v = velocityAtTime(key(n).time - thisComp.frameDuration/10);
value + v*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);
}else{value}
Never ever have I since have encountered so many "Divide by Zero" errors in my life with AE.
Currently working with CS6 and I am applying this expression to Scale, Position, and Rotation.