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

## Here is Solutions:

We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.

### Solution 1

Perhaps take a look at SymPy.

### Solution 2

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

### Solution 3

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.

### Solution 4

CGAL has Python bindings too.

### Solution 5

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:

[EDIT: I’ve now downloaded pythonocc and began working through some of the examples]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.

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.

### Solution 6

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

### Solution 7

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

### Solution 8

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.

**Note: Use and implement solution 1 because this method fully tested our system.Thank you 🙂**

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0