oZone3D.Net Forums

Old Forums (No longer active) => G-Truc Creation => Topic started by: LangFox on February 27, 2009, 10:30:43 AM

Title: GLM quaternion
Post by: LangFox on February 27, 2009, 10:30:43 AM
At first, I have to say that GLM is must-have for OpenGL developers.

But the quaternion could be optimized. It should be more efficient to make an axis-angle format and have a function to rotate vector.

Finally, great work! Yet it can be better!  ;D
Title: Re: GLM quaternion
Post by: Groove on March 17, 2009, 03:57:44 PM
You have very welcome! ;)

It actually depend how you use it. If you need to go back to the proper quaternion form, you lose a lot of benefice. If you really want to use a axis angle form, I think it would be better to simply use a vec3 and a scalar.

Have you some samples where you find advantages of axis-angle?


Title: Re: GLM quaternion
Post by: LangFox on March 19, 2009, 07:51:18 AM
Well, it is nothing important, just a little laziness, hehe.

My original math is:
Code: [Select]
sm_quat q(axis, theta);
vec3 result = q.rotate(v);

Now using GLM instead:
Code: [Select]
quat p(1.0, v.x, v.y, v.z);
quat q(cos(theta/2), axis.x*sin(theta/2), axis.y*sin(theta/2), axis.z*sin(theta/2));
quat result = cross(cross(q, p), conjugate(q));

Anyway, that doesn't matter.  :saut: