I have 4 vectors in 2 different 3D coordinate. The origin of
coordinates is the same point.Question is how I can compute
the rotation matrix between these 2 coordinates?
"Rahman " <john.doe.nospam@mathworks.com> wrote in message
<fj0bus$1i$1@fred.mathworks.com>...
> I have 4 vectors in 2 different 3D coordinate. The origin of
> coordinates is the same point.Question is how I can compute
> the rotation matrix between these 2 coordinates?
>
> Any Idea?
>
> Thanks
> Rahman
If A is 4 x 3 matrix (four vectors V put in columns) in
Coordinate system #1.
and B is 4 x 3 matrix of V in coordinate system #2.
What you want is a orthogonal matrix (3x3) matrix (rotation
matrix) such that B = Q*A.
"Bruno Luong" <brunoluong@yahoo.com> wrote in message
<fj0d9a$goi$1@fred.mathworks.com>...
> "Rahman " <john.doe.nospam@mathworks.com> wrote in message
> <fj0bus$1i$1@fred.mathworks.com>...
> > I have 4 vectors in 2 different 3D coordinate. The origin of
> > coordinates is the same point.Question is how I can compute
> > the rotation matrix between these 2 coordinates?
> >
> > Any Idea?
> >
> > Thanks
> > Rahman
>
> If A is 4 x 3 matrix (four vectors V put in columns) in
> Coordinate system #1.
> and B is 4 x 3 matrix of V in coordinate system #2.
>
> What you want is a orthogonal matrix (3x3) matrix (rotation
> matrix) such that B = Q*A.
>
> Then solving Q can be accomplished by
>
> Q = B/A
>
> Bruno
Thanks for fast answer.
In other words Q= inv(A) * B. But as you know inverse matrix
should be square!
It is possible use this way with least square method, but
problem is the computing rotation matrix doesnt have the
rotation matrix properties, or in other words its accuracy
is very low.
Thanks. I did but for my data, the result matrix is 5x4!!!
Please be aware that my data come from experiment, so surly
they are not perfect and need to choose the optimize matrix.
"Rahman " <john.doe.nospam@mathworks.com> wrote in message
<fj0rn0$9h2$1@fred.mathworks.com>...
> Thanks. I did but for my data, the result matrix is 5x4!!!
> Please be aware that my data come from experiment, so surly
> they are not perfect and need to choose the optimize matrix.
Something is very wrong. How many vectors do you have? I
though you have 4 vectors in R^3, in two coordinate systems.
If you calculate
Q = B/A where A and B are (3 x n) matrices you must get (3 x
3) matrix. The solution is unique if and only if rank(A)=3.
You can use eig() on Q to find out rotation-axis and
rotation angle.
"Rahman " <john.doe.nospam@mathworks.com> wrote in message <fj0bus$1i
$1@fred.mathworks.com>...
> I have 4 vectors in 2 different 3D coordinate. The origin of
> coordinates is the same point.Question is how I can compute
> the rotation matrix between these 2 coordinates?
>
> Any Idea?
>
> Thanks
> Rahman
-------
When you say "4 vectors in 2 different 3D coordinate", do you mean two
vectors in one coordinate system and the same two vectors expressed in terms
of a rotated coordinate system, as in the rotation of a rigid body? That is what
would be required to determine the rotation of the rigid body. Presumably the
lengths of the two vectors and the angles between them remain unchanged if
the rotation is to be about the common origin.
"Rahman " <john.doe.nospam@mathworks.com> wrote in message <fj0bus$1i
$1@fred.mathworks.com>...
> I have 4 vectors in 2 different 3D coordinate. The origin of
> coordinates is the same point.Question is how I can compute
> the rotation matrix between these 2 coordinates?
>
> Any Idea?
>
> Thanks
> Rahman
-------
When you say "4 vectors in 2 different 3D coordinate", do you mean two
vectors in one coordinate system and the same two vectors expressed in terms
of a rotated coordinate system, as in the rotation of a rigid body? That is what
would be required to determine the rotation of the rigid body. Presumably the
lengths of the two vectors and the angles between them remain unchanged if
the rotation is to be about the common origin.
"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid>
wrote in message <fj1juq$hr7$1@fred.mathworks.com>...
> Presumably the
> lengths of the two vectors and the angles between them
remain unchanged if
> the rotation is to be about the common origin.
>
Huumm, rotation in 3D does not necessary conserve angle.
Example, If you rotate about z axis about say 90 degree. The
vector (0,0,1) and transform to (0,0,1), and the angle
between them is of course 0 degree, and not 90 degree.
All rotations in R3 is a group, called SO(3). They are
orthogonal (3x3) matrix, i.e., Q*Q' = I.
Any element of SO(3) has 3 eigen-values (1, exp(i*theta),
exp(-i*theta)). The eigen-vector corresponds to 1 is the
rotation axis. Theta is the rotation angle.
The rotation conserve angle generally for vectors that are
perpendicular to the rotation axis, i.e., in the span of two
complex eigen-vectors.
Forget what I just wrote, I simply miss-understood Roger (he
wrote about angle of two vector before and after
transformation, and this is of course correct). Apologize.
Rahman wrote:
> I have 4 vectors in 2 different 3D coordinate. The origin of
> coordinates is the same point.Question is how I can compute
> the rotation matrix between these 2 coordinates?
If you have access to the Statistics Toolbox, I think you'll find that
PROCRUSTES does this nicely:
>> A = randn(4,3); % four random vectors in 3-D
>> [U,S,V] = svd(randn(3)); T = U*V'; % random orthogonal matrix
>> T
T =
-0.91586 -0.14665 -0.37375
0.084785 0.83926 -0.53707
0.39244 -0.52357 -0.75621
>> B = A*T; % rotate A
>>
>> [d,B1,tr] = procrustes(B,A);
>> tr.T % rotation component: same as original T
ans =
-0.91586 -0.14665 -0.37375
0.084785 0.83926 -0.53707
0.39244 -0.52357 -0.75621
>> tr.c % translation component: 0
ans =
2.2204e-16 5.5511e-17 0
2.2204e-16 5.5511e-17 0
2.2204e-16 5.5511e-17 0
2.2204e-16 5.5511e-17 0
>> tr.b % scale component: 1
ans =
1
Thank you very much. Ya, this is complete correct. I found a
page about it and then could understand and find the
function. For who has the same problem this Link is very useful. http://kwon3d.com/ search between theories: Computation of
the Rotation Matrix
Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for
all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content.
Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available
via MATLAB Central. Read the complete Disclaimer prior to use.