フィルターのクリア

How to calculate the Euler angles between X, Y and Z axes (in Deg) between two 3D points

42 ビュー (過去 30 日間)
Rizwana Ahmad
Rizwana Ahmad 2023 年 7 月 5 日
コメント済み: Rizwana Ahmad 2023 年 7 月 5 日
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

回答 (1 件)

Aditya Singh
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.
  1 件のコメント
Rizwana Ahmad
Rizwana Ahmad 2023 年 7 月 5 日
Hi Aditya,
Thank you for your response. I am bit confused about step 4,5 and 6 as they seem inter depdndent. we cant calculate 4th without knowing 5th and 6th, pls correct me if I am wrong.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeIntroduction to Installation and Licensing についてさらに検索

タグ

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by