好几何库在巨蟒?

我正在寻找一个良好的和开发良好的库几何操作和评估的巨蟒,如:

  • 在2D 和3D (如果存在)中计算两条线之间的交点
  • 计算一个平面和一条直线的交点,或者两个平面的交点
  • 计算直线与点之间的最小距离
  • 求通过点的平面的正交
  • 旋转、平移、镜像一组点
  • 求由四个点定义的二面角

我有一本关于所有这些操作的汇编书,我可以实现它,但不幸的是,我没有时间,所以我会喜欢一个图书馆,这样做。大多数操作对于游戏目的是有用的,所以我确信这些功能中的一些可以在游戏库中找到,但是我宁愿不包括我不需要的功能(比如图形)。

有什么建议吗? 谢谢

76282 次浏览

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

Perhaps take a look at SymPy.

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

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.

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.

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

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.