簡體   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