I have found other questions like this, but none seem to quite cover the situation I have.

I am using DirectX 11

I have an object that has:

  • Position (vector)
  • Rotation (quaternion)
  • View angle (pitch, roll, yaw)

The view angle needs to be added to the rotation in order to know the true view rotation. You can think of view a head, and rotation as body.

I want to be able to turn the head so that it looks at a given point in space (vector)

The head needs to move slowly so I need to workout what way to turn and then move the head in that direction in small amounts. (pitch, yaw, roll) units

I have attempted to get this working but I don't even seem to be able to get close to what I need.

Thanks in advance.

  • \$\begingroup\$ Are you using DirectXTK or similar? Most math libraries have a Matrix::LookAt function which will generate what you're looking for. \$\endgroup\$ – 3Dave Nov 9 '16 at 15:48
  • \$\begingroup\$ I can create a look at matrix but that is not helping me as i need to know the difference so i can slowly turn in that direction. \$\endgroup\$ – Paul Spain Nov 9 '16 at 16:36

1)Convert your rotation angle to quaternion

2)Multiply this quaternion by your object's rotation quaternion

3)Use Spherical Linear Interpolation (SLERP) to interpolate between these two quaternions.

  • \$\begingroup\$ Note that quaternions turn out to LERP pretty well too (since their internal angle is half what we'd have from a corresponding rotation matrix, they're "more linear" in a sense). So unless you need precisely consistent speed of rotation, LERP+normalize can be a cheaper substitute for SLERP. Sometimes LERP is even desireable since it will give a slight ease-in and ease-out with peak speed in the middle of the rotation. \$\endgroup\$ – DMGregory Sep 12 '17 at 11:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.