Euler angle from 3d points?

조회 수: 45 (최근 30일)
SOONMYUN JANG
SOONMYUN JANG 2020년 12월 21일
댓글: Rizwana Ahmad 2023년 7월 5일
I want to compute Euler angle from 3d points which are in a same plane and nearly rectangle shape.
These 3d points are collected by robot arm. I want to know the correct rotation value of the plane for robot arm control.
I computed like below and I don't know how to convert three angles to Euler angles.
P1 = [-426159, 501913, 845131]
P2 = [-48717.2, 499318, 847679]
P3 = [-43057.3, 493773, 478609]
P4 = [-422845, 495153, 475314]
Z_angle = atan((P2(2) - P1(2)) / (P2(1) - P1(1))) * 180 / pi;
Y_angle = atan((P2(3) - P1(3)) / (P2(1) - P1(1))) * 180 / pi;
X_angle = atan((P1(3) - P4(3)) / (P1(2) - P4(2))) * 180 / pi;

채택된 답변

Shashank Gupta
Shashank Gupta 2020년 12월 31일
편집: Shashank Gupta 2021년 1월 7일
Hi,
I think what you need to do is first convert these cartesian vectors to rotation matrix and then to Euler system. It is a simple Geometry. 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);
This is the typical geometrical way of doing it, There could be more ways, For reference check out vrrotvec, vrrotvec2mat and cart2sph These function can also make your calculation easy.
Cheers
  댓글 수: 2
SOONMYUN JANG
SOONMYUN JANG 2021년 1월 4일
Thank you so much!
Rizwana Ahmad
Rizwana Ahmad 2023년 7월 5일
Hi Shashank,
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.
v = [r*cos(si)*cos(theta), r*sin(theta), r*sin(si)*cos(theta)]
r = norm(v);
si = atan2(v(3),v(1));

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Coordinate Transformations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by