Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions How to find the biggest distance over life?

  • How to find the biggest distance over life?

    Posted by Lord Scales on May 10, 2007 at 12:30 am

    Hi!
    Let’s suppose I have this a camera wiggling the position and a light doing the same and I want to find the largest distance they will have in all the life. I know we can find the distance through length (), but I can’t think in a way to find the biggest value of it in all the Time.
    The objective is to create another method to simulate this, taken form Dan’s site (to make the Lens Flare’s brightness diminish as it moves far away form the camera):

    factor = 150;
    C = thisComp.layer(“Camera 1”);
    L = thisComp.layer(“Light 1”);
    d = length(C.position,L.position);
    d1 = length(C.position,L.position.valueAtTime(0));
    d1/d*factor

    I wanna do something like this
    maxB = 150 //maximum brightness
    minB = 25 //minimum brightness
    C = thisComp.layer(“Camera 1”);
    L = thisComp.layer(“Light 1”);
    dist = length (C.position, L.position);
    maxDist = length (C.position, L.position)…; //here I wanna find the maximum length they will have

    linear (dist, 0, maxDist, maxB, minB)

    I know I can just set a value to maxDist, but it would never be exactly once the camera’s and the light’s position are wiggling.

    Thanks!

    linear (

    Lord Scales

    Dan Ebberts replied 18 years, 12 months ago 2 Members · 5 Replies
  • 5 Replies
  • Dan Ebberts

    May 10, 2007 at 1:53 am

    I don’t think there’s any way short of looping through all the frames. I think I’d apply an expression like this to a slider: (didn’t test this – there may be typos)

    C = thisComp.layer(“Camera 1”);
    L = thisComp.layer(“Light 1”);
    maxDist = 0;
    for (t =0; t <= outPoint; t += thisComp.frameDuration){ maxDist = Math.max(maxDist, length (C.position.valueAtTime(t), L.position.valueAtTime(t))); } maxDist Then convert the expression to keyframes so it doesn't have to calculate every frame. Dan

  • Lord Scales

    May 10, 2007 at 4:01 pm

    Thanks! This works fine!

    But one doubt: t++ I know what it is but t+= what it does?

    Thank you.

    Lord Scales

  • Dan Ebberts

    May 10, 2007 at 4:15 pm

    t += thisComp.frameDuration

    gives the same result as:

    t = t + thisComp.frameDuration

    there are also -=, *=, and /= operators

    Dan

  • Lord Scales

    May 11, 2007 at 12:08 am

    Thanks! I finally got how for () works…

    But if I don’t convert that expression to keyframes, will my work take really more time to render?

    Lord Scales

  • Dan Ebberts

    May 11, 2007 at 3:23 am

    Could be considerable if your comp is long.

    Dan

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