【转】判断点在多边形内(matlab)

inpolygon -Points inside polygonal region

Syntax

IN = inpolygon(X,Y,xv,yv)
[IN ON] = inpolygon(X,Y,xv,yv)

Description

IN = inpolygon(X,Y,xv,yv) returns a matrix IN the same size as X and Y. Each element of IN is assigned the value 1 or 0 depending on whether the point (X(p,q),Y(p,q)) is inside the polygonal region whose vertices are specified by the vectors xv and yv. In particular:

IN(p,q) = 1

If (X(p,q),Y(p,q)) is inside the polygonal region or on the polygon boundary

IN(p,q) = 0

If (X(p,q),Y(p,q)) is outside the polygonal region

[IN ON] = inpolygon(X,Y,xv,yv) returns a second matrix ON the same size as X and Y. Each element of ON is assigned the value 1 or 0 depending on whether the point (X(p,q),Y(p,q)) is on the boundary of the polygonal region whose vertices are specified by the vectors xv and yv. In particular:

ON(p,q) = 1

If (X(p,q),Y(p,q)) is on the polygon boundary

ON(p,q) = 0

If (X(p,q),Y(p,q)) is inside or outside the polygon boundary

Examples

L = linspace(0,2.*pi,6); xv = cos(L)';yv = sin(L)'; xv = [xv ; xv(1)]; yv = [yv ; yv(1)]; x = randn(250,1); y = randn(250,1); in = inpolygon(x,y,xv,yv); plot(xv,yv,x(in),y(in),'r+',x(~in),y(~in),'bo')

转载于:https://www.cnblogs.com/xiongyunqi/p/3737314.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值