# Quaternions, screen coordinates, matricies, and rays

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

## 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 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 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 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)

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 15
• 22
• 16
• 13
• 14