All Projects → stephane-caron → pypoman

stephane-caron / pypoman

Licence: GPL-3.0 License
Python module for polyhedral geometry

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to pypoman

BodyParts3D
Clone of the BodyParts3D/Anatomography 3D model files
Stars: ✭ 32 (+23.08%)
Mutual labels:  geometry
pyprt
Python bindings for the "Procedural Runtime" (PRT) of CityEngine by Esri.
Stars: ✭ 36 (+38.46%)
Mutual labels:  geometry
CGAL.jl
CGAL meets Julia
Stars: ✭ 21 (-19.23%)
Mutual labels:  geometry
macuahuitl
The "Macuahuitl" Generative Art Toolbox
Stars: ✭ 68 (+161.54%)
Mutual labels:  geometry
GeoJSON4EntityFramework
Create GeoJSON from Entity Framework Spatial Data or WKT
Stars: ✭ 18 (-30.77%)
Mutual labels:  geometry
SeeThere
iOS app for identifying a location through the camera.
Stars: ✭ 18 (-30.77%)
Mutual labels:  geometry
euclid.js
2D Euclidean geometry classes, utilities, and drawing tools
Stars: ✭ 69 (+165.38%)
Mutual labels:  geometry
rgeometry
Computational Geometry library written in Rust
Stars: ✭ 77 (+196.15%)
Mutual labels:  geometry
MidcurveNN
Computation of Midcurve of Thin Polygons using Neural Networks
Stars: ✭ 19 (-26.92%)
Mutual labels:  geometry
geometry sketcher
Constraint-based geometry sketcher for blender
Stars: ✭ 1,119 (+4203.85%)
Mutual labels:  geometry
CGoGN 2
n-dimensional Meshes with Combinatorial Maps
Stars: ✭ 19 (-26.92%)
Mutual labels:  geometry
delaunator-rs
Fast 2D Delaunay triangulation in Rust. A port of Delaunator.
Stars: ✭ 115 (+342.31%)
Mutual labels:  geometry
geometer
A simple drawing program to replicate construction with a compass and straightedge
Stars: ✭ 19 (-26.92%)
Mutual labels:  geometry
adaptive-composite-map-projections
Adaptive composite map projections combine several projections
Stars: ✭ 64 (+146.15%)
Mutual labels:  projection
AdaptiveDistanceFields.jl
Adaptively sampled distance fields in Julia
Stars: ✭ 22 (-15.38%)
Mutual labels:  geometry
featool-multiphysics
FEATool - "Physics Simulation Made Easy" (Fully Integrated FEA, FEniCS, OpenFOAM, SU2 Solver GUI & Multi-Physics Simulation Platform)
Stars: ✭ 190 (+630.77%)
Mutual labels:  geometry
polytope
Geometric operations on polytopes of any dimension
Stars: ✭ 51 (+96.15%)
Mutual labels:  polyhedron
PHPCoord
PHPCoord is a PHP library to aid in handling coordinates. It can convert coordinates for a point from one system to another and also calculate distance between points
Stars: ✭ 78 (+200%)
Mutual labels:  projection
utils.js
👷 🔧 zero dependencies vanilla JavaScript utils.
Stars: ✭ 14 (-46.15%)
Mutual labels:  geometry
vos whatsapp
vangav open source - whatsapp; generated using vangav backend:
Stars: ✭ 14 (-46.15%)
Mutual labels:  geometry

Polyhedron Manipulation in Python

PyPI package Documentation Status

This library implements common operations over convex polyhedra such as polytope projection and vertex enumeration.

See the complete API documentation for details.

Installation

Make sure you have all system-wide dependencies by:

sudo apt-get install cython libglpk-dev python python-dev python-pip python-scipy

Then, install the module itself:

pip install pypoman

Examples

Vertex enumeration

We can compute the list of vertices of a polytope described in halfspace representation by A * x <= b:

from numpy import array
from pypoman import compute_polytope_vertices

A = array([
    [-1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0],
    [0, -1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0],
    [0,  0, -1,  0,  0,  0,  0,  0,  0,  0,  0,  0],
    [0,  0,  0, -1,  0,  0,  0,  0,  0,  0,  0,  0],
    [0,  0,  0,  0, -1,  0,  0,  0,  0,  0,  0,  0],
    [0,  0,  0,  0,  0, -1,  0,  0,  0,  0,  0,  0],
    [0,  0,  0,  0,  0,  0, -1,  0,  0,  0,  0,  0],
    [0,  0,  0,  0,  0,  0,  0, -1,  0,  0,  0,  0],
    [0,  0,  0,  0,  0,  0,  0,  0, -1,  0,  0,  0],
    [0,  0,  0,  0,  0,  0,  0,  0,  0, -1,  0,  0],
    [0,  0,  0,  0,  0,  0,  0,  0,  0,  0, -1,  0],
    [0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, -1],
    [1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0],
    [0,  0,  0,  1,  1,  1,  0,  0,  0,  0,  0,  0],
    [0,  0,  0,  0,  0,  0,  1,  1,  1,  0,  0,  0],
    [0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  1],
    [1,  0,  0,  1,  0,  0,  1,  0,  0,  1,  0,  0],
    [0,  1,  0,  0,  1,  0,  0,  1,  0,  0,  1,  0],
    [0,  0,  1,  0,  0,  1,  0,  0,  1,  0,  0,  1]])
b = array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 2, 2, 1, 2, 3])
vertices = compute_polytope_vertices(A, b)

Halfspace enumeration

The other way round, assume we know the vertices of a polytope, and want to get its halfspace representation A * x <= b.

from numpy import array
from pypoman import compute_polytope_halfspaces

vertices = map(array, [[1, 0, 0], [0, 1, 0], [1, 1, 0], [0, 0, 1], [0, 1, 1]])
A, b = compute_polytope_halfspaces(vertices)

Polytope projection

Let us project an n-dimensional polytope over x = [x_1 ... x_n] onto its first two coordinates proj(x) = [x_1 x_2]:

from numpy import array, eye, ones, vstack, zeros
from pypoman import plot_polygon, project_polytope

n = 10  # dimension of the original polytope
p = 2   # dimension of the projected polytope

# Original polytope:
# - inequality constraints: \forall i, |x_i| <= 1
# - equality constraint: sum_i x_i = 0
A = vstack([+eye(n), -eye(n)])
b = ones(2 * n)
C = ones(n).reshape((1, n))
d = array([0])
ineq = (A, b)  # A * x <= b
eq = (C, d)    # C * x == d

# Projection is proj(x) = [x_0 x_1]
E = zeros((p, n))
E[0, 0] = 1.
E[1, 1] = 1.
f = zeros(p)
proj = (E, f)  # proj(x) = E * x + f

vertices = project_polytope(proj, ineq, eq, method='bretl')

if __name__ == "__main__":   # plot projected polytope
    import pylab
    pylab.ion()
    pylab.figure()
    plot_polygon(vertices)

See also

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].