matlab - matlab中真的没有预定义的旋转矩阵吗?
问题描述
我只是想知道,如果 MathWorks Matlab 中真的没有预定义的函数可以给你一些这样的:
R = rot(a)
与rot(a)
存在[cos(a) -sin(a); sin(a) cos(a)]
解决方案
没有内置这样的函数。但你基本上是自己写的,所以保存它(下)并调用它:rot2d()。如果您想要 3d 旋转矩阵,请发布另一个问题。如果要旋转行向量,请转置显示的矩阵,并在相乘时将向量放在矩阵之前。
function [R] = rot2d(a)
%ROT2D Return 2D rotation matrix
% Returns matrix that rotates a column vector by angle a (in radians).
% Example 1: v=[1;1]; w=rot2d(pi/4)*v; {w now = [0;1.414]}
% Example 2: Rotate 3 (or more) [x;y] pairs at a time:
% v1=[1,0]; v2=[1;1]; v3=[0;1]; vc=[v1,v2,v3]; wc=rot2d(pi/6)*vc;
% The examples show the correct multiplication order.
% Note that this is not the matrix to use if you want to express a
% vector in terms of a coordinate system rotated by angle a.
% Use w=inv(rot2d(a))*v to express vector v in a coordinate system
% rotated by a.
R = [cos(a),-sin(a);sin(a),cos(a)];
end
推荐阅读
- amazon-web-services - AWS Glue 在子级创建表
- sql - 为什么我会遇到这个错误 ORA-02264: name already used by an existing constraint 02264. 00000 - “name already used by an existing constraint” *原因?
- c# - 自定义 ScrollViewer 样式中断 RichTextBox 鼠标滚轮滚动
- c++ - 为什么交换 stl 容器很快,但移动它们却很慢?
- amazon-web-services - 通过 aws Step Functions 中的 Fail 状态传播错误消息
- node.js - 节点、集群、express 和 socket.io/sticky 上的 Socket.io 创建多个连接
- python - 部署到 Heroku 后,不读取 Dash (Plotly) 资产文件
- python - Python桌面通知程序,没有弹出通知?
- python - Pandas df.mean() 抛出 TypeError:'NoneType' 对象不可调用或返回空系列
- pandas - 使用 pandas 输出不正确的数据