Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions A little math help…

  • A little math help…

    Posted by Stephen Reber on September 25, 2009 at 2:41 am

    Hey guys…

    I’m a little stumped here. I am using Math.sin() and want the sine to go from 0 to 1 rather than -1 to 1.

    What I am confused about is that, from what I understand, by the order of operations, both expressions should put out the same result. From what I remember, everything in the parenthesis go first then everything on the outside goes next * / + – in that order. But I get two different results, the first expression gives a result of 0 to 400 and the second expression gives a result of 0 to 1.

    Thanks in advance…

    Stephen =]

    First expression, bad result...

    x = transform.position[0];
    y = 2 / (1+ Math.sin(time * 2 * Math.PI));

    [x, y]

    Second expression, good result

    x = transform.position[0];
    y = (1+ Math.sin(time * 2 * Math.PI)) / 2;

    [x, y]

    Stephen Reber replied 16 years, 7 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    September 25, 2009 at 1:57 pm

    You’re right about the parentheses, but in your first expression you end up with 2 divided by the stuff in parentheses and in the second, it’s the other way around. The order of the operands doesn’t matter for multiplication, but it does for division.

    Dan

  • Stephen Reber

    October 3, 2009 at 4:17 am

    EXCELLENT!

    Thanks Dan =]

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy