rotating a line using rotation matrix
5 次查看(过去 30 天)
显示 更早的评论
I have this function thats supposed to rotate a 2x2 matrix (arm) by theta.
I think i have to multiply the arm matrix by a rotation matrix to be given the new arm but i can't figure out how to do it. I keep getting error messages saying that arm and the rotation matrix is of different sizes.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/517447/image.png)
0 个评论
采纳的回答
KSSV
2021-2-12
编辑:KSSV
2021-2-12
L = rand(2,2) ; % line
% Rotation matrix
R = @(theta) [cos(theta) -sin(theta) ; sin(theta) cos(theta)] ;
% Get mean
m = mean(L) ;
L1 = m+(L-m)*R(pi/2) ; % rotate line by 45 degrees
plot(L(:,1),L(:,2),'r',L1(:,1),L1(:,2),'b')
6 个评论
Walter Roberson
2021-2-12
arm.' * R
would be 10 x 2 * 2 x 2, giving a 10 x 2 result. You could then transpose that to 2 x 10.
(arm.' * R).'
You might also be able to just use
R * arm
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 3-D Scene Control 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!