• 15
• 15
• 11
• 9
• 10

# Is there Quaternion class for opengl users ??

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

## Recommended Posts

I need some good quaternion class for use with 3d graphics. Something like quaternion class from microsoft but more usefull with opengl and in c++.

##### Share on other sites
i believe someone here was working on something like that

##### Share on other sites
I'm working on a quat class which I hope to make available when it's done, but it might be a while yet. Meanwhile, here are a couple of tips on how to make your own quat class OpenGL-friendly. The first thing to do is to define multiplication in the 'standard' way, i.e.:
q1q2 = [w1w2-v1.v2, w1v2+w2v1+v1Xv2]
With this form, quaternion concatenation mirrors matrices with column vectors, i.e. the quaternion product q2q1 applies q1 first, followed by q2. This is as opposed to DirectX, which uses 'reverse' quaternion multiplication (v2Xv1 instead of v1Xv2) to mirror the row-vector convention.

The only other OpenGL-specific thing I can think of right now is how you convert the quaternion to a matrix. To be lazy and skip over the details, there are basically only two ways to convert a (unit-length) quaternion to a rotation matrix, and they are transposes of each other. To make a long story short, if your current version doesn't give you the results you expect, transpose the indices in the code.

I think that should about do it, but feel free to ask if you have other questions.