【转】判断点在多边形内(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')

【转】判断点在多边形内(matlab)的更多相关文章
- zoj 1081 判断点在多边形内
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=81Points Within Time Limit: 2 Second ...
- 判断点在多边形内算法的C++实现
目录 1. 算法思路 2. 具体实现 3. 改进空间 1. 算法思路 判断平面内点是否在多边形内有多种算法,其中射线法是其中比较好理解的一种,而且能够支持凹多边形的情况.该算法的思路很简单,就是从目标 ...
- hdu 1756:Cupid's Arrow(计算几何,判断点在多边形内)
Cupid's Arrow Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Tot ...
- php之判断点在多边形内的api
1.判断点在多边形内的数学思想:以那个点为顶点,作任意单向射线,如果它与多边形交点个数为奇数个,那么那个点在多边形内,相关公式: <?php class AreaApi{ //$area是一个多 ...
- POJ 2318 TOYS | 二分+判断点在多边形内
题意: 给一个矩形的区域(左上角为(x1,y1) 右下角为(x2,y2)),给出n对(u,v)表示(u,y1) 和 (v,y2)构成线段将矩形切割 这样构成了n+1个多边形,再给出m个点,问每个多边形 ...
- ZOJ 1081 Points Within | 判断点在多边形内
题目: 给个n个点的多边形,n个点按顺序给出,给个点m,判断m在不在多边形内部 题解: 网上有两种方法,这里写一种:射线法 大体的思想是:以这个点为端点,做一条平行与x轴的射线(代码中射线指向x轴正方 ...
- R树判断点在多边形内-Java版本
1.什么是RTree 待补充 2.RTree java依赖 rtree的java开源版本在GitHub上:https://github.com/davidmoten/rtree 上面有详细的使用说明 ...
- hdu 1756 判断点在多边形内 *
模板题 #include<cstdio> #include<iostream> #include<algorithm> #include<cstring> ...
- A Round Peg in a Ground Hole - POJ 1584 (判断凸多边形&判断点在多边形内&判断圆在多边形内)
题目大意:首先给一个圆的半径和圆心,然后给一个多边形的所有点(多边形按照顺时针或者逆时针给的),求,这个多边形是否是凸多边形,如果是凸多边形在判断这个圆是否在这个凸多边形内. 分析:判断凸多边形可 ...
- matlab inpolygon 判断点在多边形内
如何判断一个点在多边形内部? xv= [0 3 3 0 0]; %x坐标 yv= [0 0 3 3 0];%y坐标 x=1.5; y=1.5; in=inpolygon(x,y,xv,yv) plot ...
随机推荐
- mongodb 的进库操作
mongo show dbs use xxx show collections db.xxx.find() db.users.update({ "xxx" : ObjectId( ...
- [译]Dapper教程
脑子里突然浮现出一个想法:尝试翻译一些技术文档.说干就干,先来翻译个最近经常查阅的Dapper教程,有兴趣的园友可以一起参与进来 dapper-tutorial-cn. 什么是Dapper Dappe ...
- Codeforces 839A Arya and Bran【暴力】
A. Arya and Bran time limit per test:1 second memory limit per test:256 megabytes input:standard inp ...
- [bzoj4411] [Usaco2016 Feb]Load balancing
先离散化一下(也可以不用 枚举横坐标,用线段树维护两边纵坐标上的节点数. 每次在线段树上二分...(感觉似乎树状数组也行? #include<cstdio> #include<ios ...
- D. Longest Subsequence
D. Longest Subsequence time limit per test 2 seconds memory limit per test 256 megabytes input stand ...
- Logstash+Kibana部署配置
Logstash是一个接收,处理,转发日志的工具.支持系统日志,webserver日志,错误日志,应用日志,总之包括所有可以抛出来的日志类型. 典型的使用场景下(ELK): 用Elasticsearc ...
- C/C++之循环结构
C语言中提供四种循环,即goto循环.while循环.do…while循环和for循环.四种循环可以用来处理同一问题,一般情况下它们可以互相代替换,但一般不提倡用goto循环,因为强制改变程序的顺序经 ...
- RegExp对象的三个方法
RegExp 对象有 3 个方法:test().exec() 以及 compile(). test( ) test()方法检索字符串中的指定值.返回值是true或false. 例子: 因为字符 ...
- Oracle_数据库表的约束
Oracle_数据库表的约束 完整性约束分类 域完整性约束 (非空not null,检查check) 实体完整性约束 (唯一unique,主键primary key) 参照完整性约束 (外键forei ...
- 十二个 ASP.NET Core 例子——中间件
目录: 什么是中间件(IApplicationBuilder) 创建 顺序规则 Asp.Net Core 内置的中间件 1.什么是中间件 官方:中间件是组装成应用程序管道以处理请求和响应的软件.每个组 ...