Processing Geometry Suite
Hi everyone.
I’m pleased to share something I’ve been working on the past few months – a 2D computational geometry that I’ve called Processing Geometry Suite.
The focus of the library is on visualisation rather than providing underlying data structures and so all methods in the library are static and most of them take in and return PShapes
or PVectors
.
I’ve made a real effort to make it easy to pick up – it’s well documented, the Github is replete with gifs illustrating the varied functionality, and there’s a handful of example sketches included too.
It certainly shares some functionality in common with existing computational geometry libraries for Processing but there’s a lot of novel functionality introduced too. Furthermore many of the existing libraries are poorly supported and documented. All of this hopefully makes PGS a very worthwhile addition to the Processing library ecosystem.
Overview
Library functionality is split over the following classes:
-
PGS_Construction
- Construct uncommon 2D primitives
-
PGS_Contour
- Methods that produce various contours from shapes: medial axes, straight skeletons, offset curves, etc.
-
PGS_Conversion
- Conversion between PShapes and JTS Geometries
-
PGS_Morphology
- Methods that affect the geometry or topology of shapes (buffering, simplification, smoothing, etc.)
-
PGS_Optimsation
- Solve geometric optimisation problems, such as finding the maximum inscribed circle, or the closest vertex to a coordinate
-
PGS_Processing
- Methods that process a shape in some way: compute hulls, partition, slice, etc.
-
PGS_ShapeBoolean
- Boolean set-operations for 2D shapes
-
PGS_ShapePredicates
- Various shape metrics (area, circularity, etc.) and predicates (“do these shapes intersect?”)
-
PGS_Transformation
- Various geometric and affine transformations that affect vertex coordinates
-
PGS_Triangulation
- Delaunay triangulation (constrained and refined) and earcut triangulation of shapes and point sets
-
PGS_Voronoi
- Voronoi Diagrams of shapes and point sets
Installation
Processing IDE — Quick
Download the latest PGS.jar from releases and simply drag-and-drop it onto the Processing IDE.
Processing IDE — Permanently
Download the latest PGS.jar from releases and save it to Documents\Processing\libraries\PGS\library
.
Result: Documents\Processing\libraries\PGS\library\PGS.jar
.
(Note the .jar and the folder must be called PGS
— rename the .jar if this is not the case).
Examples
A number of example Processing sketches are provided in examples.
Illustrations
A few illustrations below. There are many more on the Github repo…