Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Directional Cosine Matrix
Date: Fri, 20 Jun 2008 15:55:05 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 37
Message-ID: <g3gjsp$7sv$1@fred.mathworks.com>
References: <g3do4d$667$1@fred.mathworks.com> <g3fk6a$co7$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1213977305 8095 172.30.248.35 (20 Jun 2008 15:55:05 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 20 Jun 2008 15:55:05 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:475005



"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in 
message <g3fk6a$co7$1@fred.mathworks.com>...
>   It is not entirely evident from your description what you asking, Chia.
> ........

  A good night's sleep has furnished a much superior method of solving your 
problem, Chia.  This method has none of the disadvantages of the one I sent 
you yesterday and is much simpler.  There is no need to run through the 
previous eight possibilities.

  Assume, as before, that A and B are n x 3 arrays in which all column sums 
are zero.  Then do this:

 [U,S,V] = svd(A'*B);
 R = U*V';

This R will be your desired unitary (direction cosine) matrix that, if applied to 
A, will bring you to B:  B = A*R.

  If B differs from such a transformation of A, then this solution yields an R 
which I have reason to believe, (but can't prove,) is the best one in a least 
squares sense.

  In the case that two or all three of the singular values in S are equal, there 
will be an inherent indeterminacy, but this time it does not interfere with 
finding a valid solution.  In such cases there would be an infinite continuum 
of equally good solutions.

  Again I remind you that the above solution, R, can in some cases have a 
determinant of -1 instead of +1 and therefore be a reflection, rather than 
rotation, matrix.  In these cases the reflection matrix would provide a closer 
fit than a true rotation matrix.  It would nevertheless be unitary, that is, a 
matrix of direction cosines.

Roger Stafford