[英]Rotation / Affine matric function using affine matrix in octave / matlab
I can create a plot shown in BLUE which is correct but when I try and rotate it around 90 degrees about point (0,0) the plot in RED is created. 我可以创建显示为蓝色的图,这是正确的,但是当我尝试将其围绕点(0,0)旋转90度时,就创建了红色的图。 It should just be rotated around 90 degrees about point (0,0). 它应该仅绕点(0,0)旋转90度。 Anyone know what part of my function / code is causing the problem? 有人知道我的功能/代码的哪一部分引起了问题?
See function along with example code below: 请参见下面的函数以及示例代码:
%affine matrix rotation about a point rtaffine[theta,rpx,rpy,sigx,sigy,sigz]
%crx cry rpx rpy represent center of rotation
function [rotsig,theta,crpx,crpy,sigx,sigy,sigz] = rtaffine(theta,rpx,rpy,sigx,sigy,sigz)
rotsig=[];
%affinematrix=[];
siga=[sigx;sigy;sigz];
r00 = cosd(theta); r01 = -sind(theta); r10 = sind(theta); r11 = cosd(theta);
affinematrix = [r00, r01, rpx(1,1) - r00*rpx(1,1) - r01*rpy(1,1);...
r10, r11, rpy(1,1) - r10*rpx(1,1) - r11*rpy(1,1);...
0, 0, 1];
rotsig=affinematrix*siga; %new affine matrix
end
%radial arms
t = linspace(0,2*pi,500);
r=e^0.3063489*t;
x = r.*cos(t);
y = r.*sin(t);
plot(x,y)
hold on
%rotation
theta=90;
z = ones(size(y));
siga=[t;y;z];
rotsig=rtaffine(theta,0,0,siga(1,:),siga(2,:),siga(3,:));
plot(t(1,:),rotsig(1,:),'r-')
You are passing in t
and trying to plot against t
instead of x
in both cases: 您正在传递t
并尝试针对两种情况绘制t
而不是x
:
siga=[t;y;z];
should be 应该
siga=[x;y;z];
And 和
plot(t(1,:),rotsig(1,:),'r-')
should be 应该
plot(rotsig(1,:),rotsig(2,:),'r-')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.