Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Computing rotation matrix from one vector

Subject: Computing rotation matrix from one vector

From: Carlos Junior

Date: 29 Mar, 2011 04:28:03

Message: 1 of 8

Hi, please, I would like to ask a help about finding a Rotation Matrix.

Doubt: Is it possible to get the Rotation Matrix of one vector at the System of Coordinates #1 to the System of Coordinates #2 ?

The transformation is below:
[ 0.245 -0.563 -0.055 ]' = R * [ 0.3 -0.5 0.2 ]'

I think it is possible because the setup above give me 3 equations and 3 variables (theta_x, theta_y, theta_z)... But, MatLab can not solve!


Thanks a lot

Carlos
carlosjunior@gmail.com

Subject: Computing rotation matrix from one vector

From: Rune Allnor

Date: 29 Mar, 2011 04:30:36

Message: 2 of 8

On Mar 29, 6:28 am, "Carlos Junior" <carlosjun...@gmail.com> wrote:
> Hi, please, I would like to ask a help about finding a Rotation Matrix.
>
> Doubt: Is it possible to get the Rotation Matrix of one vector at the System of Coordinates #1 to the System of Coordinates #2 ?
>
> The transformation is below:
> [ 0.245 -0.563 -0.055 ]' = R * [ 0.3 -0.5 0.2 ]'
>
> I think it is possible because the setup above give me 3 equations and 3 variables (theta_x, theta_y, theta_z)... But, MatLab can not solve!
>
> Thanks a lot
>
> Carlos
> carlosjun...@gmail.com

http://en.wikipedia.org/wiki/Euler's_rotation_theorem

Rune

Subject: Computing rotation matrix from one vector

From: Carlos Junior

Date: 29 Mar, 2011 05:05:04

Message: 3 of 8

Hi Rune, very thanks by the answer, but, the Wikipedia link http://en.wikipedia.org/wiki/Euler's_rotation_theorem does not elucidate the doubt... There are a lot of text and theory there, but, not a numeric or practical example of the type I have shown before ( [ 0.245 -0.563 -0.055 ]' = R * [ 0.3 -0.5 0.2 ]' ) ...

Please, how would you find the R matrix of this problem? The information above is enough to find that ?

Very Thanks,

Carlos Junior
carlosjunior@gmail.com



Rune Allnor <allnor@tele.ntnu.no> wrote in message <62228b51-0fe2-43bd-a76b-0d9f0266619f@z20g2000yqe.googlegroups.com>...
> On Mar 29, 6:28 am, "Carlos Junior" <carlosjun...@gmail.com> wrote:
> > Hi, please, I would like to ask a help about finding a Rotation Matrix.
> >
> > Doubt: Is it possible to get the Rotation Matrix of one vector at the System of Coordinates #1 to the System of Coordinates #2 ?
> >
> > The transformation is below:
> > [ 0.245 -0.563 -0.055 ]' = R * [ 0.3 -0.5 0.2 ]'
> >
> > I think it is possible because the setup above give me 3 equations and 3 variables (theta_x, theta_y, theta_z)... But, MatLab can not solve!
> >
> > Thanks a lot
> >
> > Carlos
> > carlosjun...@gmail.com
>
> http://en.wikipedia.org/wiki/Euler's_rotation_theorem
>
> Rune

Subject: Computing rotation matrix from one vector

From: Bruno Luong

Date: 29 Mar, 2011 05:52:04

Message: 4 of 8

Note thet R cannot be NOT uniquely determined from ONE vector and its rotation. You need at least two pairs.
 
u = [ 0.245 -0.563 -0.055 ]';
v = [ 0.3 -0.5 0.2 ]' ;

u1 = u/norm(u)
v1 = v/norm(v)

k = cross(u1,v1);
% Rodrigues's formula:
costheta = dot(u1,v1);
R =[ 0 -k(3) k(2);
     k(3) 0 -k(1);
    -k(2) k(1) 0];
R = costheta*eye(3) + R + k*k'*(1-costheta)/sum(k.^2);

disp(v)
disp(R*u)

% Bruno

Subject: Computing rotation matrix from one vector

From: Bruno Luong

Date: 29 Mar, 2011 06:09:03

Message: 5 of 8

Rune Allnor <allnor@tele.ntnu.no> wrote in message <62228b51-0fe2-43bd-a76b-0d9f0266619f@z20g2000yqe.googlegroups.com>...

> >
> > I think it is possible because the setup above give me 3 equations and 3 variables (theta_x, theta_y, theta_z)... But, MatLab can not solve!

You have 2 equations independent equations not three, since the constraint is the norm of both vectors (before and after rotation) must be equal. So the 3 equations on Cartesian's coordinates are only indeed two independent ones.

The problem is ill posed.

Bruno

Subject: Computing rotation matrix from one vector

From: Bruno Luong

Date: 29 Mar, 2011 06:36:03

Message: 6 of 8

Sorry the quote below is from Carlos J., not from Rune.

> > > I think it is possible because the setup above give me 3 equations and 3 variables (theta_x, theta_y, theta_z)... But, MatLab can not solve!

Bruno

Subject: Computing rotation matrix from one vector

From: Carlos Junior

Date: 29 Mar, 2011 13:41:06

Message: 7 of 8

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <imrukj$8iq$1@fred.mathworks.com>...
> Sorry the quote below is from Carlos J., not from Rune.
>
> > > > I think it is possible because the setup above give me 3 equations and 3 variables (theta_x, theta_y, theta_z)... But, MatLab can not solve!
>
> Bruno

Very thanks by the help Bruno... I have wrote your code and it worked perfectly! If I could help you in some subject, please be free to ask...

Now I will begin to explore how to identify the origin of the rotation found. For example, could I know the order of rotation? Could I know what of the 6 possible rotations the code returned me ? ( Rx*Ry*Rz ? Rx*Rz*Ry ? Ry*Rx*Rz ? Ry*Rz*Rx ? Rz*Ry*Rx ? Rz* Rx*Ry ? ) ...

Tks,

Carlos
carlosjunior@gmail.com

Subject: Computing rotation matrix from one vector

From: Colin

Date: 28 Oct, 2011 18:50:33

Message: 8 of 8

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <imrs24$rq6$1@fred.mathworks.com>...
> Note thet R cannot be NOT uniquely determined from ONE vector and its rotation. You need at least two pairs.
>
> u = [ 0.245 -0.563 -0.055 ]';
> v = [ 0.3 -0.5 0.2 ]' ;
>
> u1 = u/norm(u)
> v1 = v/norm(v)
>
> k = cross(u1,v1);
> % Rodrigues's formula:
> costheta = dot(u1,v1);
> R =[ 0 -k(3) k(2);
> k(3) 0 -k(1);
> -k(2) k(1) 0];
> R = costheta*eye(3) + R + k*k'*(1-costheta)/sum(k.^2);
>
> disp(v)
> disp(R*u)
>
> % Bruno

Bruno,

Thank you so much for this. I was really struggling with this exact problem. You make it look so easy.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us