How to convert two 3D coordinates to Euler angles?
18 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
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 个评论
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.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!