Package Exports
- @thi.ng/geom
- @thi.ng/geom/aabb
- @thi.ng/geom/api/aabb
- @thi.ng/geom/api/apc
- @thi.ng/geom/api/arc
- @thi.ng/geom/api/bpatch
- @thi.ng/geom/api/circle
- @thi.ng/geom/api/cubic
- @thi.ng/geom/api/ellipse
- @thi.ng/geom/api/group
- @thi.ng/geom/api/line
- @thi.ng/geom/api/path
- @thi.ng/geom/api/plane
- @thi.ng/geom/api/points
- @thi.ng/geom/api/polygon
- @thi.ng/geom/api/polyline
- @thi.ng/geom/api/quad
- @thi.ng/geom/api/quad3
- @thi.ng/geom/api/quadratic
- @thi.ng/geom/api/ray
- @thi.ng/geom/api/rect
- @thi.ng/geom/api/sphere
- @thi.ng/geom/api/text
- @thi.ng/geom/api/triangle
- @thi.ng/geom/arc
- @thi.ng/geom/arc-length
- @thi.ng/geom/area
- @thi.ng/geom/as-cubic
- @thi.ng/geom/as-path
- @thi.ng/geom/as-polygon
- @thi.ng/geom/as-polyline
- @thi.ng/geom/as-svg
- @thi.ng/geom/bounds
- @thi.ng/geom/bpatch
- @thi.ng/geom/center
- @thi.ng/geom/centroid
- @thi.ng/geom/circle
- @thi.ng/geom/classify-point
- @thi.ng/geom/clip-convex
- @thi.ng/geom/closest-point
- @thi.ng/geom/convex-hull
- @thi.ng/geom/cubic
- @thi.ng/geom/edges
- @thi.ng/geom/ellipse
- @thi.ng/geom/fit-into-bounds
- @thi.ng/geom/flip
- @thi.ng/geom/group
- @thi.ng/geom/intersects
- @thi.ng/geom/line
- @thi.ng/geom/map-point
- @thi.ng/geom/offset
- @thi.ng/geom/path
- @thi.ng/geom/path-builder
- @thi.ng/geom/path-from-svg
- @thi.ng/geom/plane
- @thi.ng/geom/point-at
- @thi.ng/geom/point-inside
- @thi.ng/geom/points
- @thi.ng/geom/polygon
- @thi.ng/geom/polyline
- @thi.ng/geom/quad
- @thi.ng/geom/quadratic
- @thi.ng/geom/ray
- @thi.ng/geom/rect
- @thi.ng/geom/resample
- @thi.ng/geom/scatter
- @thi.ng/geom/simplify
- @thi.ng/geom/sphere
- @thi.ng/geom/split-at
- @thi.ng/geom/split-near
- @thi.ng/geom/subdiv-curve
- @thi.ng/geom/tangent-at
- @thi.ng/geom/tessellate
- @thi.ng/geom/text
- @thi.ng/geom/transform
- @thi.ng/geom/transform-vertices
- @thi.ng/geom/translate
- @thi.ng/geom/triangle
- @thi.ng/geom/union
- @thi.ng/geom/unmap-point
- @thi.ng/geom/vertices
- @thi.ng/geom/volume
- @thi.ng/geom/warp-points
- @thi.ng/geom/with-attribs
Readme
This project is part of the @thi.ng/umbrella monorepo.
For the Clojure version, please visit: thi.ng/geom-clj
About
Functional, polymorphic API for 2D geometry types & SVG generation.
This project is a partially ported from the Clojure version of the same name. All polymorphic operations built on @thi.ng/defmulti.
Up-to-date feature matrix spreadsheet
This package acts as a higher-level frontend for most of the following related packages (which are more low-level, lightweight and usable by themselves too):
Support packages
- @thi.ng/geom-accel - n-D spatial indexing data structures with a shared ES6 Map/Set-like API
- @thi.ng/geom-api - Shared type & interface declarations for @thi.ng/geom packages
- @thi.ng/geom-arc - 2D circular / elliptic arc operations
- @thi.ng/geom-clip-line - 2D line clipping (Liang-Barsky)
- @thi.ng/geom-clip-poly - 2D polygon clipping / offsetting (Sutherland-Hodgeman, Grainer-Hormann)
- @thi.ng/geom-closest-point - 2D / 3D closest point / proximity helpers
- @thi.ng/geom-fuzz - Highly configurable, fuzzy line & polygon creation with presets and composable fill & stroke styles. Canvas & SVG support
- @thi.ng/geom-hull - Fast 2D convex hull (Graham Scan)
- @thi.ng/geom-io-obj - Wavefront OBJ parser (& exporter soon)
- @thi.ng/geom-isec - 2D/3D shape intersection checks
- @thi.ng/geom-isoline - Fast 2D contour line extraction / generation
- @thi.ng/geom-poly-utils - 2D polygon/polyline analysis & processing utilities
- @thi.ng/geom-resample - Customizable nD polyline interpolation, re-sampling, splitting & nearest point computation
- @thi.ng/geom-splines - nD cubic & quadratic curve analysis, conversion, interpolation, splitting
- @thi.ng/geom-subdiv-curve - Freely customizable, iterative nD subdivision curves for open / closed geometries
- @thi.ng/geom-tessellate - 2D/3D convex polygon tessellators
- @thi.ng/geom-voronoi - Fast, incremental 2D Delaunay & Voronoi mesh implementation
Status
STABLE - used in production
Search or submit any issues for this package
Installation
yarn add @thi.ng/geom
ES module import:
<script type="module" src="https://cdn.skypack.dev/@thi.ng/geom"></script>
For Node.js REPL:
# with flag only for < v16
node --experimental-repl-await
> const geom = await import("@thi.ng/geom");
Package sizes (gzipped, pre-treeshake): ESM: 12.44 KB
Dependencies
- @thi.ng/api
- @thi.ng/arrays
- @thi.ng/associative
- @thi.ng/checks
- @thi.ng/defmulti
- @thi.ng/equiv
- @thi.ng/errors
- @thi.ng/geom-api
- @thi.ng/geom-arc
- @thi.ng/geom-clip-line
- @thi.ng/geom-clip-poly
- @thi.ng/geom-closest-point
- @thi.ng/geom-hull
- @thi.ng/geom-isec
- @thi.ng/geom-poly-utils
- @thi.ng/geom-resample
- @thi.ng/geom-splines
- @thi.ng/geom-subdiv-curve
- @thi.ng/geom-tessellate
- @thi.ng/hiccup
- @thi.ng/hiccup-svg
- @thi.ng/math
- @thi.ng/matrices
- @thi.ng/random
- @thi.ng/strings
- @thi.ng/transducers
- @thi.ng/vectors
Usage examples
Several demos in this repo's /examples directory are using this package.
A selection:
Screenshot | Description | Live demo | Source |
---|---|---|---|
![]() |
Convex hull & shape clipping of 2D polygons | Demo | Source |
![]() |
geom-fuzz basic shape & fill examples | Demo | Source |
![]() |
Animated, recursive polygon tessellations | Demo | Source |
![]() |
Poisson-disk shape-aware sampling, Voronoi & Minimum Spanning Tree visualization | Demo | Source |
![]() |
Mouse gesture / stroke analysis, simplification, corner detection | Demo | Source |
![]() |
2D Bezier curve-guided particle system | Demo | Source |
![]() |
Animated arcs & drawing using hiccup-canvas | Demo | Source |
![]() |
Canvas based Immediate Mode GUI components | Demo | Source |
![]() |
Animated sine plasma effect visualized using contour lines | Demo | Source |
![]() |
2D Poisson-disc sampler with procedural gradient map | Demo | Source |
![]() |
Polygon to cubic curve conversion & visualization | Demo | Source |
![]() |
Animated Voronoi diagram, cubic splines & SVG download | Demo | Source |
![]() |
2D scenegraph & shape picking | Demo | Source |
![]() |
2D scenegraph & image map based geometry manipulation | Demo | Source |
![]() |
Compute cubic spline position & tangent using Dual Numbers | Demo | Source |
![]() |
3D wireframe textmode demo | Demo | Source |
API
TODO
Authors
Karsten Schmidt
If this project contributes to an academic publication, please cite it as:
@misc{thing-geom,
title = "@thi.ng/geom",
author = "Karsten Schmidt",
note = "https://thi.ng/geom",
year = 2013
}
License
© 2013 - 2022 Karsten Schmidt // Apache Software License 2.0