Reply to topic

Quaternion Constructor Postconditions

BearT
Registered Member
Posts
2
Karma
0
I'm currently reading in some configuration data consisting of a quaternion and a 3d translation vector and later randomizing the data. During that I triggered some assertions in my code where the Quaternion constructor taking an AngleAxis did not create a normalized quaternion ie. a valid rotation. When debugging I found that the quaternion configuration data had been a unit quaternion and thus the rotation axis was undefined, ie. a zero vector, which was fed into an AngleAxis and so on.

So my question would be if "garbage in - garbage out" is the intended behaviour or if there are (or should be) any stronger guarantees that a constructor only constructs (in this case) valid rotations? If you're concerned about performance (which I do not consider a problem with constructors) would it be a viable solution to at least assert in constructors, so in debug builds these problems are shown as soon as they a recognized and not at the time they break some (admittedly sloppy) user code? Or am I completely wrong about rotations and normalized quaternions?

thanks,
Norbert
User avatar ggael
Moderator
Posts
3447
Karma
19
OS
We already had such a discussion, but no action has been taken yet. See: http://comments.gmane.org/gmane.comp.lib.eigen/3987
User avatar ggael
Moderator
Posts
3447
Karma
19
OS
See also this bug report: http://eigen.tuxfamily.org/bz/show_bug.cgi?id=601
And feel free to give your inputs there.
BearT
Registered Member
Posts
2
Karma
0
I'm sorry I missed the old discussions. I only checked the forum history. Thanks for the links Gael. It's good to see that Hauke made the same mistakes, so at least I feel a bit better now. ;)

FWIW I'd really like to see at least your proposed patch applied in an upcoming version, cause that would have saved me some time I spent debugging. Since there already is this dummy_precision trait in Eigen already I've now placed my own assertions outside Eigen like this
Code: Select all
assert(quat.normalized().isApprox(quat));
Though I think the ideal solution would be an explicit UnitQuaternion (and possibly RotationMatrix, etc.) class for quaternions (and special matrices) and leaving your proposed checks in AngleAxis.

I'm already lurking the mailinglist for some time now and if this discussion comes up there again I'll join in. Thanks for the answer and I'll try to be even more cautious now when feeding data into Eigen.

 
Reply to topic

Bookmarks



Who is online

Registered users: adamjbeals, Bing [Bot], Google [Bot], Sogou [Bot], YaCy [Bot], Yahoo [Bot]