Registered Member
|
Hello,
I have noticed there is no test for quaternions equality which is defined (e.g. something like operator==(...) or an 'isEqualTolerance(..., Scalar tolerance = (Scalar)1e-3)'). Is there a good reason for that or is it just something to add one day in the future? Of course I understand I can customize the class and add the function / operator myself. I only ask to understand whether it is a good idea to do so or whether there is a trick Thanks, Antoine. |
Moderator
|
There is an isApprox method that compares the quaternion's coefficients: q1.isApprox(q2). If you want to compare the orientations represented by the quaternions you can use the angularDistance function q1.angularDistance(q2)<epsilon, or even q1.dot(q2)>1-epsilon which avoids a trigonometric function.
|
Registered Member
|
|
Registered Member
|
slight follow up here. I am storing orientations and want to ensure I only store unique quaternions. As each quaternion has 2 possible representations I wanted to chose the one with W > 0. Is there a cleaner way to negate all the components?
Right now I have to do quat.w() *= -1; quat.x() *= -1; quat.y() *= -1; quat.z() *= -1; |
Moderator
|
quat.coeffs() *= -1;
or quat.coeffs() = -quat.coeffs() ; |
Registered Member
|
Thanks. Sorry I missed that in the docs |
Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]