【问题标题】:rotating a 3D point around the y axis in matlab在matlab中围绕y轴旋转一个3D点
【发布时间】:2011-11-18 00:40:29
【问题描述】:

我得到了一个可以使用的旋转矩阵:

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

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

然而每当函数到达这个阶段它就会返回错误

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

非常感谢任何帮助

【问题讨论】:

标签: matlab matrix rotation


【解决方案1】:
Ry(theta) 

theta 很可能不是正整数或逻辑整数。

【讨论】:

    【解决方案2】:

    问题是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)];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-10-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-25
      相关资源
      最近更新 更多