MATLAB Answers

How to find Rotation Matrix for a Given Position?

28 views (last 30 days)
ercan duzgun
ercan duzgun on 20 Jan 2021
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;
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]'
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)
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];
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.

Answers (0)




Community Treasure Hunt

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

Start Hunting!

Translated by