Return-Path: Received: from mail-ea0-f181.google.com ([209.85.215.181] verified) by media-motion.tv (CommuniGate Pro SMTP 4.2.10) with ESMTP-TLS id 5002724 for AE-List@media-motion.tv; Thu, 14 Mar 2013 03:19:09 +0100 Received: by mail-ea0-f181.google.com with SMTP id z10so717271ead.26 for ; Wed, 13 Mar 2013 19:26:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:content-type; bh=KQWN+wcsBCMFBU6hi0L9OYJZAmqGwG67/6ga9OWYpx8=; b=Sv3CkWyJ7u//rivSm9p4hSbm+rkzXRGEPmULI4B0jNt0FdWAhG3ZWcuwN09u/2004D mlXXD8vMqo5VlQuvJ4Wu/lNBdSnnGp7nrB8qgBTobgJvS7hCNA6L2Vs3BeAT7FL3Qx07 OeeJJ4RrVr1CSP5GpKu7ObcPWJME0x34N9FQXJc2Hu0XfkxeOWTIk5mqw/1wpqZ1eB0a 5J+oEXHQybeW6RxlbkZ7Tcncb/2qZMb7nlsEHIs9Vyu15LuGtf0H8bsXsbbEMlx0gvQP TiPX8gxWFkuAqIbymis2QyLJSuk9DKgk0Iy1JPHMzjJIWjGFmM66Sd9fTAyTcwBGxNxw qw8A== X-Received: by 10.14.0.73 with SMTP id 49mr1878072eea.21.1363227971546; Wed, 13 Mar 2013 19:26:11 -0700 (PDT) MIME-Version: 1.0 Received: by 10.223.41.13 with HTTP; Wed, 13 Mar 2013 19:25:51 -0700 (PDT) In-Reply-To: References: From: Bruce Wainer Date: Wed, 13 Mar 2013 22:25:51 -0400 Message-ID: Subject: Re: [AE] Divide by Zero Errors... To: After Effects Mail List Content-Type: multipart/alternative; boundary=047d7b60525efe1d5104d7d93e06 --047d7b60525efe1d5104d7d93e06 Content-Type: text/plain; charset=ISO-8859-1 I'm glad you got it to work. On my end, no matter what I do I can't cause a divide by zero error to occur. Odd. Bruce On Wed, Mar 13, 2013 at 10:22 PM, Andrew Embury wrote: > Didn't seem to work, however, I think I found the problem. > > I adjusted the "decay = 12.0;" to "decay = 6.0" and it seemed to fix > everything... > > > On Wed, Mar 13, 2013 at 10:09 PM, Bruce Wainer wrote: > >> Well for now just replace it with a dummy value, like 10 or 5 or 54321. >> We have to see if that makes the errors go away. After we determine whether >> or not "Math.exp(decay*t)" is causing the errors, then we can put it back >> in and make the errors go away. You just can't fix a problem before you >> determine where the problem is. >> >> Bruce >> >> >> On Wed, Mar 13, 2013 at 10:06 PM, Andrew Embury wrote: >> >>> 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 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 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. >>>>> >>>>> Any help would be greatly appreciated. >>>>> >>>>> Thank you. >>>>> >>>>> - Andrew >>>>> >>>> >>>> >>> >> > --047d7b60525efe1d5104d7d93e06 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
I'm glad you got it to work. On my end, no matter= what I do I can't cause a divide by zero error to occur. Odd.

<= /div>Bruce


On Wed, Mar 13, 2013 at 10:22 PM, Andrew Embury <aembury@gmail.com>= wrote:
Didn't seem to work, however, I think I found the prob= lem.

I adjusted the "decay =3D 12.0;" to "= ;decay =3D 6.0" and it seemed to fix everything...


On Wed, Mar 13, 2013 at 10:09 PM, Bruce = Wainer <brwainer@gmail.com> wrote:
Well for now just replace it with a dummy value, like= 10 or 5 or 54321. We have to see if that makes the errors go away. After w= e determine whether or not "Math.exp(decay*t)" is causing the err= ors, then we can put it back in and make the errors go away. You just can&#= 39;t fix a problem before you determine where the problem is.

Bruce
<= div>


On Wed, Mar 13, 2013 at 10:00 PM, Bruce = Wainer <brwainer@gmail.com> wrote:
Andrew,

The onl= y thing I can think of is that the Math.exp() method is returning 0 or infi= nity 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 ei= ther 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 som= ething 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 var= iable. The only solution would be to protect that code by creating a variab= le 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 mor= e Java, PHP, and SQL lately than Javascript (which the After Effects expres= sion engine is based on). Oh the joys of being a Media Arts and Telecommuni= cations dual major.

Bruce Wainer


On We= d, 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 =3D .03;
freq =3D 4.0;
decay =3D 12.0;
n = =3D 0;
if (numKeys > 0){
n =3D nearestKey(time).inde= x;
if (key(n).time > time){
n--;
}}
<= div>if (n =3D=3D 0){ t =3D 0;
}else{
t =3D time - key(n).time;
}
if (n= > 0){
v =3D velocityAtTime(key(n).time - thisComp.frameDurati= on/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 lif= e with AE.

Currently working with CS6 and I am app= lying this expression to Scale, Position, and Rotation.

Any help would be greatly appreciated.

Thank you.

= - Andrew





--047d7b60525efe1d5104d7d93e06--