#### Archived

This topic is now archived and is closed to further replies.

# Rotation without quats

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

## Recommended Posts

Are there any good alternativves for making a camera rotation except for using quaternions? And it there is, maybe you know of a good tutorial that covers it (or quats).
Bad Monkey Productions [edited by - shakazed on September 10, 2002 6:00:39 AM]

##### Share on other sites

Quats are best really as they let you interpolate between a start and finish angle, so you can still easily calculate orientation even if frame rate is a bit bumpy. They also avoid gimble lock, so as far as I know its the best approach. Dunno about tutorials, but google is pretty effective.

##### Share on other sites
Okay, well I guess that´s the way to go then. Just seem so hard to grasp. Do you have a simple example on how to rotate a camera around an arbitrary axis?

##### Share on other sites

The DirectX docs in the SDK actually give a clear description of what they are :

Quaternions add a fourth element to the [x, y, z] values that define a three-component-vector. Quaternions are an alternative to the matrix methods that are typically used for 3-D rotations. A quaternion represents an axis in 3-D space and a rotation around that axis. For example, a quaternion might represent a (1,1,2) axis and a rotation of 1 radian. Quaternions carry valuable information, but their true power comes from the two operations that you can perform on them: composition and interpolation.

I.e. they define an axis and rotation magnitude.

I got that from googles cache as its from the Direct X 7 API docs that are no longer up. However I''m sure its in the DX8 docs, so just do some searching. The cached page is linked below :

http://216.239.51.100/search?q=cache:H93TTwyGpJQC:msdn.microsoft.com/library/en-us/dx8_c/hh/dx8_c/graphics_intro_7igj.asp+simple+quaternion+example&hl=en&ie=UTF-8

If you find a good tutorial you should post it here as most of them seem dreadful

##### Share on other sites
Thanks for the links and suggestions, will check it out.

##### Share on other sites
Okay quats are good for some stuff...

But my recomendation is "screw" the quats code and use matrices. I actually think that a simple matrix transformation (resultant from the multiplication of various transform matrices and not the adaption of a quat to a matrix) gives far better results for the camera, specially because the transforms can have simple intuitive commands to move the camera around...

##### Share on other sites
I''d have to disagree with mister Anonymous Poster here. Quaternions are generally more mathematically intuitive than matrices when it comes to rotations, and they can be manipulated in all the same ways, so...

##### Share on other sites
Actually... NO! Quats are not more intuitive mathamatical beings, for me. Quats and matrices give you exactly the same result, although quats allow you to do some interesting things, matrices are actually easier to understand. The only thing that you''ve got to remember is that a rotation/translation/scalling matrix is nothing more than a transformation matrix which transforms vectores fom one vector space to another vector space. Said like that it might sound daunting, but the fact is that with an example image anyone would understand what I''m saying and if you have all your data stored in some kind of scene graph structure using matrices could save you a lot of trouble with various implementations (although you have the added cost of matrix multiplications) using an extremely intuitive implementation.

Other then that using matrices for something as simple as a rotation is still a simple case, just make a matrix with the adequate rotations (with matrix multiplication) and apply...

##### Share on other sites
I''m writing a tutorial on a full 6 degree of freedom camera system using matrices right now. should be finished and in a couple days, mainly because as said before, most are dreadful.

What it comes down to is you need 3 axes and a position. You need to be able to rotate about these 3 axes.
If you''re using d3d you can use either D3DXMatrixRotationAxis or D3DXQuaternionRotationAxis and both will work, only if you''re going to alter the view matirx (as most cameras do) you''ll have to convert your quaternion back to a matrix, which is an extra step you don''t have to do with matrices.
that said, quaternios offer the interpolation advantages that matrices don''t, but if you don''t need interpolation in your camera then go with matrices.

D3DX Allows you to use either matrices or quaternions without understanding the theory anyway so the debate about which is easier to understand is mute.

I''ll post back when the tute is funished.

Toby

Gobsmacked - by Toby Murray

1. 1
2. 2
3. 3
Rutin
22
4. 4
5. 5

• 13
• 19
• 14
• 9
• 9
• ### Forum Statistics

• Total Topics
632930
• Total Posts
3009289
• ### Who's Online (See full list)

There are no registered users currently online

×