#### Archived

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

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

## Recommended Posts

I'm currently working on implementing a project involving skeletal-animation, so I'm storing rotational info on the bones, using axis-angle as a representation. Now I'm wondering how to "add" a rotation to a previous one. As an example let's say I got a bone with a rotation and i want to rotate it around another axis. How do I add these rotations to get one single rotation? Thanks in advance. [edited by - kenki on November 9, 2002 12:55:29 PM]

##### Share on other sites
You would use unit quaternions to represent the rotations, and multiply them toghether to combine their rotations

Compared to axis-angle (a,x,y,z), a quaternion is [ cos(a/2), x*sin(a/2), y*sin(a/2), z*sin(a/2) ] and has ''special'' multiplication rules that make it ''work right''.

Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]

##### Share on other sites
Is it really necessary to use quats? Having to convert back and forth every frame seems like a waste of CPU. It feels as though it should be possible to do directly in axis-angle... Does anybody know for sure if quats are really a necessity?

##### Share on other sites
You have to convert back to a rotation matrix anyways - quats let you do it directly, without involving trig :

Quaternion [w,x,y,z]

Rotation Matrix
[ 1-2yy-2zz   2xy+2wz   2xz-2wy ][   2xy-2wz 1-2xx-2zz   2yz+2wx ][   2xz+2wy   2yz-2wx 1-2xx-2yy ]

And yes, even glRotate and its DX equivalent HAVE to go back to rotation matrices - quaternions are essentially axis-angle with the trig already incorporated. In that respect, they are faster to use - you don't have to go back to axis-angle every frame, just use quaternions all the way.

edit - formatting

Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]

[edited by - Fruny on November 9, 2002 1:15:06 PM]

##### Share on other sites
Yes, I knew some of that, but I have a reluctancy to use quats as I don't like using things I don't fully understand (although I'm working on it). I understand axis/angle rotation a lot better than quats and thusly I prefer axis/angle. So until I find quaternions familiar to work with, is there a way to do it with axis/angle representation?
By the way, thanks for all the input so far!

[edited by - kenki on November 9, 2002 1:46:33 PM]

##### Share on other sites
quote:
Original post by kenki
Yes, I knew some of that, but I have a reluctancy to use quats as I don''t like using things I don''t fully understand (although I''m working on it)

Not that I am aware of, the only thing I could advise you to do is to try and work out the math, starting from the quats. That would be the best way to learn how they work.

Note that, mathematically, unit quaternions & multiplication exactly represent 3D rotations & composition.

Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]

##### Share on other sites
I was beginning to think about that... However, I''m starting to lean towards implementing quaternions instead. It''s just that I have to rewrite quite a lot of code... *sigh*

By the way, how would I manipulate a gl-matrix? Is there a function or something?
Also a quat question: I''m supposed to multiply the matrix obtained by quat conversion with the current gl-matrix, is that correct?

##### Share on other sites
quote:
Original post by kenki
By the way, how would I manipulate a gl-matrix? Is there a function or something?
Also a quat question: I''m supposed to multiply the matrix obtained by quat conversion with the current gl-matrix, is that correct?

- glMultMatrix

- It depends whether your quaternion represents incremental rotation (difference between two frames) or the actual orientation (from, say, pointing down the Z axis).

Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]

1. 1
2. 2
3. 3
Rutin
16
4. 4
5. 5

• 10
• 11
• 14
• 10
• 25
• ### Forum Statistics

• Total Topics
632649
• Total Posts
3007644
• ### Who's Online (See full list)

There are no registered users currently online

×