Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Normal of a plane between two parented lines, responsive as angle changes

  • Normal of a plane between two parented lines, responsive as angle changes

    Posted by Brian Kim on November 25, 2013 at 7:52 pm

    Help AE ExpressionWizards!
    I’m trying to recreate a diagram of an angle in 3 dimensions, and I have two paths parented together at their vertex to create this angle. See picture attached.

    The vertex is close to the camera, and the bottom vector (Line A) extends out into Z-space.
    The 2nd vector (Line B) of the angle is variable, and as I animate its X° and Y° rotation properties, I need to show two things:
    • The plane that is created between Line A and Line B, (I’m expecting to solve this with keyframing/masking)

    And more importantly
    • The perpendicular line/normal that extends out from this plane.

    This is where I need help with expression guidance or (no pun intended) to be pointed in the right direction.

    Darby Edelen replied 12 years, 5 months ago 3 Members · 2 Replies
  • 2 Replies
  • David Alex

    December 2, 2013 at 3:47 pm

    Hi!
    I noticed you’re using 2 null objects to define the points, so I tried it out using a shape layer as the arrow.
    I made the arrow 3D and used this expression in its Position:
    (thisComp.layer("1").position+thisComp.layer("2").position)/2

    This places it directly in between the two.
    Two rotate it in the right direction, I used this in the Orientation:
    lookAt(thisComp.layer("1").position,thisComp.layer("2").position);

    It won’t be completely right, but you can use the X,Y and Z rotation properties to offset and get it pointing the correct way. It also depends on how you drew the shape and which direction it was facing originally.
    Hope this helps 😀

    Ideas to Creations | Motion Graphics, Visual Effects and Digital Art inspiration, tutorials and much more!
    https://ideastocreations.blogspot.com

  • Darby Edelen

    December 3, 2013 at 12:08 am

    You can cross multiply the two vectors to find the normal. Something like this given the 3 points that make up the vectors:


    a = effect("A")("Layer");
    b = effect("B")("Layer");
    c = effect("C")("Layer");
    v1 = a.toWorld(a.anchorPoint) - b.toWorld(b.anchorPoint);
    v2 = a.toWorld(a.anchorPoint) - c.toWorld(c.anchorPoint);
    lookAt(toWorld(anchorPoint), fromWorld(cross(v1, v2)));

    A, B and C are Nulls in my example and this is applied to the Orientation property of another Null representing the normal. If you want the Null to always be centered between the vectors you could also use something like this on the position property:


    a = effect("A")("Layer");
    b = effect("B")("Layer");
    c = effect("C")("Layer");
    (a.toWorld(a.anchorPoint) + b.toWorld(b.anchorPoint) + c.toWorld(c.anchorPoint)) / 3;

    All of the returned vectors are in world space, so if you want the Null to be parented you’d have to modify these to be in the layer space of the parent.

    Darby Edelen

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