## 问题：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

Perhaps take a look at SymPy.

## 回答 1

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

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

## 回答 2

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.

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是用于Python编程语言的3D CAD / CAE / PLM开发框架。它提供的功能包括高级拓扑和几何运算，数据交换（STEP，IGES，STL导入/导出），2D和3D网格划分，刚体模拟，参数化建模。

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

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

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.