This bugzilla service is closed. All entries have been migrated to https://gitlab.com/libeigen/eigen
Bug 459 - [feature request] Quaternion as rotation & scaling
Summary: [feature request] Quaternion as rotation & scaling
Status: DECISIONNEEDED
Alias: None
Product: Eigen
Classification: Unclassified
Component: Geometry (show other bugs)
Version: 3.1
Hardware: All All
: Normal Feature Request
Assignee: Nobody
URL:
Whiteboard:
Keywords:
Depends on: 560 758
Blocks:
  Show dependency treegraph
 
Reported: 2012-05-05 23:57 UTC by Hauke Strasdat
Modified: 2019-12-04 11:39 UTC (History)
4 users (show)



Attachments
patch (2.26 KB, patch)
2012-05-05 23:57 UTC, Hauke Strasdat
strasdat: review? (gael.guennebaud)
Details | Diff
Another patch: Rotate and scale a vector (1.23 KB, patch)
2012-05-06 18:41 UTC, Hauke Strasdat
strasdat: review? (gael.guennebaud)
Details | Diff

Description Hauke Strasdat 2012-05-05 23:57:08 UTC
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.
Comment 1 Hauke Strasdat 2012-05-06 18:41:38 UTC
Created attachment 268 [details]
Another patch: Rotate and scale a vector

Another patch: Rotate and scale a vector
Comment 2 Gael Guennebaud 2012-05-14 13:08:08 UTC
thanks for the patches, I'm too busy ATM, I'll look at it next week.
Comment 3 Christoph Hertzberg 2014-06-15 04:14:21 UTC
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).
Comment 4 Gael Guennebaud 2014-06-16 13:30:30 UTC
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.
Comment 5 Nobody 2019-12-04 11:39:01 UTC
-- 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.

Note You need to log in before you can comment on or make changes to this bug.