How to convert two 3D coordinates to Euler angles?

조회 수: 28 (최근 30일)
Andrew Poissant
Andrew Poissant 2018년 3월 4일
편집: Jim Riggs 2018년 3월 6일
I have two vectors representing (lat, long, alt). I need to calculate the Euler angles (roll, pitch, yaw) required to go from vec1 to vec2. I tried making a rotations matrix and then use rotm2eul() function but I keep getting an error, seen below? The rotation matrix is not of the same format that rot2eul() expects but I am unsure how to fix it. Also, my altitude is in meters, and lat long is in degree so would I need to convert to a common unit?
Error message: Error using rotm2eul Expected R to be of size 3x3xM, but it is of size 1x4.
Error in robotics.internal.validation.validateRotationMatrix (line 21) validateattributes(R, {'single','double'}, {'nonempty', ...
Error in rotm2eul (line 33) robotics.internal.validation.validateRotationMatrix(R, 'rotm2eul', 'R');
Error in S1_NoAcc_3_glide3 (line 346) eul = rotm2eul(rotm);
x_earth = 76.9470;
y_earth = 38.9948;
xnew = 76.9492;
ynew = 38.9935;
hi = 150; % m
hf = 0;
vec1 = [x_earth, y_earth, hi];
vec2 = [xnew, ynew, hf];
rotm = vrrotvec(vec1, vec2); % generate rotation matrix
eul = rotm2eul(rotm);
  댓글 수: 2
Jan
Jan 2018년 3월 5일
편집: Jan 2018년 3월 5일
Please post the complete error message, such that we do not have to guess, which error occurs where. Thanks.
There is no "common unit" for meters and degrees. You need a reference system to determine the rotation matrix and in your case there is a translation also.
Andrew Poissant
Andrew Poissant 2018년 3월 5일
Thank you, I have updated the question to include the error message.

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

답변 (1개)

Jim Riggs
Jim Riggs 2018년 3월 5일
편집: Jim Riggs 2018년 3월 5일
According to the documentation for function vrrotvec, the output of this function is a rotation vector, not a rotation matrix. vrrotvec provides a 4-element row vector output; the first three elements are the rotation vector axis, and the fourth element is the rotation angle.
Function rotm2eul is expecting a 3x3 rotation matrix (i.e. a direction cosine matrix) as the input argument.
  댓글 수: 8
Andrew Poissant
Andrew Poissant 2018년 3월 6일
Isn't pitch proportional to altitude?
Jim Riggs
Jim Riggs 2018년 3월 6일
편집: Jim Riggs 2018년 3월 6일
@Andrew: In this case, you are assuming that the aircraft is at position 1 given by vec1 and some time later it is at position 2, located by vec2. The course of the aircraft is along the vector (vec2-vec1), but this does not really specify the attitude of the aircraft. If you assume that the aircraft traveled in a straight line from (1) to (2), zero angle of attack, and zero sideslip then the aircraft attitude will align with the course line (but only if there also is no wind). You will also need to assume a bank angle in order to completely define the set of Euler angles. So you see, it takes a lot of assumptions to get from a course line to the attitude.

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

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by