Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Expression (x,y) compairson to + 1 frame (x,y) = x degrees

  • Expression (x,y) compairson to + 1 frame (x,y) = x degrees

    Posted by Ganer Stewart on June 18, 2007 at 2:31 pm

    I’m working on a “camera” shake and I’m trying to write a scrip that will compare 2 different (x,y) positions and return the movement in degrees. Also if someone has done this before, I’d like the scrip that also return the number of pixels moved between two points. Any Ideas would be appreciated.

    gs

    gs

    Dan Ebberts
    replied 18 years, 10 months ago
    3 Members · 5 Replies
  • 5 Replies
  • Dan Ebberts

    June 18, 2007 at 3:18 pm

    I don’t think you’ve provided nearly enough information. You can’t just convert pixels to degrees without a point of reference. Is the reference point the camera? So you have a point that is moving in 3D space from one frame to the next and you want to caluclate how much you have to rotate the camera to track it, is that correct? If so, why not just attach the camera’s POI to the point? What are you trying to do, exactly? 🙂

    Dan

  • Darby Edelen

    June 18, 2007 at 4:05 pm

    [Ganer13] “Also if someone has done this before, I’d like the scrip that also return the number of pixels moved between two points”

    This one is fairly simple if you only want the distance between the two points:


    p1 = thisComp.layer("Layer One").transform.position;
    p2 = thisComp.layer("Layer Two").transform.position;

    length(p1, p2); //Returns the distance from p1 to p2

    Darby Edelen
    DVD Menu Artist
    Left Coast Digital
    Aptos, CA

  • Ganer Stewart

    June 18, 2007 at 4:24 pm

    dan,

    What I’m trying to do is generate an angle of movement in 2d space. if an object is at (0,0) and then moves to (10,10) I’m trying to return a value of the direction of movement. This I’ll attach to the variable (degrees) in the “Directional blur” effect. This I’m hoping will mimic the natural “Smearing” of a camera shake. Then I’ll attach the “length of movement” to the amount of blur in “directional blur” effect. Does that make more sense?

    gs

  • Dan Ebberts

    June 18, 2007 at 4:34 pm

    Yup. Try this:

    P1 = [0,0];
    P2 = [10,10];

    delta = P2 – P1;
    radiansToDegrees(Math.atan2(delta[1],delta[0]));

    Dan

  • Dan Ebberts

    June 18, 2007 at 4:56 pm

    I think you have to add 90 degrees to get it to work right with the directional blur filter:

    P1 = [0,0];
    P2 = [10,10];

    delta = P2 – P1;
    90 + radiansToDegrees(Math.atan2(delta[1],delta[0]));

    Dan

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