Thanks for the detailed explanation. Like mentioned before I can see your point but nevertheless the absolute value still in some applications removes valuable information.
Have a look at
http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToAngle/
There is a picture where you see that by taking the absolute value you removing one quadrant. From a mathematical point of view with the absolute value I cannot determine anymore the direction of rotation.
With the absolute value an angle of 190° would result in a return value 10° which makes sense because the two quaternions are 10° apart but I don't know in which direction. In my case in a realtime simulation moving a camera I want to always go the shortest
way and therefore need that Information. By now I know I can get the direction information from the sign of q.w() but for me it makes more sense to retrieve that information by using the atan2 formula without the abs and ensuring the result is [-pi,pi).
Like I said in my second mail the angularDistance() method should not be changed but for some application it would be nice to have something like:
double angularDirection() { return std::copysign( angularDistance(), q.w() ); }
Regards,
Michael
From: Gabriel Nützi <gnuetzi@xxxxxxxxx>
Sent: Tuesday, August 14, 2018 7:46 AM
To: eigen@xxxxxxxxxxxxxxxxxxx
Subject: Re: [eigen] Why does Eigen::Quaterniond::angularDistance() method return the absolute angle?
@gael: Very good explanation
@Michael: If you need probaply a more encompassing intro to quaternions and rotations, I have written "yet" another summary here, where we make a detour over R^4 to finally come to a represetation of a quaternion for Rotations in R^3 (unit-quaternions):
Chapter 3
https://www.research-collection.ethz.ch/bitstream/handle/20.500.11850/117165/eth-49175-02.pdf?sequence=2&isAllowed=y
BR Gabriel
Am 13.08.2018 um 23:53 schrieb Gael Guennebaud:
Again, in 3D if you have a rotation of angle 'a' and axis `v`, then the pair (-a,-v) represents the same rotation, and this the same for the quaternions q and -q. This is why it is enough to restrict the angle to the [0,pi) range, which is what angularDistance
does. Another example (following yours):
say we take:
q2.coeffs() = -q1.coeffs()
then q2 and q1 represents the exact same rotation, and it thus makes sense that:
q0.angularDistance(q1) == q0.angularDistance(q2).
Same for:
AngleAxisd(q1).angle() == AngleAxisd(q2).angle()
AngleAxisd(q1).axis() == AngleAxisd(q2).axis()
gael
Ok, I can see your point regarding angular distance. The issue I'm facing happens for really large angles in my application I have following 2 quaternions:
q0=
[0]:0.42320069127859006
[1]:-0.52593954473002769
[2]:0.45987326974154225
[3]:0.5768928375077278
and q1=
[0]:-0.50596192324633082
[1]:0.59255532789450238
[2]:-0.38450528029832376
[3]:-0.49501152009970484
a = q0.angularDistance(q1) returns 0.30801826469545818 ( ~17.6 deg )
while
q = q0.conjugate() * q1;
b = 2 * std::atan2( q.vec().norm(), std::fabs(q.w()) ) returns 5.9751670424841281 (342.4 deg)
For my understanding if you wanted to ensure (-pi,pi] the angle should be -17.6 deg
Maybe the atan2 when used with proper quaternions can never return negative values? So the times 2 is used to ensure [0,pi) ?
I did not find the derivation of this formula and even if probably I wouldn't understand it. But at least also here it is written without the absolute value:
https://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation#Recovering_the_axis-angle_representation
Michael
From: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>
Sent: Wednesday, August 8, 2018 10:13 AM
To: eigen
Subject: Re: [eigen] Why does Eigen::Quaterniond::angularDistance() method return the absolute angle?
One reasons is that a distance is expected to be symmetric and positive. Another one is that the "sign" is relative to the axis of rotation, so returning a "signed" angular distance alone does not seem to make much sense. Perhaps you want:
AngleAxisd aa(q1*q2.conjugate());
and if you really don't care about the axis defining the sign:
double a = AngleAxisd(q1*q2.conjugate()).angle();
gael
Hi All,
This is my first mailling list mail. So if I could improve something tell me.
The Issue I face currently with the Eigen::Quaterniond class is that my application relies on the signed angle between two quaternions. Is there a really easy way to get that sign information I'm not aware of?
I had a look in the history why there is the numext::abs(d.w()) inside the atan2 call and found this:
http://eigen.tuxfamily.org/bz/show_bug.cgi?id=824#c1
This is not really an explanation so I wanted to ask for the reasoning behind the abs.
I would appreciate if you could change this method or add another one which gives the signed angle.
Regards,
Michael
The information in this e-mail is confidential. The contents may not be disclosed or used by anyone other than the addressee. Access to this e-mail by anyone else is unauthorised.
If you are not the intended recipient, please notify Airbus immediately and delete this e-mail.
Airbus cannot accept any responsibility for the accuracy or completeness of this e-mail as it has been sent over public networks. If you have any concerns over the content of this message or its Accuracy or Integrity, please contact Airbus immediately.
All outgoing e-mails from Airbus are checked using regularly updated virus scanning software but you should take whatever measures you deem to be appropriate to ensure that this message and any attachments are virus free.
The information in this e-mail is confidential. The contents may not be disclosed or used by anyone other than the addressee. Access to this e-mail by anyone else is unauthorised.
If you are not the intended recipient, please notify Airbus immediately and delete this e-mail.
Airbus cannot accept any responsibility for the accuracy or completeness of this e-mail as it has been sent over public networks. If you have any concerns over the content of this message or its Accuracy or Integrity, please contact Airbus immediately.
All outgoing e-mails from Airbus are checked using regularly updated virus scanning software but you should take whatever measures you deem to be appropriate to ensure that this message and any attachments are virus free.
The information in this e-mail is confidential. The contents may not be disclosed or used by anyone other than the addressee. Access to this e-mail by anyone else is unauthorised. If you are not the intended recipient, please notify Airbus immediately and delete this e-mail. Airbus cannot accept any responsibility for the accuracy or completeness of this e-mail as it has been sent over public networks. If you have any concerns over the content of this message or its Accuracy or Integrity, please contact Airbus immediately. All outgoing e-mails from Airbus are checked using regularly updated virus scanning software but you should take whatever measures you deem to be appropriate to ensure that this message and any attachments are virus free.
|