使用matlab,我想要应用旋转和平移的变换包含到二维点。例如,我的观点是:
points.x=[1 5 7 100 52];
points.y=[42 96 71 3 17];
points.angle=[2 6 7 9 4];
the value of rotate is:30 degree
the value of x_translate is 5.
the value of y_translate is 54.
有没有人可以帮我写matlab代码,将这个变换应用到我的点上,并在变换后计算点的新坐标?
发布于 2016-08-15 07:30:01
我不知道您所说的points.angle
是什么意思,因为点相对于原点的角度(在三角意义上)已经由atand2(y,x)定义
代码如下:
clear;clc
oldCoord = [1 5 7 100 52;42 96 71 3 17];
newCoord = zeros(size(oldCoord));
theta = 30 * pi/180;
T = @(theta) [cos(theta), -sin(theta); sin(theta) , cos(theta)];
trans = [5;54];
for m = 1:size(oldCoord,2)
newCoord(:,m) = T(theta) * oldCoord(:,m) + trans;
end
结果:
oldCoord =
1 5 7 100 52
42 96 71 3 17
newCoord =
-15.1340 -38.6699 -24.4378 90.1025 41.5333
90.8731 139.6384 118.9878 106.5981 94.7224
https://stackoverflow.com/questions/38949947
复制相似问题