• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

matlab中的三维坐标系与旋转 - jmpep

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

matlab中的三维坐标系与旋转

1. matlab中的三维坐标系

matlab中的三维坐标系是使用的右手坐标系;

输入以下代码:

>> plot3(0,0,0)

>> xlabel(\'axis X\')

>> ylabel(\'axis Y\')

>> zlabel(\'axis Z\')

可以看出是个很明显的右手坐标系。

2. matlab中的欧拉角和四元数旋转

euler angles ----> quaternion ----> dcm ---->rotation

MATLAB中欧拉角旋转基本遵循以上步骤,欧拉角、四元数、旋转矩阵之间是可以相互转换的,具体可以参见help文档中的Aerospace Toolbox ----> Functions ----> Axes ----> Axes Transformations中查看。

假设我在三维坐标系中有一向量r,绕Z轴旋转90度,结果为:

close all;

clear;

clc;

r = [0 1 1];

% 默认的旋转顺序是ZYX,所以[90 0 0]表示绕Z轴旋转90度

angle = [90 0 0] * pi / 180;

quaternion = angle2quat(angle(1),angle(2),angle(3));

n = quatrotate(quaternion,r)

结果:

n =

     1.0000    0.0000    1.0000

 

原始向量在YZ平面上[0 1 1],旋转后的平面在XZ的平面上[1 0 1],可以看出从Z轴的正方向来看,顺时针旋转;

再次验证:

close all;

clear;

clc;

r = [0 1 1];

% 默认的旋转顺序是ZYX,所以[0 0 -90]表示绕X轴旋转90度

angle = [0 0 -90] * pi / 180;

quaternion = angle2quat(angle(1),angle(2),angle(3));

n = quatrotate(quaternion,r)


结果:

n =

         0   -1.0000    1.0000

结论:MATLAB中的默认坐标系是右手坐标系,且进行欧拉角旋转时,顺着轴的正方向来看,顺时针方向为正,逆时针方向为负。

另外,MATLAB自带rotate函数,解释如下:

rotate

Rotate object in specified direction 



Syntax

rotate(h,direction,alpha) 

rotate(...,origin) 


Description

The rotate function rotates a graphics object in three-dimensional space, according to the right-hand rule.

rotate(h,direction,alpha) rotates the graphics object h by alpha degrees. direction is a two- or three-element vector that describes the axis of rotation in conjunction with the origin.

rotate(...,origin) specifies the origin of the axis of rotation as a three-element vector. The default origin is the center of the plot box.

此旋转函数可选择三维空间中的图像,遵循右手坐标系,顺着轴的正方向来看,且逆时针方向为正,顺时针方向为负。

 


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Delphi开发 Android 程序启动画面简单完美解决方案发布时间:2022-07-18
下一篇:
delphi微服务发布时间:2022-07-18
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap