0

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!

  • You could create a new basis with originPosition, destinationPosition, and their respective cross. Then the appropriate rotation matrix would be about new z. You can find the angle of rotation with the inner product formula. Conjugate this rotation matrix with change of basis matrix to get the desired one. – Kevin Aug 28 '22 at 22:00
  • Pitch and yaw work for an aircraft because in addition to forward and rearward directions, the aircraft has a left side, a right side, a top, and a bottom defining three specific axes around which it can rotate. A vector has only forward and reverse. So the first thing to figure out is what kind of actions "yaw" and "pitch" should perform on your vector. Also note that there are infinitely many rotations that can make a given vector point in the direction of another given vector. – David K Aug 28 '22 at 22:00
  • Is there a reason it has to be yaw, pitch, and roll? It is very easy to "rotate" a vector $u$ to the direction of another vector $u$: just construct a new vector $v'$ with the length of $v$ but the direction of $u.$ Two dot products, a division, a square root, and a multiplication will do it. – David K Aug 28 '22 at 22:31
  • @DavidK The code I need to write requires I set a yaw, pitch, and roll so there isn't another way for me to do it sadly. – SmushyTaco Aug 28 '22 at 22:45
  • I find it hard to believe that any respectable 3D library supports only yaw, pitch, and roll. Are there other constraints you're not telling us, for example a bunch of other vectors have to be moved at the same time by the same transformation? In any case, when using operations provided by software, the first thing is to find out what those operations actually are. Math can't tell you that, but the documentation might. – David K Aug 28 '22 at 22:59
  • It is curious that you should choose to link to the definition of Cartesian coordinates, which any person capable of even comprehending your question would surely already know, but not to the definition of Pitch, Roll, Yaw, which are not at all as widely known. – Paul Sinclair Aug 29 '22 at 21:44

0 Answers0