我想在matlab中爲給定的簡單多邊形(無凸,無孔)創建一個緩衝區,而不使用bufferm函數。matlab中多邊形的緩衝區
vx = [ 2 4 6 4 2]; % polygon vertices
vy = [ 2 4 3 2 2];
figure;
% axis equal;
plot([vx vx(1)],[vy vy(1)],'r');
hold on;
vx = vx(end:-1:1); % Vertices in cw direction
vy = vy(end:-1:1);
xctr = mean(vx(1:end-1)); % find centroid of polygon
yctr = mean(vy(1:end-1));
sf = 2; % scale factor to extend polygon
rx = vx - xctr; % find radius
ry = vy - yctr;
angle = atand(ry/rx); % find angle
new_vx = xctr + rx * cosd(angle) * sf; % find new vertex at a distance of sf
new_vy = yctr + ry * sind(angle) * sf;
plot([new_vx new_vx(1)],[new_vy new_vy(1)], 'g');
但它錯誤地繪製。任何想法請..
你想接收緩衝區固定寬度?爲什麼沒有寬度值? – 2013-03-13 12:20:30
我已經把它作爲sf = 2 – user1785307 2013-03-13 12:24:13