General-purpose 2D geometry libraries
The following libraries provide a wide set of basic geometric shapes and tools to manipulate them but may lack advanced features such as spatial indexing.
- Flatten-js – Good supply of basic geometric shapes such as point, vector, circle, and affine transformation matrix. Nicely separates the concepts of point and vector. Object-oriented design. Almost 200 stars at GitHub (June 2021). First commit in 2017.
- Geometric – Minimalistic. Focus on points, line segments, and polygons. Object-oriented design. Over 600 stars at GitHub (June 2021). First commit in 2018.
- Euclid.ts – Basic geometric shapes such as point, rectangle, ellipse, line, and polygon. Only light treatment of affine geometry and transformations. Immutable, object-oriented design. Written in TypeScript. First commit in 2020.
- ts-2d-geometry – Basic geometric shapes and math objects, such as point, vector, 3×3 matrix, and affine transformation. Immutable, object-oriented design. Written in TypeScript. First commit in 2020.
Libraries that focus on some aspect of 2D geometry
- detect-collisions – Detect collisions between points, circles, polygons
- SAT.js – Detect collisions between convex shapes
- Flatbush – Static spatial indexing
- rbush – Dynamic spatial indexing
- kdbush – Static spatial indexing
- point-cluster – Spatial indexing with quadtrees
- grid2 – Simple spatial indexing with grids
- snap-points-2d – Group points by pixel grid
- nudged – Estimate affine transformations between point sets
- projection-3d-2d – Perspective transformation between 3D and 2D
- transformation-matrix – Create and manipulate affine transformation matrices
- affineplane – Projections between affine 2D planes for various geometries
- d3-polygon – Polygon operations
- Hull.js – Concave hull builder
- concaveman – 2D concave hull algorithm
- point-geometry – A 2d point/vector class
- Delaunator – Delaunay triangulation of points
Libraries that focus on geospatial geometry
Geometry libraries that focus on spherical surfaces instead of pure 2D planes. We only list them here for reference.
- OpenLayers Geometry – A geographical geometry suite
- Turf.js – Geospatial analysis tools
- Google Maps Geometry – LatLng and other geospatial tools used in Google Maps JS API
- geolib – Basic geospatial operations
- JSTS – OpenLayers compatible topology suite
- spherical-geometry-js – A port of Google Maps JS API geometries
In addition to physical simulation capabilities in 2D, these libraries have a good suite of geometric shapes and collision detection tools.
Other libraries worth to mention
These libraries are not focused only to pure 2D geometry but have 2D tools worth to mention.
- Paper.js – Object model for Canvas with a suite of 2D geometry objects
- Tapspace – Zoomable UI library with a suite of 2D geometries and transformations
There are lots of 2D geometry libraries out there. Some provide a wide set of basic geometric shapes such as points, vectors, and circles while others are dedicated to certain algorithm-heavy features, such as spatial indexing. Common to all is the fact that every lib has its unique approach to geometry.
I will update the lists as new promising libraries reach my attention.