Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions HowTo: Expression Angle Control dictates the Position of a Null

  • HowTo: Expression Angle Control dictates the Position of a Null

    Posted by Roland R. kahlenberg on October 11, 2013 at 3:21 am

    As the Subject Title says BUT with an additional requirement – the Null can only move along the perimeter/edge of the Comp.

    Cheers
    RoRK

    Intensive mocha & AE Training in Singapore and Other Dangerous Locations

    Imagineer Systems (mocha) Certified Instructor
    & Adobe After Effects CS6 ACE/ACI

    Madli Man replied 12 years, 5 months ago 3 Members · 3 Replies
  • 3 Replies
  • Dan Ebberts

    October 12, 2013 at 11:11 pm

    This is probably too late to help, but I finally found enough time to work this one out.


    a = effect("Angle Control")("Angle")%360;
    if (a < 0) a += 360;
    ar = degreesToRadians(a);
    w = thisComp.width;
    h = thisComp.height;
    g = Math.atan2(h,w);

    if ((ar > Math.PI*2 - g) || (ar <= g)){
    x = w;
    y = (h + w*Math.tan(ar))/2

    }else if ((ar > g) && (ar <= Math.PI - g)){
    x = (w - h*Math.tan(ar - Math.PI/2))/2;
    y = h;
    }else if ((ar > Math.PI - g) && (ar <= Math.PI + g)){
    x = 0;
    y = (h - w*Math.tan(ar - Math.PI))/2;
    }else{
    x = (w + h*Math.tan(ar - 3*Math.PI/2))/2;
    y = 0;
    }
    [x,y]

    Dan

  • Roland R. kahlenberg

    October 14, 2013 at 2:56 am

    Thanks Dan! This worked wonderfully!

    Cheers
    RoRK

    Intensive mocha & AE Training in Singapore and Other Dangerous Locations

    Imagineer Systems (mocha) Certified Instructor
    & Adobe After Effects CS6 ACE/ACI

  • Madli Man

    November 25, 2013 at 10:06 am

    Hi Dan,

    Just found this thread. This is something i wanted to do long time ago. havent found the trick. 😛

    I have situation here:
    I found this code: that calculate degrees from position.velocity. I use linear to animate position. how can i merge this code to make animated current position to angle control? something like direction.

    Thanks
    Mad

    v = position - position.valueAtTime(time-thisComp.frameDuration);
    radiansToDegrees(Math.atan2(v[1],v[0]))

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