Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions 3D orientation script

  • 3D orientation script

    Posted by Simon Cam on August 24, 2007 at 3:40 pm

    Hey fellow script-heads,

    I’m trying to animate “tracer” bullets between two 3D points and I want to be able to orient the bullet along the path. I can’t use “orient to path” cause there is no path as such – the positional motion is an expression too. I’m therefore trying to do the orientation trig based on the start and end points, but I can’t seem to find anything on the net to help me maths-wise. I’ve tried doing the orientation as 2 separate 2d x/z and x/y calculations but that’s not right. Anyone know the trig for the 3D angles between two 3D points?

    Cheers!

    sCam

    Simon Cam replied 18 years, 8 months ago 2 Members · 2 Replies
  • 2 Replies
  • Mike Clasby

    August 24, 2007 at 4:32 pm

    Just curious, what’s the Positional expression?

    Can you modify Dan’s auto-orient expression, here:

    https://www.motionscript.com/design-guide/auto-orient-y-only.html

    It uses toWorld between two points. Maybe an altternative to “Math.atan2” or subtract 90 degrees from something???

    Also, t-would be a pain, but you could always take that Positional expression and Animation>Keyframe Assistant>Convert Expression to Keyframes, then use “orient to path”. Bad idea I know, sooo many keyframes and expressions are so clean.

  • Simon Cam

    August 28, 2007 at 7:04 am

    Heya – thanks for that link! Yes that’s kind of what I’m doing. That script orientates an object to “look at” another object but in the y-axis only. I’m trying to do it for both the y-axis (left to right) and also the x-axis (up down). I haven’t actually cracked it yet, but having researched it a bit more I think this would be the principle:

    1. Calculate y-axis rotation by “looking down” on the vector from above in 2d, and doing a basic atan2 on the x and z distances (as per Dan’s example above).

    2. Now here’s the trick – rotate the vector negatively by the result in the y-axis, so you effectively ‘remove’ this rotation from it.

    3. Now you’re free to do the same for the x-axis rotation as you’ve ‘straightened’ the vector up to run flat along the z axis.

    That’s the theory anyway, bear in mind I might be totally wrong!. I think it would definitely have its limitations too. I ran out of time on this one to finish it off properly and so did it by hand in the end. If I get round to trying it out I’ll post the results.

    Cheers, sCam

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