Sign in to follow this  

Quaternions, screen coordinates, matricies, and rays

This topic is 4812 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Yay! The login problem is finally fixed :) Anyone how to retrieve the up, direction, and right, vectors from a 4x4 matrix that has been created from a quaternion? Or better yet, anyone know any way to generate rays using only the screen coordinates and the quaternion? I am using one quaternion and one 3D vector for my camera orientation and position. I pass the quaternion to glRotate, rasterize the scene (first hit optimization), and then generate rays using screen coordinates and the camera's position and orientation. Any help or references will be greatly appreciated.

Share this post


Link to post
Share on other sites
The up, direction, and right vectors come out of the matrix just like any other rotation matrix: first row is right, second row is up, and third row is direction, assuming D3D.

Share this post


Link to post
Share on other sites
yes, and assuming OpenGL, 1st column is right, 2nd is up, 3rd is direction, except that, IIRC, direction is negated.
Also W part of columns is 0.

Also, you're better convert your quaternions to 3x3 matrices directly - why waste time and space.
Read matrix and quaternion FAQ and math&physics forum FAQ.
You can make operators for using 3x3 matrices as 4x4 with 1.0 in [4,4] (and 0 in all other unused cells)

Share this post


Link to post
Share on other sites
Wow, I can't get over how I knew the answer the whole time! Thanks.
So is it safe to assume that there is no way to generate rays without converting to matrix? (i.e. using the quaternion, camera position, and screen coordinates)

Share this post


Link to post
Share on other sites

This topic is 4812 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this