Path: news.mathworks.com!not-for-mail
From: "Bruno Luong" <b.luong@fogale.fr>
Newsgroups: comp.soft-sys.matlab
Subject: Re: angle from rotation matrix
Date: Mon, 17 Dec 2007 19:25:03 +0000 (UTC)
Organization: FOGALE nanotech
Lines: 26
Message-ID: <fk6ief$3kq$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>
Reply-To: "Bruno Luong" <b.luong@fogale.fr>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1197919503 3738 172.30.248.38 (17 Dec 2007 19:25:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 17 Dec 2007 19:25:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 390839
Xref: news.mathworks.com comp.soft-sys.matlab:442817


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