@thi.ng/geom-subdiv-curve
Version:
Freely customizable, iterative nD subdivision curves for open / closed geometries
85 lines • 3.21 kB
TypeScript
import type { ReadonlyVec } from "@thi.ng/vectors";
import type { SubdivKernel } from "./api.js";
/**
* HOF subdiv kernel function for computing 2 split points from 2 source
* points, using weighted summation (thi.ng/vectors/addW2)
*
* @param u - split coeffs
* @param v - split coeffs
*/
export declare const kernel2: ([ua, ub]: number[], [va, vb]: number[]) => ([a, b]: ReadonlyVec[]) => import("@thi.ng/vectors").Vec<number>[];
/**
* HOF subdiv kernel function for computing 2 split points from 3 source
* points, using weighted summation (thi.ng/vectors/addW3)
*
* @param u - split coeffs
* @param v - split coeffs
*/
export declare const kernel3: ([ua, ub, uc]: number[], [va, vb, vc]: number[]) => ([a, b, c]: ReadonlyVec[]) => import("@thi.ng/vectors").Vec<number>[];
/**
* HOF subdiv kernel function for computing 2 split points from 5 source
* points, using weighted summation (thi.ng/vectors/addW5)
*
* @param u - split coeffs
* @param v - split coeffs
*/
export declare const kernel5: ([ua, ub, uc, ud, ue]: number[], [va, vb, vc, vd, ve]: number[]) => ([a, b, c, d, e]: ReadonlyVec[]) => import("@thi.ng/vectors").Vec<number>[];
/**
* Splits each curve / line segment into halves at midpoint.
*/
export declare const SUBDIV_MID: SubdivKernel;
/**
* Splits each curve / line segment into 3 parts at 1/3 and 2/3.
*/
export declare const SUBDIV_THIRDS: SubdivKernel;
/**
* Chaikin subdivision scheme for open curves.
*/
export declare const SUBDIV_CHAIKIN: SubdivKernel;
/**
* Cubic bezier subdivision scheme. Currently ONLY supported for closed curves.
*/
export declare const SUBDIV_CUBIC: SubdivKernel;
/**
* Subdivision kernel for Dyn-Levin-Gregory subdivision. Currently ONLY
* supported for closed curves.
*
* @remarks
* Reference:
* https://web.archive.org/web/20060816003547/https://algorithmicbotany.org/papers/subgpu.sig2003.pdf
*/
export declare const SUBDIV_DLG: SubdivKernel;
/**
* Higher-order 2D only subdiv kernel. Takes an array of 2-tuples of `[t,x]`
* where `t` is the normalized split position (along each edge) and `x` is the
* normalized displacement amount (relative to edge length). The `closed` flag
* indicates if to be used for open/closed curves. Returns a
* {@link SubdivKernel} which results in `displace.length` points for each
* original edge and displaces each point by `displace[i][1] * edgeLength` units
* along the normal of the edge.
*
* @remarks
* The original edge end points are always remaining in place. The normalized
* split positions `t` must be in the open `(0,1)` interval.
*
* @example
* ```ts tangle:../export/subdiv-displace.ts
* import { subdivide, SUBDIV_DISPLACE } from "@thi.ng/geom-subdiv-curve";
*
* // define subdiv kernel w/ custom displacements
* const kernel = SUBDIV_DISPLACE([[0.25, 0.25], [0.75, -0.25]]);
*
* // subdivide polyline with the kernel
* console.log(
* subdivide([[0,0], [100, 100], [200, 0]], [kernel])
* );
* // [
* // [ 0, 0 ], [ 50, 0 ], [ 50, 100 ], [ 100, 100 ],
* // [100, 50 ], [ 200, 50 ], [ 200, 0 ]
* // ]
* ```
*
* @param displace
*/
export declare const SUBDIV_DISPLACE: (displace: number[][]) => SubdivKernel;
//# sourceMappingURL=kernels.d.ts.map