views:

2267

answers:

5

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

+6  A: 

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

Coady
Seems to be very focused on GIS data handling, rather than pure "mathematical geometry" (so to speak)
Stefano Borini
It certainly has been created for use by the GIS community, however it is deliberately ignorant of geographic projections, which makes it fine for use as a general-purpose euclidean geometry library. I use it heavily as such in a nascent computer game project, and it works fine.
Tartley
Ah, caveat: I'm using Shapely in 2D, I cannot vouch for its abilities in 3D.
Tartley
+8  A: 

Perhaps take a look at SymPy.

John Y
It does not really satisfy my requirements, but it's indeed a cool project, so I accept your answer as an interesting suggestion also for the future (as SymPy has a geometry module, and a huge amount of developers)
Stefano Borini
+3  A: 

Take a look at NumPy to see if has what you need.

ecounysis
Could some of the people upvoting this perhaps elucidate on whether or not numpy does contain anything useful, and if so, then what?
Tartley
+5  A: 

CGAL has Python bindings too.

Vulcan Eager
+1  A: 

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

Denis