Python中三维多边形的交点

Python中三维多边形的交点

本文介绍了Python中三维多边形的交点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何开源工具或库(理想情况下在Python中)可用于从ESRI shapefile中读取大量3D几何体的交集?大多数测试将是简单的线段与多边形。



我已经研究过OGR 1.7.1 / GEOS 3.2.0,并且正确加载数据,由此产生的交叉点是不正确的,其他大多数工具似乎都是基于这项工作。

虽然CGAL可以替代,但它的许可证并不适合。 Boost泛型几何库看起来很棒,但api非常庞大,并且似乎不支持开箱即用的wkt或wkb阅读器。 解决方案 div>

答案有点迟,但我的python光线追踪程序完全是这样。它可以这样工作:

1)用多个点列表定义多边形并创建一个Polygon对象

  points = [[0,0,0],[0,0.1,0],[0.1,0.1,-0.03],[0.1,0,-0.03]] 
多边形=多边形(点)


$ b 2)获取Ray对象的交点p>

  ray = Ray(position =(0,0,0),direction =(0,0,1))
print polygon.intersection(ray)


Are there any open source tools or libraries (ideally in python) that are available for performing lots of intersections with 3D geometry read from an ESRI shapefile? Most of the tests will be simple line segments vs polygons.

I've looked into OGR 1.7.1 / GEOS 3.2.0, and whilst it loads the data correctly, the resulting intersections aren't correct, and most of the other tools available seem to build on this work.

Whilst CGAL would have been an alternative, it's license isn't suitable. The Boost generic geometry library looks fantastic, but the api is huge, and doesn't seem to support wkt or wkb readers out of the box.

解决方案

A bit late on answer but my python optical ray tracing programme pvtrace does exactly this. It would work like this:

1) Define polygon with a a list of points and make a Polygon object

points = [[0,0,0],[0,0.1,0],[0.1,0.1,-0.03],[0.1,0,-0.03]]
polygon = Polygon(points)

2) Get the intersection point(s) with a Ray object

ray = Ray(position=(0,0,0), direction=(0,0,1))
print polygon.intersection(ray)

这篇关于Python中三维多边形的交点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 12:44