luca-piccioni / OpenGL.Net

Modern OpenGL bindings for C#.
MIT License
570 stars 109 forks source link

Quaternion multiplication has an error in a formula #63

Open AlissaSabre opened 7 years ago

AlissaSabre commented 7 years ago

The line 324 in file "OpenGL.Net/Quaternion.cs" currently reads:

double _q2 = w1*y2 + y1*w2 + x1*z2 - z1*x2;

but I believe it should be:

double _q2 = w1*y2 + y1*w2 + z1*x2 - x1*z2;

i.e., the last two terms (x1*z2 and z1*x2) are tangled.

I'm not a math guru and can't provide a good test case. I just noticed some strange rotation behaviour in my program run on OpenGL.Net (thank you for the great program, by the way!), and my trouble shooting finally came to the quaternion multiplication. The above change solved my issue. Can you please check it against your source of the quaternion formula.

luca-piccioni commented 7 years ago

We definitively need an unit test for Quaternion class.