connectpoly.m

本文介绍了一个MATLAB函数connectpoly,用于连接由X和Y坐标定义的多边形顶点,形成闭合的多边形边界。该函数假设输入的顶点按顺时针或逆时针顺序排列,并返回包含所有边界点的坐标序列。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

%connectpoly源程序
function c = connectpoly(x, y) 
%CONNECTPOLY Connects vertices of a polygon. 
%   C = CONNECTPOLY(X, Y) connects the points with coordinates given 
%   in X and Y with straight lines. These points are assumed to be a 
%   sequence of polygon vertices organized in the clockwise or 
%   counterclockwise direction. The output, C, is the set of points 
%   along the boundary of the polygon in the form of an nr-by-2 
%   coordinate sequence in the same direction as the input. The last 
%   point in the sequence is equal to the first. 
 
%   Copyright 2002-2004 R. C. Gonzalez, R. E. Woods, & S. L. Eddins 
%   Digital Image Processing Using MATLAB, Prentice-Hall, 2004 
%   $Revision: 1.4 $  $Date: 2003/11/21 14:29:16 $ 
 
v = [x(:), y(:)]; 
 
% Close polygon. 
if ~isequal(v(end, :), v(1, :)) 
   v(end + 1, :) = v(1, :); 
end 
 
% Connect vertices. 
segments = cell(1, length(v) - 1); 
for I = 2:length(v) 
   [x, y] = intline(v(I - 1, 1), v(I, 1), v(I - 1, 2), v(I, 2)); 
   segments{I - 1} = [x, y]; 
end 
 
c = cat(1, segments{:}); 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值