测试目标点是否在多边形内
int pnpoly(int nvert, float *vertx, float *verty, float testx, float testy)
{
int i, j, c = 0;
for (i = 0, j = nvert-1; i < nvert; j = i++) {
if ( ((verty[i]>testy) != (verty[j]>testy)) &&
(testx < (vertx[j]-vertx[i]) * (testy-verty[i]) / (verty[j]-verty[i]) + vertx[i]) )
c = !c;
}
return c;
}
Argument Meaning
nvert Number of vertices in the polygon. Whether to repeat the first vertex at the end is discussed below.
vertx, verty Arrays containing the x- and y-coordinates of the polygon's vertices.
testx, testy X- and y-coordinate of the test point.

http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html

PNPOLY - Point Inclusion in Polygon W. Randolph Franklin的更多相关文章

  1. PNPOLY - Point Inclusion in Polygon Test

    https://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html The C Code Here is the code, ...

  2. PNPoly算法代码例子,判断一个点是否在多边形里面

    写C语言的实验用到的一个算法,判断一个点是否在多边形的内部.C的代码如下: int pnpoly(int nvert, float *vertx, float *verty, float testx, ...

  3. Determining if a point lies on the interior of a polygon

    Determining if a point lies on the interior of a polygon Written by Paul Bourke  November 1987 Solut ...

  4. SVG & convert polygon/polyline to path

    SVG & convert polygon/polyline to path SVG Polygon/Polyline to Path Converter https://codepen.io ...

  5. lucene入门创建索引——(二)

    1.程序宏观结构图

  6. 【ASC 23】G. ACdream 1429 Rectangular Polygon --DP

    题意:有很多棍子,从棍子中选出两个棍子集合,使他们的和相等,求能取得的最多棍子数. 解法:容易看出有一个多阶段决策的过程,对于每个棍子,我们有 可以不选,或是选在第一个集合,或是选在第二个集合 这三种 ...

  7. LightOJ 1285 - Drawing Simple Polygon (几何,极角排序)

    1285 - Drawing Simple Polygon   PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: ...

  8. [算法]A General Polygon Clipping Library

    A General Polygon Clipping Library Version 2.32    http://www.cs.man.ac.uk/~toby/alan/software/gpc.h ...

  9. POJ 1179 IOI1998 Polygon

    Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 5472   Accepted: 2334 Description Polyg ...

随机推荐

  1. MySQL查询优化之explain

    在分析查询性能时,考虑EXPLAIN关键字同样很管用.EXPLAIN关键字一般放在SELECT查询语句的前面,用于描述MySQL如何执行查询操作.以及MySQL成功返回结果集需要执行的行数.expla ...

  2. HTML5数组方法

    ***************************** forEach方法 *****************************   <script>var data = [1, ...

  3. 不同分辨率下获取不同js文件

    获取当前网站的目录  //js获取网站根路径(站点及虚拟目录),获得网站的根目录或虚拟目录的根地址 function getRootPath(){ //整个域名(如:http://vc3.cn/ind ...

  4. mysql各种日志对应的配置项

    01.error_log --log-error=<file_name> 02.general_log --general-log-file=<file_name> --gen ...

  5. 局域网内IP冲突怎么办

      对于在Internet和Intranet网络上,使用TCP/IP协议时每台主机必须具有独立的IP地址,有了IP地址的主机才能与网络上的其它主机进行通讯.但IP地址冲突会造成网络客户不能正常工作,只 ...

  6. PHP设计模式之委托模式

    委托模式: 通过分配或委托至其他对象,委托设计模式能够去除核心对象中的判决和复杂的功能性. class Bank{ protected $info; /* 设置基本信息 @param string $ ...

  7. 【PAT】1025. PAT Ranking (25)

    题目链接:http://pat.zju.edu.cn/contests/pat-a-practise/1025 题目描述: Programming Ability Test (PAT) is orga ...

  8. C11 memory_order

    概念: 摘录自:http://preshing.com/20120913/acquire-and-release-semantics/ Acquire semantics is a property ...

  9. c语言_常见图片格式判断

    c语言_常见图片格式判断 我想尽各种思路.今天,终于把图片判断搞定了. 在此,我写一下我的思路.希望对那些不想看代码的朋友们有帮助. 常风的的图片格式有:bmp,png,jpg,gif等图片格式. 我 ...

  10. uva 10245 The Closest Pair Problem_枚举

    题意:求任意两点之间的距离的最少一个距离 思路:枚举一下就可以了 #include <iostream> #include<cstdio> #include<cmath& ...