繁体   English   中英

在Matlab中绕y轴旋转3D点

[英]rotating a 3D point around the y axis in matlab

我已获得要使用的旋转矩阵:

矩阵

并将矩阵输入到我的函数中

theta = radians(theta);
Ry(theta) = [cos(theta) 0 sin(theta); 0 1 0; -sin(theta) 0 cos(theta)];
newpose = pos*Ry(theta);

但是无论何时函数到达此阶段,它都会返回错误

??? 下标索引必须是实数正整数或逻辑值。

任何帮助非常感谢

问题是Ry(theta) 如果希望它成为变量,则将其Ry_theta ,或将其放入实际函数中。 这应该工作:

theta = radians(theta);
Ry_theta = [cos(theta) 0 sin(theta); 0 1 0; -sin(theta) 0 cos(theta)];
newpose = pos*Ry_theta;

或者-如果您想要更可重用的解决方案:

% in your existing file:
theta = radians(theta);
newpose = pos*rotationAboutYAxis(theta);;

% in a file called rotationAboutYAxis.m:
function Ry = rotationAboutYAxis(theta)
Ry = [cos(theta) 0 sin(theta); 0 1 0; -sin(theta) 0 cos(theta)];
Ry(theta) 

theta最有可能不是实数或逻辑。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM