Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions finding a vector between to point in space

  • Xavier Gomez

    July 9, 2014 at 11:19 am

    p1 = effect(“3D Point Control”)(“3D Point”);
    p2 = effect(“3D Point Control 2”)(“3D Point”);
    normalize(sub(p2,p1)); // unit vector

    If for some reason you need both the length and the unit vector
    v = sub(p2, p1);
    L = length(v);
    u = L==0 ? null : div(v,L);

    // you can use p2-p1 instead of sub(p2,p1), etc, AE supports it.

    Xavier.

  • Shahed Naderi

    July 9, 2014 at 12:38 pm

    thank you Xavier, that’s helpful , what about a normal of a plane ?
    and what about multiplying those two vector in a way that you have a number, V1.V2 ? I dont know the name of math operator

  • Xavier Gomez

    July 9, 2014 at 3:14 pm

    normal of the plane parallel to v1 and v2 (up to sign): normalize(cross(v1, v2));
    v1.v2 : dot(v1,v2);

    To get all methods (math or not) available to expressions, enable the expression of a property, and click the triangle near the = sign.
    It opens up the menu.

    Xavier.

  • Shahed Naderi

    July 9, 2014 at 4:01 pm

    thank you , I just saw them now , never needed them 🙂 I know cross gives you a vector which is perpendicular to those vector you crossed. but I just have a regular plane and a camera , I know where is my camera and from that point to another point on the surface of the plane , there is just a vector. but I need to have another vector for the plane , which is its normal. so I can dot them . that way I have a number which is related to distant and angel of view.
    so I need to know how I can have normal for planes .
    any help on that ?

  • Xavier Gomez

    July 10, 2014 at 6:15 am

    I don’t know what plane you are talking about…

    If your plane is a layer, then a normal to the “plane” can be the vector [0,0,1] (in layer coordinate system). To get the coordinates of that vector in world coordinate system, use toWorld, then normalize to get a unit vector in world system (in case your layer is scaled etc):

    normalize(thisComp.layer(“Plane”).toWorld([0,0,1]));

    Something like this. I barely do any 3D so i’m not sure to be honnest… That’s a whole different question from the first one 😉

    If your plane is not a layer, then you should give more info about that plane…

    Xavier.

  • Shahed Naderi

    June 20, 2015 at 6:25 pm

    hello there again

    thanks for answer, a while back I used these and I made the idea I had but it didnt give me the effect I was trying to achive,
    the thing I want to do is ,to make some highlights using “CC Light Sweep” and put it on top of a layer, then I want that highlight which is kinda stright line along surface react to camera movement in a proper way. I had in mind that I can tie center point of “CClight sweep” to camera movement somehow, but how ? that’s the question.

    thank you for respond

    shahed

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