How to calculate the Euler angles between X, Y and Z axes (in Deg) between two 3D points
조회 수: 33 (최근 30일)
이전 댓글 표시
Hi,
I have two 3D points, Tx (Tx,Ty,Tz) and Rx (Rx,Ry,Rz). I want to calculate the rotation angles in terms of yaw, roll and pitch. How can I do this in matlab? Do we have any direct function that does it, otherwise how to program for the same?
TIA
댓글 수: 0
답변 (1개)
Aditya Singh
2023년 7월 5일
Hi Rizwana,
To my understanding, you have two points and want to calculate the Euler angles between them.
You need to do is first convert these cartesian vectors to rotation matrix and then to Euler system. Below is the brief code for the reference
% Lets take first 2 points and find Spherical coordinates.
P1 = [-426159, 501913, 845131];
P2 = [-48717.2, 499318, 847679];
v = P1-P2;
% Let's define si and theta in such a way that.
v = [r*cos(si)*cos(theta), r*sin(theta), r*sin(si)*cos(theta)]
r = norm(v);
si = atan2(v(3),v(1));
theta = atan2(v(2),sqrt(v(1).^2+v(3).^2));
j = [cos(si)*cos(theta), sin(theta), sin(si)*cos(theta)];
% Correspond to j vector you can also find orthonormal vector to j
i = [sin(si), 0, -cos(si)];
k = [cos(si)*sin(theta), -cos(theta), sin(si)*sin(theta)];
% Rotation matrix;
m = [i',j',k'];
% You can use MATLAB inbuilt function to convert rotation matrix to Euler system
eul = rotm2eul(m);
For more information you can refer to the MATALB question Euler angle from 3d points? - MATLAB Answers - MATLAB Central (mathworks.com).
Hope it helps.
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!