Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Angle Measure expression

  • Angle Measure expression

    Posted by Josh Coleman on May 26, 2013 at 3:59 pm

    Hello all,

    I was just wondering if there was an expression to display an angle between two lines?

    If i had two lines generated to a persons leg, could i write an expression to show me the angle between them as the person was to squat down?

    Thank you

    Josh Coleman replied 13 years, 3 months ago 2 Members · 15 Replies
  • 15 Replies
  • Dan Ebberts

    May 26, 2013 at 4:31 pm

    How are you creating the lines?

    Dan

  • Josh Coleman

    May 26, 2013 at 4:56 pm

    At the moment I am using Generate>Beam, but is there is a better way i’m all for it.

  • Dan Ebberts

    May 26, 2013 at 6:57 pm

    Depending on how you have things set up, some variation of this should work:

    beam1 = thisComp.layer(“Beam Layer”).effect(“Beam”);
    beam2 = thisComp.layer(“Beam Layer”).effect(“Beam 2”);
    v1 = beam1(“Ending Point”) – beam1(“Starting Point”);
    v2 = beam2(“Ending Point”) – beam2(“Starting Point”);
    radiansToDegrees(Math.acos(dot(normalize(v1),normalize(v2))))

    Dan

  • Josh Coleman

    May 26, 2013 at 7:36 pm

    And which layer(s) should i put this into?
    I don’t use expressions that often, so i’m a little new to this.

  • Dan Ebberts

    May 26, 2013 at 7:38 pm

    If you want to display it, I’d put it in the Source Text property of a text layer in the same comp.

    Dan

  • Josh Coleman

    May 26, 2013 at 8:17 pm

    ok so all of
    beam1 = thisComp.layer(“Beam Layer”).effect(“Beam”);
    beam2 = thisComp.layer(“Beam Layer”).effect(“Beam 2”);
    v1 = beam1(“Ending Point”) – beam1(“Starting Point”);
    v2 = beam2(“Ending Point”) – beam2(“Starting Point”);
    radiansToDegrees(Math.acos(dot(normalize(v1),normalize(v2))))

    goes into the text layer, as long as my two beam layers are called ‘beam1’ and ‘beam2’?

  • Dan Ebberts

    May 26, 2013 at 8:38 pm

    The way the expression is written, it’s expecting two Beam effects (“Beam” and “Beam 2”) on a single layer (“Beam Layer”). It would be easy to change though, if your beams were on separate layers (“Beam Layer 1” and “Beam Layer 2”). That would be more like this:

    beam1 = thisComp.layer(“Beam Layer 1”).effect(“Beam”);
    beam2 = thisComp.layer(“Beam Layer 2”).effect(“Beam”);
    v1 = beam1(“Ending Point”) – beam1(“Starting Point”);
    v2 = beam2(“Ending Point”) – beam2(“Starting Point”);
    radiansToDegrees(Math.acos(dot(normalize(v1),normalize(v2))))

    Dan

  • Josh Coleman

    May 26, 2013 at 9:18 pm

    Ok thank you, I’ll play about with it and see what I get.

  • Josh Coleman

    May 26, 2013 at 9:26 pm

    In the current situation, the expression is outputting “0”

    I’ve tried moving the beams and rotating them but no change.

  • Dan Ebberts

    May 26, 2013 at 9:55 pm

    Hard to say without seeing how you have it set up. The expression assumes that the beam layers are not rotated or non-uniformly scaled. If that’s not the case, the expression needs to be more complex.

    Dan

Page 1 of 2

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