简体   繁体   English

两个多边形之间的重叠检查

[英]Overlapping check between two polygon

I have a two polygon shape draw using HTML5 canvas(GWT). 我有一个使用HTML5画布(GWT)的两个多边形形状绘制。 I have all the points for two polygon shape. 我有两个多边形的所有点。 Means I have the list of points for draw this type of polygon. 意味着我有绘制这种多边形的点列表。

Below image showing two polygon intersect or overlapping each other. 下图显示两个多边形相互交叉或重叠。 Now I am searching for a solution how to find two polygon "intersect or not" using java? 现在我正在寻找一个解决方案如何使用java找到两个多边形“相交或不相交”? I am using pure java programming without using any third library. 我使用纯java编程而不使用任何第三个库。

在此输入图像描述

I have another issue. 我有另一个问题。 For explaining this issue I am attaching another image below. 为了解释这个问题,我附上了另一张图片。

在此输入图像描述

This is the another case when one Polygon inside of another Polygon. 这是另一个Polygon内部的Polygon内部的另一种情况。 In this scenario how to calculate minimum distance between two polygon in negative? 在这种情况下如何计算两个多边形之间的最小距离为负?

Using Postgis Api Using You get Information That Two Polygon intersect or not . 使用Postgis Api使用您获得两个多边形相交或不相交的信息。 Find Following Link As Reference http://www.postgis.net/docs/ST_Intersection.html 查找以下链接作为参考http://www.postgis.net/docs/ST_Intersection.html

You can use the sweepline paradigm. 您可以使用sweepline范例。

Consider the horizontal lines passing through the vertexes of either polygons. 考虑通过任一多边形顶点的水平线。 Two consecutive lines cut out slabs (trapezoids). 连续两条线切出板(梯形)。

在此输入图像描述

As the slabs are simple, convex polygons, checking them for intersection is straightforward: it suffices to detect overlap of the bases (mind the case where they form an X cross). 由于平板是简单的凸多边形,检查它们的交叉是直截了当的:它足以检测基底的重叠(注意它们形成X交叉的情况)。

Now the whole process can be decomposed as 现在整个过程可以分解为

  • sorting the vertices of both polygons by increasing ordinates; 通过增加纵坐标来排序两个多边形的顶点; for every vertex, remember to what polygon it belongs and what are its neighbors with a higher ordinate (none, one or two); 对于每个顶点,记住它所属的多边形以及具有较高纵坐标的邻居(无,一个或两个);

  • scanning the vertices by increasing ordinate, while maintaining a list of the edges that are intersected (it is called the active list). 通过增加纵坐标扫描顶点,同时保持相交的边的列表(称为活动列表)。 Every time you move to another vertex, update the active list; 每次移动到另一个顶点时,都要更新活动列表;

  • testing the slabs for intersection. 测试板的交叉点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM