Dear Sir
I am a research student and I've been using this quaternion library, with much
success, and thanks. I hope this email is being directed in right direction,
I'm sure you'll let me know if not.
I should like to offer a third opinion in the discussion below.
I agree with Mr Pradeep.
Regarding Mr Pradeep's first example: A rotation stays the same with a reversal
of the axis of rotation as long as the angle of rotation is also negated.
However, in the example given, the angle 0.78540=pi/4, through a sequence of
transformations that are not supposed to change the effect of spatial rotation,
becomes 2.3562=3*pi.4. If the axis or rotation were reversed and the rotation
to remain the same, actually this should have become either -pi/4 or 7*pi/4.
Qualitatively, you can see that 3*pi/4 is a rotation that takes the clock-hands
further from midnight than either pi/4 or 7*pi/4 could.
Regarding Mr Pradeep's second example: In the example given, Mr Pradeep was
able to turn a rotation of almost nothing and, by putting it through the
quaternion function, turn it into a rotation of close to pi. If this resultant
rotation were close to 2*pi or were negative, then your reasoning about the
reversal of normal vectors would apply. However, quantitatively, rotations of 0
and 2*pi are either full-turns or no-turns, but rotations of pi are half-turns.
You can't turn a no-turn or a full-turn into a half-turn by reversing the
direction of the turn.
I have my own example too, which should help convince. Here is output from an
octave session:
octave:356> qqq=[sin(pi/4) 0 0 -cos(pi/4)]
qqq =
0.70711 0.00000 0.00000 -0.70711
octave:358> [aaa,bbb]=quaternion(qqq)
aaa =
1 0 0
bbb = 1.5708
octave:360> rrr=quaternion(aaa,bbb)
rrr =
0.70711 0.00000 0.00000 0.70711
Note the negation of the scalar component (-0.70711) during the transform, even
though the quaternion as a whole is not negated.
Note that here we have broken another supposed invariant - i.e. that there are a maximum of two unit quaternions that parametrise a certain rotation (i.e. qqq and -qqq). In this case, we get a third, rrr. But we know that there should not be a third parametrisation, so there's something wrong here. It's in the call to quaternion(qqq).
If this does not convince, see what happens when we use qqq and rrr to rotate a
unit vector:
octave:390> vec=[0 1 0 0]
vec =
0 1 0 0
octave:392> qmult(qqq,qmult(vec,qinv(qqq)))
ans =
0.00000 0.00000 -1.00000 -0.00000
octave:394> qmult(rrr,qmult(vec,qinv(rrr)))
ans =
0.00000 0.00000 1.00000 0.00000
We get different results each time, telling us that qqq and rrr actually
represent different rotations.
I note that the latest version of quaternion.m, seemingly at
http://octave.svn.sourceforge.net/viewvc/octave/trunk/octave-forge/main/quaternion/inst/quaternion.m?revision=5326
, doesn't seem to have been changed since the version that I'm using.
I hope this email has been helpful and contributed towards the success of a wonderful piece of software.
If you'd like me to I can take a look at the code and Mr Pradeep's solution too; just let me know.
Best wishes
Damien Jade Duff
http://www.cs.bham.ac.uk/~djd/
dbateman2 wrote:
My understanding of quaternions is that this is like the right hand rule
of vector multiplication. You've redefined the normal vector (the thumb
of your right hand) to be in the negative direction and so your fingers
are now points in the opposite direction than if your unit vector was
defined in the positive direction. Thus the difference. Quaternions are
not what I work with normally though so a second (or rather third)
opinion, would be welcome
D.
Vijay Pradeep wrote:
Hello David,
So what you are arguing is that composing two quaterions q & -q is the
same as composing q & q. And I completely agree with you. However,
what I am trying to argue is that in certain special cases (that is,
when w(4) < 0), the conversion from quaternion to axis-angle is
incorrect.
Let me try to explain in another example.
*octave:1> *q = [0 0 -.01 -.99995]
q =
0.00000 0.00000 -0.01000 -0.99995
*octave:2> [ax4 ang4] = quaternion(q)*
ax4 =
-0 -0 -1
ang4 = 3.1216
Note that the rotation angle (ang4) is close to PI, whereas the
quaternion is very close to [0 0 0 -1], and hence it should be a
rotation of zero.
Cheers,
Vijay
On Sat, Jan 17, 2009 at 9:14 AM, David Bateman <address@hidden
<mailto:address@hidden>> wrote:
Vijay Pradeep wrote:
Hello David,
I believe that you are arguing that the two sets of [ax ang]
that you computed are equivalent, and that they're simply
rotations in opposite directions. If so, then ang1+ang2
should equal 2*PI. However, they sum to PI, so it's off by
180 degrees.
That would be true if the direction of the first unit vector
defining the quaternion wasn't reversed. But it is and so Pi is
the right answer. Start with your original definition
w = quaternion([1 0 0], pi/4);
Consider that the w= -w for a quaternion and that multiplication
of two quaternions gives the equivalent rotation of the applying
each of the rotations consecutively. Therefore w * -w should be a
rotation of pi/2 around the i^\hat or -i^\hat
[ac3, ang3] = quaternion (qmult (w, -w))
ac3 =
-1 0 0
ang3 = 1.5708
seems right. So I still don't see the issue.
D.
--
David Bateman address@hidden
<mailto:address@hidden>
35 rue Gambetta +33 1 46 04 02 18 (Home)
92100 Boulogne-Billancourt FRANCE +33 6 72 01 06 33 (Mob)
--
David Bateman address@hidden
35 rue Gambetta +33 1 46 04 02 18 (Home)
92100 Boulogne-Billancourt FRANCE +33 6 72 01 06 33 (Mob)
_______________________________________________
Bug-octave mailing list
address@hidden
https://www-old.cae.wisc.edu/mailman/listinfo/bug-octave
Quoted from:
http://old.nabble.com/Quaternion-to-axis-angle-conversion-is-buggy-when-w%284%29%3C0-tp20956270p21880629.html