我想修补点以获得一个正方形并对轴上的所有其他点执行此操作,但我想在for循环中执行此操作。此后,我将一些转换属性应用于修补点。这就是我到目前为止所做的。任何帮助将不胜感激。
whitebg('g')
axis on
% first patch point on the axis
pts2 = [0 0 1 1 0;0 1 1 0 0];
% last patch point on the axis
pts3 = [29 29 30 30 29;29 30 30 29 29];
[n m] = size(pts2);
[o p] = size(pts3);
axis([0 30 0 30])
shg
theta=0;
dx=0;
dy=0;
d=patch(pts1(1,1:end),pts1(2,1:end),'b*-');
for pts1 = pts2:pts3
if (d==patch(pts1(1,1:end),pts1(2,1:end),'b*-'))
delete(d)
end
%function to process
rot = [cosd(theta) sind(theta);-sind(theta) cosd(theta)];
trans = [1 0 dx;0 1 dy; 0 0 1];
homogeneous_rot = eye(3);
homogeneous_rot(1:2,1:2) = rot;
homogeneous_pts1 = [pts1; ones(1,5)];
trans_pts1 = trans*homogeneous_rot*homogeneous_pts1;
hold off
f=patch(trans_pts1(1,1:end),trans_pts1(2,1:end),'r*-');
draw now
end