简体   繁体   English

试图找到两个多边形的交点

[英]Trying to find the intersection of two polygons

I am looking for a code in JavaScript to find the intersection of two convex polygons.我正在寻找 JavaScript 中的代码来找到两个凸多边形的交点。 Suppose var poly1 = [ [x1,y1],[x2,y2],[x3,y3],[x4,y4]] and var poly2 = [ [x5,y5],[x6,y6],[x7,y7],[x8,y8]], and want to find the intersection polygon returned by the array of coordinates similar to poly1 or poly2.假设 var poly1 = [ [x1,y1],[x2,y2],[x3,y3],[x4,y4]] 和 var poly2 = [ [x5,y5],[x6,y6],[x7,y7 ],[x8,y8]],并且想要找到类似于 poly1 或 poly2 的坐标数组返回的交集多边形。

Fortunately, I found the following web site at which the code snippet for finding the intersection of two polygons are available in different programming languages.幸运的是,我找到了以下 web 站点,在该站点中,用于查找两个多边形交集的代码片段可用于不同的编程语言。 http://www.rosettacode.org/wiki/Sutherland-Hodgman_polygon_clipping#JavaScript http://www.rosettacode.org/wiki/Sutherland-Hodgman_polygon_clipping#JavaScript

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

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