0
\$\begingroup\$

I have a quaternion based camera class (which controls a view matrix) and would like a function to rotate the camera to face a specified point. The best approach I can come up with is that I rotate the camera on the plane of the two vector by the angle between them.

Any advice?

\$\endgroup\$
3
\$\begingroup\$

Any decent OpenGL math library should have a function called lookAt. It does exactly what you want with the exception that it produces a matrix and not a quaternion. This problem can be solved by converting the matrix back to a quaternion.

In case you aren't already using a math library, I recommend checking glm which basically tries to provide everything that GLSL has, just in C++.

\$\endgroup\$

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.