Created attachment 267 [details] patch While unit quaternions represent rotations in 3d, general quaternions can be interpreted as the group of rotation and scaling. It would be nice if corresponding feature would be added to the Quaternion class. I added a patch which contains the conversion from a general quaternion to a matrix of rotation & scaling.
Created attachment 268 [details] Another patch: Rotate and scale a vector Another patch: Rotate and scale a vector
thanks for the patches, I'm too busy ATM, I'll look at it next week.
Both things would be more consistent with the `q*[0;v]*q.conjugate()` definition of quaternion rotation using this definition: { Scalar scale = this->squaredNorm(); Vector3 imag_cross_v = this->vec().cross(v); imag_cross_v += imag_cross_v; return scale*v + (this->w() * imag_cross_v + this->vec().cross(imag_cross_v)); } This would also save a sqrt, an if-branch, and a division. Furthermore, the result would be smooth everywhere (Hauke's implementation is not near zero). For the matrix conversion the changes are equivalent. Drawback: For scaling with s, the quaternion must be scaled with sqrt(s) -- but that would actually make it more obvious that scaling with negative numbers is not possible (or rather that scaling with -1.0 has no effect).
I agree that it should follow the standard way to apply quaternions to vector, i.e.: 'q*[0;v]*q.conjugate()' . The conversion to matrices should be factorized to avoid duplicated code.
-- GitLab Migration Automatic Message -- This bug has been migrated to gitlab.com's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.com/libeigen/eigen/issues/459.