Package Exports
- @thi.ng/geom-splines
- @thi.ng/geom-splines/cubic-arc
- @thi.ng/geom-splines/cubic-bounds
- @thi.ng/geom-splines/cubic-closest-point
- @thi.ng/geom-splines/cubic-from-breakpoints
- @thi.ng/geom-splines/cubic-from-controlpoints
- @thi.ng/geom-splines/cubic-line
- @thi.ng/geom-splines/cubic-quadratic
- @thi.ng/geom-splines/cubic-sample
- @thi.ng/geom-splines/cubic-split
- @thi.ng/geom-splines/cubic-tangent
- @thi.ng/geom-splines/point-at
- @thi.ng/geom-splines/quadratic-bounds
- @thi.ng/geom-splines/quadratic-closest-point
- @thi.ng/geom-splines/quadratic-line
- @thi.ng/geom-splines/quadratic-sample
- @thi.ng/geom-splines/quadratic-split
- @thi.ng/geom-splines/quadratic-tangent
Readme
[!IMPORTANT] ‼️ Announcing the thi.ng user survey 2024 📋
Please participate in the survey here!
(open until end of February)To achieve a better sample size, I'd highly appreciate if you could circulate the link to this survey in your own networks.
[!NOTE] This is one of 190 standalone projects, maintained as part of the @thi.ng/umbrella monorepo and anti-framework.
🚀 Help me to work full-time on these projects by sponsoring me on GitHub. Thank you! ❤️
About
nD cubic & quadratic curve analysis, conversion, interpolation, splitting. This is a support package for @thi.ng/geom.
Current implementations partially based on toxiclibs (Java) and Clojure version of thi.ng/geom.
Status
STABLE - used in production
Search or submit any issues for this package
Related packages
- @thi.ng/geom-subdiv-curve - Freely customizable, iterative nD subdivision curves for open / closed geometries
Installation
yarn add @thi.ng/geom-splines
ES module import:
<script type="module" src="https://cdn.skypack.dev/@thi.ng/geom-splines"></script>
For Node.js REPL:
const geomSplines = await import("@thi.ng/geom-splines");
Package sizes (brotli'd, pre-treeshake): ESM: 2.38 KB
Dependencies
- @thi.ng/api
- @thi.ng/checks
- @thi.ng/geom-api
- @thi.ng/geom-arc
- @thi.ng/geom-resample
- @thi.ng/math
- @thi.ng/vectors
Usage examples
One project in this repo's /examples directory is using this package:
Screenshot | Description | Live demo | Source |
---|---|---|---|
![]() |
Polygon to cubic curve conversion & visualization | Demo | Source |
API
Cubic curve conversion from polygons & polylines
Currently, there're two ways to convert a polygon/polyline into a sequence of cubic curve segments. Both modes support customizable curve tightness.
Furthermore, both conversion modes can be instructed to use uniformly scaled control point tangents: In uniform mode, the tangents have a uniform, user defined length, resulting in equidistant control points for each poly vertex. In non-uniform mode, each tangent is scaled by the length of its parent poly edge.
Poly vertices as control points
In this mode the curve always goes through the midpoints each polygon edge, with the original polygon vertices being used to compute control points.
Proportional tangent scale | Uniform tangent scale |
---|---|
![]() |
![]() |
Poly vertices as break points
In this mode the curve always goes through the original polygon vertices and additional control points are created via symmetric tangents at each poly vertex. The tangents themselves are computed via the bisector of each vertex corner, taking into the convexity of each poly vertex.
Proportional tangent scale | Uniform tangent scale |
---|---|
![]() |
![]() |
Authors
If this project contributes to an academic publication, please cite it as:
@misc{thing-geom-splines,
title = "@thi.ng/geom-splines",
author = "Karsten Schmidt",
note = "https://thi.ng/geom-splines",
year = 2016
}
License
© 2016 - 2024 Karsten Schmidt // Apache License 2.0