Fwd: Quaternion to axis/angle conversion is buggy when w(4)<0
David Bateman
dbateman at dbateman.org
Wed Jan 14 15:53:04 CST 2009
Vijay Pradeep wrote:
> Below is a patch (generated from [diff -cp]) for the bug listed below:
>
> *** quaternion.m 2008-12-10 21:16:51.000000000 -0800
> --- quaternion_ORIGINAL.m 2008-12-10 21:15:28.000000000 -0800
> *************** function [a, b, c, d] = quaternion (w, x
> *** 54,63 ****
> if (abs (norm (w) - 1) > 1e-12)
> warning ("quaternion: ||w||=%e, setting=1 for vv, theta", norm(w));
> w = w/norm(w);
> ! endif
> ! if (w(4)<0)
> ! w = -w ;
> ! end
> [a, b, c, d] = quaternion (w);
> theta = acos (d) * 2;
> if (abs (theta) > pi)
> --- 54,60 ----
> if (abs (norm (w) - 1) > 1e-12)
> warning ("quaternion: ||w||=%e, setting=1 for vv, theta", norm(w));
> w = w/norm(w);
> ! endif
> [a, b, c, d] = quaternion (w);
> theta = acos (d) * 2;
> if (abs (theta) > pi)
>
>
> ---------- Forwarded message ----------
> From: Vijay Pradeep <vpradeep at willowgarage.com>
> Date: Wed, Dec 10, 2008 at 9:13 PM
> Subject: Quaternion to axis/angle conversion is buggy when w(4)<0
> To: bug at octave.org
>
>
> Sorry..... the auto bug-reporting tool was having issues. I have
> included the bug report below.
>
> Subject: Quaternion to axis/angle conversion is buggy when w(4)<0
> -----------
> Bug report for Octave 3.0.0 configured for i486-pc-linux-gnu
>
> Description:
> -----------
> A rotation represented by a quaternion w is equivalently represented
> by -w. However, if w(4) is negative,
> then the conversion of this quaternion to axis angle is incorrect,
> because of the ambiguity in acos(),
> which is used in ./octave/3.0.0/m/quaternion/quaternion.m to compute
> the rotation angle.
>
> Repeat-By:
> ---------
> w = quaternion([1 0 0], pi/4)
> [ax ang] = quaternion( w)
> [ax2 ang2] = quaternion(-w)
>
> The rotations represented by [ax ang] and [ax2 ang2] are not equivalent
>
> Fix:
> ---
> in /octave/3.0.0/m/quaternion/quaternion.m
>
> if w(4) is negative, then negate w before operating on it.
>
I see the following
octave:1> w = quaternion([1 0 0], pi/4)
w =
0.38268 0.00000 0.00000 0.92388
octave:2> [ax ang] = quaternion( w)
ax =
1 0 0
ang = 0.78540
octave:3> [ax2 ang2] = quaternion(-w)
ax =
-1 -0 -0
ang = 2.3562
so I don't see what the issue is. Yes in the second case the angle is Pi
larger, but that is normal when the first unit vector is reverse. That
is the transformation is different but equivalent. I therefore don't
consider this a bug as such
Regards
David
--
David Bateman dbateman at dbateman.org
35 rue Gambetta +33 1 46 04 02 18 (Home)
92100 Boulogne-Billancourt FRANCE +33 6 72 01 06 33 (Mob)
More information about the Bug-octave
mailing list