How to find Rotation Matrix for a Given Position?

4 次查看(过去 30 天)
The position of any point in space can be calculated via rotation+displacement. But how can we calculte if the position is known, and rotation matrix is desired to be found?
My code is below.
close all;clear all;clc;
rb=30;rp=15;
t=[0,0,60]';
deg120=120*pi/180;deg60=60*pi/180;
p1=[rp*cos(deg60), rp*sin(deg60), 0]';
p3=[rp*cos(deg60+deg120), rp*sin(deg60+deg120), 0]';
p2=[rp*cos(deg60+2*deg120), rp*sin(deg60+2*deg120), 0]';
% p1=[7.50, 12.9904, 0]'
% p2=[7.50, -12.9904, 0]'
% p3=[-15, 0, 0]'
alpha=0*pi/180;beta=0*pi/180;gamma=0*pi/180;
Rx=[1 0 0;
0 cos(alpha) -sin(alpha)
0 sin(alpha) cos(alpha)];
Ry=[cos(beta) 0 sin(beta)
0 1 0
-sin(beta) 0 cos(beta)];
Rz=[cos(gamma) -sin(gamma) 0
sin(gamma) cos(gamma) 0
0 0 1];
R=Rz*Ry*Rx; P1=R*p1+t;P2=R*p2+t;P3=R*p3+t;
% -------Second part of the code (after some rotation)
alpha_new=20*pi/180;beta_new=20*pi/180;gamma_new=20*pi/180;
Rx_new=[1 0 0;
0 cos(alpha_new) -sin(alpha_new)
0 sin(alpha_new) cos(alpha_new)];
Ry_new=[cos(beta_new) 0 sin(beta_new)
0 1 0
-sin(beta_new) 0 cos(beta_new)];
Rz_new=[cos(gamma_new) -sin(gamma_new) 0
sin(gamma_new) cos(gamma_new) 0
0 0 1];
R_new=Rz_new*Ry_new*Rx_new;
P1_new=R_new*p1+t;P2_new=R_new*p2+t;P3_new=R_new*p3+t;
For the code above, imagine that we know P1_new, P2_new, P3_new, and t. Therefore, we want to find R_new rotation matrix, and also alpha_new, beta_new, gamma_new angles. (They are set to 20degrees. But imagine that we don't know it yet.)
How can I find alpha_new, beta_new, gamma_new angles? Thanks in advance.

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Robotics 的更多信息

产品


版本

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by