How to align an axis with a vector?

edited November 2016 in How To...

Hi everyone! I'm stuck on a problem, and I don't think there's a simple answer (or any answer at all) so that's why I'm asking you.

Here's the problem: I've got a 3D vector. I'd simply like to rotate the system to align an axis (the z axis for instance) with my vector. I've tried to do it with rotateX() and rotateY() but it didn't work. That would be pretty easy if, like with the camera() function, you'd be able to just set the direction to face. I was looking for a function that would do the job, but I didn't find anything (did I miss it?).

Thank you for your help!

Tagged:

Answers

  • but it didn't work

    Can you share an example of what you tried?

    Did you use any PVector methods to find the angles between your vector components and the current heading components?

Sign In or Register to comment.