Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Can I simplify this expression?

  • Can I simplify this expression?

    Posted by Lord Scales on April 27, 2007 at 6:14 pm

    Hi!
    Ok, I connected my Source Text to my Text scale.

    To the scale, I applied this:
    x = Math.abs(Math.sin(time)*100);
    y = 100;
    [x, y]

    Until here, no problem.
    But my source text had a lot of numbers after the dot, like: 84,14709848…

    So I applied Math.round(transform.scale[0]) to round it.

    But I wanted to simplify to 84,1 (84,14709848…) and not to 84 (example).

    So I did this:

    scale = transform.scale[0];
    round = Math.round(scale);
    d = (scale – round)*10;
    dII = .1*Math.round (d);
    fin = round + dII;

    fin

    So, scale was the scale of my layer, and in “round” I rounded it (example: 84,14709848 to 84). In “d” I simply subtract scale and round (84,14709848… – 84 = 0,14709848…), to leave only the numbers after the decimal point and I multiplied them by 10 to give them and integer number (so 0,14709848… became 1,4709848…). In “dII” I round my 1,4709848… to 1 and I divided it by 10 (multiply by 0.1) so it became 0.1. So in “fin” I did the round (value in integers) plus the dII (the number with one number after the decimal point) to round 84,14709848 to 84,1.

    And to round 84,14709848 to 84,14 I used this:

    scale = transform.scale[0];
    scale2 = scale*10
    round = Math.round(scale2);
    d = (scale2 – round)*10;
    dII = .1*Math.round (d);
    fin = (round + dII)*.1;

    fin

    So, I have and impression that I can simplify this a lot. Is it possible or am I crazy?

    Thank you,
    Gustavo.

    Dan Ebberts replied 14 years, 6 months ago 3 Members · 5 Replies
  • 5 Replies
  • Dan Ebberts

    April 27, 2007 at 6:54 pm

    You’ll like this 🙂

    transform.scale[0].toFixed(1)

    Dan

  • Lord Scales

    April 27, 2007 at 7:18 pm

    I almost fainted when I saw that, so simple, so easy…

    I didn’t know toFixed till now, it is incredible to simplify numers (not as incredible as you, Dan).

    It is a good think to add in your Expressioneer’s Design Guide, isn’t it?

    Thank you very much!

  • Dan Ebberts

    April 27, 2007 at 7:48 pm

    Yes, thanks for thanks for the suggestion. I’m working on one that uses toFixed();

    Dan

  • Nick Depp

    November 5, 2011 at 6:24 am

    1/1+a^n + 1/1+a^-n

    My attempt:
    =1/1+a^n + 1+a^n/1
    =1+{1+a^n(1+a^n)}/1+a^n
    =1+1+2a^n+a^n^2/1+a^n
    =2+2a^n+a^n^2/1+a^n
    let a^n=m
    =2+2m+2m^2/1+m
    =2(1+m+m^2)/1+m

    I don’t know what to do next, the answer is supposed to be 1.

    will you please simplify the expression its very urgent i tried on many sites but didn’t get the correct answer according to my mathematics textbook.

  • Dan Ebberts

    November 5, 2011 at 8:39 am

    How about this:

    1/(1 + a^n) + 1/(1 + a^-n)
    = ((1 + a^-n) + (1 + a^n))/((1 + a^n)*(1 + a^-n))
    = (2 + a^n + a^-n)/(1 + a^n + a^-n + a^n*a^-n)
    = (2 + a^n + a^-n)/(2 + a^n + a^-n)
    = 1

    Dan

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