Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Rotate a layer to be perpendicular to a path?

  • Rotate a layer to be perpendicular to a path?

    Posted by Riccardo Sinti on July 26, 2013 at 4:45 pm

    I’ve got some layers (people) I’ve linked to a path through an expression so that i can use a slider to position them along the shape of the path but I can’t auto orient them to the path so that they are always standing on the path perpendicular to it.

    Is there an expression that can orient a layer to be perpendicular to a path? Tangents maybe?

    Big thanks as always to the brilliant minds in this forum!

    Riccardo Sinti replied 12 years, 9 months ago 2 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    July 26, 2013 at 5:27 pm

    What’s the expression you’re using to determine the layer’s position?

  • Riccardo Sinti

    July 26, 2013 at 5:43 pm

    I’ve got a pre-comp with the path I’m referencing then on the position of the layers that are aligned on the path I have this expression:

    PathPercent=effect(“Path Percent”)(“Slider”);
    PathLength=comp(“PATH”).duration;
    PathCalc=(PathLength*PathPercent)/100;
    PathPos = comp(“PATH”).layer(“PATH”).position.valueAtTime(PathCalc);

    then on the “Path Percent” “Slider” I have this to control spacing and offset along the path

    f = index*thisComp.layer(“OFFSET”).effect(“FACTOR”)(“Slider”);
    f + thisComp.layer(“OFFSET”).effect(“OFFSET”)(“Slider”);

    So this rig has allowed me to position the people on the perimeter of my logo shape (which is defined by the PATH) and control the space between them with the FACTOR.

    Does that make sense?

  • Dan Ebberts

    July 26, 2013 at 5:48 pm

    Try this for rotation (not tested, but should be close):

    PathPercent=effect(“Path Percent”)(“Slider”);
    PathLength=comp(“PATH”).duration;
    PathCalc=(PathLength*PathPercent)/100;
    v = comp(“PATH”).layer(“PATH”).position.velocityAtTime(PathCalc);
    radiansToDegrees(Math.atan2(v[1],v[0]))

    Dan

  • Riccardo Sinti

    July 26, 2013 at 6:06 pm

    PERFECT!

    You are the best!

    Thanks so much!

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