关于ZYZ旋转和XYZ旋转

关于ZYZ旋转和XYZ旋转ZYZ 旋转和 XYZ 旋转 绕 xyz 轴旋转的旋转矩阵

大家好,欢迎来到IT知识分享网。

ZYZ旋转和XYZ旋转

概述

  1. 以下公式默认为右手坐标系;
  2. ZYZ通常可以避免死解情况,因此在六轴末端解算时常被用到;
  3. 参考文章

1、XYZ旋转

function R = RotationZYX(xyz) X = [1, 0, 0; ... 0, cos(xyz(1)), -sin(xyz(1)); ... 0, sin(xyz(1)), cos(xyz(1))]; Y = [cos(xyz(2)), 0, sin(xyz(2)); ... 0, 1, 0; ... -sin(xyz(2)), 0, cos(xyz(2))]; Z = [cos(xyz(3)), -sin(xyz(3)), 0; ... sin(xyz(3)), cos(xyz(3)), 0; ... 0, 0, 1]; R = Z * Y * X; end 

C++代码:

cv::Mat EulerToMat(cv::Point3f Euler) { 
    float alpha = Euler.x / 180 * CV_PI; float belta = Euler.y / 180 * CV_PI; float gamma = Euler.z / 180 * CV_PI; cv::Mat Rx = (cv::Mat_<float>(3, 3) << 1, 0, 0, 0, cos(alpha), -sin(alpha), 0, sin(alpha), cos(alpha)); cv::Mat Ry = (cv::Mat_<float>(3, 3) << cos(belta), 0, sin(belta), 0, 1, 0, -sin(belta), 0, cos(belta) ); cv::Mat Rz = (cv::Mat_<float>(3, 3) << cos(gamma), -sin(gamma), 0, sin(gamma), cos(gamma), 0, 0, 0, 1 ); return Rz * Ry * Rx; } 

2、ZYZ旋转

XYZ旋转一般是绕自身轴旋转(内旋),旋转矩阵的构成为:RxRyRz。
在这里插入图片描述
MATLAB代码:

syms a b c Ra=[cos(a) -sin(a) 0; sin(a) cos(a) 0; 0 0 1]; Rb=[cos(b) 0 sin(b); 0 1 0;-sin(b) 0 cos(b)]; Rc=[cos(c) -sin(c) 0;sin(c) cos(c) 0;0 0 1]; Rzyz=Ra*Rb*Rc % 定义姿态旋转角度 angle1 = deg2rad(-8.668); % 绕z轴旋转角度 angle2 = deg2rad(146.282); % 绕y轴旋转角度 angle3 = deg2rad(175.557); % 绕新z轴旋转角度 r11 = cos(angle1) * cos(angle2) * cos(angle3) - sin(angle1) * sin(angle3); r12 = -cos(angle1) * cos(angle2) * sin(angle3) - sin(angle1) * cos(angle3); r13 = cos(angle1) * sin(angle2); r21 = sin(angle1) * cos(angle2) * cos(angle3) + cos(angle1) * sin(angle3); r22 = -sin(angle1) * cos(angle2) * sin(angle3) + cos(angle1) * cos(angle3); r23 = sin(angle1) * sin(angle2); r31 = -sin(angle2) * cos(angle3); r32 = sin(angle2) * sin(angle3); r33 = cos(angle2); % 姿态旋转矩阵 ZYZ_matrix = [r11 r12 r13; r21 r22 r23; r31 r32 r33]; 

C++代码:

float angle1 = config.ReadFloat("Parmeter", "angleA", 0.0); float angle2 = config.ReadFloat("Parmeter", "angleE", 0.0); float angle3 = config.ReadFloat("Parmeter", "angleR", 0.0); angle1 = angle1 * CV_PI / 180; angle2 = angle2 * CV_PI / 180; angle3 = angle3 * CV_PI / 180; float r11 = cos(angle1) * cos(angle2) * cos(angle3) - sin(angle1) * sin(angle3); float r12 = -cos(angle1) * cos(angle2) * sin(angle3) - sin(angle1) * cos(angle3); float r13 = cos(angle1) * sin(angle2); float r21 = sin(angle1) * cos(angle2) * cos(angle3) + cos(angle1) * sin(angle3); float r22 = -sin(angle1) * cos(angle2) * sin(angle3) + cos(angle1) * cos(angle3); float r23 = sin(angle1) * sin(angle2); float r31 = -sin(angle2) * cos(angle3); float r32 = sin(angle2) * sin(angle3); float r33 = cos(angle2); cv::Mat ZYZ_matrix = (cv::Mat_<float>(3, 3) << r11, r12, r13, r21, r22, r23, r31, r32, r33); 

免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://yundeesoft.com/145367.html

(0)
上一篇 2024-11-24 19:26
下一篇 2024-11-24 19:33

相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注微信