Oct 10, 2007, polyhedron version 0.2.1
Fixed a bug in cddlib-0.94d causing segfault when computing Vrep from a minimal number of vertices. Patched cddlib-0.94d is included.
Oct 9, 2007, polyhedron version 0.2
Made polyhedron a package. Dropped Numeric support, supporting NumPy instead. Added example.py file. The source of cddlib is now included. Using GMP is optional.
----------------------------------------------- C-Library cddlib (version 0.91) README FILE ----------------------------------------------- 1. The C-library cddlib is a C implementation of the Double Description Method of Motzkin et al. for generating all vertices (i.e. extreme points) and extreme rays of a general convex polyhedron in R^d given by a system of linear inequalities: P = { x=(x1, ..., xd)^T : b - A x >= 0 } where A is a given m x d real matrix, b is a given m-vector and 0 is the m-vector of all zeros. ...
import
polyhedron
from Python program. The package
polyhedron
provides two classes Hrep
and
Vrep
which will hold polyhedron's data.
Currently, there is no documentation available, but the code is really
simple in order to get an idea how to access polyhedron's data from Python.
See Polyhedron.__str__
method and the header of
_cddmodule.c
for more details.
Here follows an example how to construct a convex hull from a set of random points and then to test if a random point is inside or outside the hull:
from numpy import * from polyhedron import Vrep, Hrep points = random.random ((20,3)) def mkhull(points): p = Vrep (points) return Hrep (p.A, p.b) p = mkhull(points) print 'Hull vertices:\n',p.generators points2 = 1.1*random.random ((3,3)) for i in range (len (points2)): point = points2[i] if alltrue (dot (p.A,point) <= p.b): print 'point',point,'is IN' else: print 'point',point,'is OUT'
python setup.py install
to build and
install polyhedron
package.
Run python setup.py build_ext --inplace
to build
polyhedron
package in-situ.
setup.py
file properly for that).