Path: news.mathworks.com!not-for-mail
From: "James Tursa" <aclassyguywithaknotac@hotmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: angle from rotation matrix
Date: Mon, 17 Dec 2007 21:35:56 +0000 (UTC)
Organization: Boeing
Lines: 45
Message-ID: <fk6q3s$dns$1@fred.mathworks.com>
References: <fjvbqk$gbt$1@fred.mathworks.com> <fk0cpd$g0v$1@fred.mathworks.com> <fk0iq9$k0j$1@fred.mathworks.com> <fk59hv$n5r$1@fred.mathworks.com> <2shcm3pkforks50k3jjkjo0bdkioir9jq2@4ax.com> <fk6eis$ra6$1@fred.mathworks.com> <fk6ief$3kq$1@fred.mathworks.com>
Reply-To: "James Tursa" <aclassyguywithaknotac@hotmail.com>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1197927356 14076 172.30.248.37 (17 Dec 2007 21:35:56 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 17 Dec 2007 21:35:56 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 756104
Xref: news.mathworks.com comp.soft-sys.matlab:442838


"Bruno Luong" <b.luong@fogale.fr> wrote in message 
<fk6ief$3kq$1@fred.mathworks.com>...
> Roger,
> 
> Thank you or pointing out the accuracy problem when
> theta~pi. Here is the change I made that work better. 
Though
> I don't think the issue when theta~0 could be overcome.
> 
> Bruno
> 
> 
> c=(trace(A)-1);
> u=[A(3,2)-A(2,3);...
>    A(1,3)-A(3,1); ...
>    A(2,1)-A(1,2)];
> s=norm(u);
> theta=atan2(s,c)
> 
> if abs(2-c)>s % <- Use diagonal terms to estimate u
>     signu=sign(u);
>     signu(signu==0)=1; % we don't want the nil case 
>     u=sqrt((2*diag(A)-c)/(2-c)).*signu
> elseif s~=0 % <- use off-diagonal terms to estimate u
>     u=u/s
> else
>     warning('A close to identity');
>     u=[1 0 0]
> end

Hello Bruno,

I think that if you continue to improve your method, i.e. 
looking for the best combination of A elements to use to 
form u depending on circimstances, etc., this effort will 
eventually lead you to an algorithm that essentially 
accomplishes ths same thing as the direction cosine matrix 
to quaternion code that I posted earlier. This code looks 
for the best numerical way to combine the A elements to 
form the quaternion, and of course the rotation axis then 
falls out naturally from the quaternion elements. Again I 
would point out that this is not my original algorithm.

James Tursa