How Do I Calculate The Pitch, Yaw, and Roll of An Object To Face Another Object?

283 Views Asked by At

So to start off I'm using the https://en.wikipedia.org/wiki/Cartesian_coordinate_system

Okay so, let's say I have two Vector3 objects, each consisting of an x, y, and z.

One object is labeled originPosition.

The other object is labeled destinationPosition.

How would I set the Pitch, Yaw and Roll to get the originPosition to face the destinationPosition?

If it makes explaining this easier, let's say the originPosition has an X of 2, a Y of 3, and a Z of 4. (2, 3, 4)

We'll also say the destinationPosition has an X of 5, a Y of 6, and a Z of 7. (5, 6, 7)

With all that said, how do I make originPosition rotate to look directly at destinationPosition?

I'm not trying to make it rotate over time either, I'm trying to make it snap onto destinationPosition. Thanks!