Activity › Forums › Adobe After Effects Expressions › Angle Measure expression
-
Angle Measure expression
Posted by Josh Coleman on May 26, 2013 at 3:59 pmHello 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
-
Josh Coleman
May 26, 2013 at 4:56 pmAt 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 pmDepending 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 pmAnd 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 pmIf 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 pmok 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 pmThe 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:26 pmIn 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 pmHard 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
Reply to this Discussion! Login or Sign Up