python中好的几何库?[关闭]

问题:python中好的几何库?[关闭]

我正在寻找一个良好而完善的库,用于python中的几何处理和评估,例如:

  • 评估2D和3D中两条线之间的交点(如果存在)
  • 评估一个平面和一条线之间的相交点,或两个平面之间的相交线
  • 评估线与点之间的最小距离
  • 找到通过点的平面的正交线
  • 旋转,平移,镜像一组点
  • 找出由四个点定义的二面角

我有一本关于所有这些操作的简书,虽然可以实现,但不幸的是我没有时间,所以我会喜欢做这本书的图书馆。大多数操作对于游戏目的都是有用的,因此我确信可以在游戏库中找到其中一些功能,但是我不希望不包含不需要的功能(例如图形)。

有什么建议 ?谢谢

I am looking for a good and well developed library for geometrical manipulations and evaluations in python, like:

  • evaluate the intersection between two lines in 2D and 3D (if present)
  • evaluate the point of intersection between a plane and a line, or the line of intersection between two planes
  • evaluate the minimum distance between a line and a point
  • find the orthonormal to a plane passing through a point
  • rotate, translate, mirror a set of points
  • find the dihedral angle defined by four points

I have a compendium book for all these operations, and I could implement it but unfortunately I have no time, so I would enjoy a library that does it. Most operations are useful for gaming purposes, so I am sure that some of these functionalities can be found in gaming libraries, but I would prefer not to include functionalities (such as graphics) I don’t need.

Any suggestions ? Thanks


回答 0

也许看看SymPy

Perhaps take a look at SymPy.


回答 1

Shapely是流行的GEOS库周围的一个不错的python包装器。

Shapely is a nice python wrapper around the popular GEOS library.


回答 2

我发现pyeuclid是一个很棒的简单通用欧几里得数学包。尽管该库可能未完全包含您提到的问题,但其基础结构足以使您自己编写这些问题变得容易。

I found pyeuclid to be a great simple general purpose euclidean math package. Though the library may not contain exactly the problems that you mentioned, its infrastructure is good enough to make it easy to write these on your own.


回答 3

CGAL也具有Python绑定


回答 4

geometry-simple仅使用numpy,类的点线平面运动约为300条;看一看。

geometry-simple has classes Point Line Plane Movement in ~ 300 lines, using only numpy; take a look.


回答 5

我真的想要这个问题的一个好答案,而上面的那些让我不满意。但是,我只是遇到了pythonocc,看起来很不错,除了缺少好的文档,而且安装仍然有些麻烦(尚未pypi兼容)。最近一次更新是4天前(2011年6月19日)。它包装了具有大量几何和建模功能的OpenCascade。从pythonocc网站:

pythonOCC是用于Python编程语言的3D CAD / CAE / PLM开发框架。它提供的功能包括高级拓扑和几何运算,数据交换(STEP,IGES,STL导入/导出),2D和3D网格划分,刚体模拟,参数化建模。

[编辑:我现在下载了pythonocc并开始研究一些示例]

我相信它可以执行上述所有任务,但我发现使用起来并不直观。它几乎完全由SWIG包装器创建,因此,对命令进行自省变得很困难。

I really want a good answer to this question, and the ones above left me dissatisfied. However, I just came across pythonocc which looks great, apart from lacking good docs and still having some trouble with installation (not yet pypi compatible). The last update was 4 days ago (June 19th, 2011). It wraps OpenCascade which has a ton of geometry and modeling functionality. From the pythonocc website:

pythonOCC is a 3D CAD/CAE/PLM development framework for the Python programming language. It provides features such as advanced topological and geometrical operations, data exchange (STEP, IGES, STL import/export), 2D and 3D meshing, rigid body simulation, parametric modeling.

[EDIT: I’ve now downloaded pythonocc and began working through some of the examples]

I believe it can perform all of the tasks mentioned, but I found it to be unintuitive to use. It is created almost entirely from SWIG wrappers, and as a result, introspection of the commands becomes difficult.


回答 6

您可能对OpenOpt项目http://openopt.org中的Python模块SpaceFuncs感兴趣

SpaceFuncs是2D,3D,N维几何建模的工具,可以进行参数化计算,数值优化和几何方程组求解

You may be interested in Python module SpaceFuncs from OpenOpt project, http://openopt.org

SpaceFuncs is tool for 2D, 3D, N-dimensional geometric modeling with possibilities of parametrized calculations, numerical optimization and solving systems of geometrical equations


回答 7

Python Wild Magic是另一个SWIG包装的代码。但是,它是一个游戏库,但是您可以操纵SWIG库文件以从Python API中排除任何不需要的图形内容。

Python Wild Magic is another SWIG wrapped code. It is however a gaming library, but you could manipulate the SWIG library file to exclude any undesired graphics stuff from the Python API.