@ac-kit/math-curves 0.1.10 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +86 -0
- package/README.md +57 -4
- package/dist/_hermite2-samples.d.ts +2 -0
- package/dist/_hermite2-samples.d.ts.map +1 -0
- package/dist/_hermite2-samples.js +34 -0
- package/dist/_hermite2-samples.js.map +1 -0
- package/dist/bezier2-flatten.d.ts +103 -0
- package/dist/bezier2-flatten.d.ts.map +1 -0
- package/dist/bezier2-flatten.js +423 -0
- package/dist/bezier2-flatten.js.map +1 -0
- package/dist/bezier2.d.ts +13 -6
- package/dist/bezier2.d.ts.map +1 -1
- package/dist/bezier2.js +29 -16
- package/dist/bezier2.js.map +1 -1
- package/dist/hermite2.d.ts +33 -0
- package/dist/hermite2.d.ts.map +1 -0
- package/dist/hermite2.js +42 -0
- package/dist/hermite2.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/spline2.d.ts +99 -0
- package/dist/spline2.d.ts.map +1 -0
- package/dist/spline2.js +319 -0
- package/dist/spline2.js.map +1 -0
- package/package.json +6 -5
package/dist/hermite2.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { assertInteger } from "@ac-kit/core";
|
|
2
|
+
import { cubicHermite2Samples_ } from "./_hermite2-samples.js";
|
|
3
|
+
/**
|
|
4
|
+
* Samples the cubic Hermite curve from `p0` to `p1` with the tangents `m0` and
|
|
5
|
+
* `m1` (derivatives with respect to the parameter `u ∈ [0, 1]`, so a tangent
|
|
6
|
+
* equal to `p1 − p0` is the straight segment's): writes the points after `p0`
|
|
7
|
+
* at `u = 1/samples, 2/samples, …, 1`, the last one being exactly `p1`, so
|
|
8
|
+
* consecutive spans chain without a duplicate, as with the Bézier `…Flatten`.
|
|
9
|
+
* The same span as the Bézier with control points `p0`, `p0 + m0/3`, `p1 −
|
|
10
|
+
* m1/3`, `p1`.
|
|
11
|
+
*
|
|
12
|
+
* Evaluated relative to `p0` in a form that keeps a flat span (equal points,
|
|
13
|
+
* zero tangents) exactly flat and a straight span (both tangents `p1 − p0`)
|
|
14
|
+
* exactly evenly spaced. Non-finite input propagates `NaN` or `Infinity`.
|
|
15
|
+
* Accurate while the points' differences and the tangents lie within about
|
|
16
|
+
* [1e−150, 1e150] (S12); tangents near `Number.MAX_VALUE` overflow before they
|
|
17
|
+
* cancel.
|
|
18
|
+
*
|
|
19
|
+
* Complexity: O(samples) time, no allocation.
|
|
20
|
+
*
|
|
21
|
+
* @param out - Destination, 2 numbers (x, y) per point.
|
|
22
|
+
* @param offset - Index in `out` of the first number written.
|
|
23
|
+
* @param p0 - Start point (not written).
|
|
24
|
+
* @param m0 - Tangent at `p0`.
|
|
25
|
+
* @param p1 - End point.
|
|
26
|
+
* @param m1 - Tangent at `p1`.
|
|
27
|
+
* @param samples - Points written, a positive integer.
|
|
28
|
+
* @returns `samples`, the point count written (`2 · samples` numbers).
|
|
29
|
+
* @throws {RangeError} When `samples` is not a positive integer, `offset` is
|
|
30
|
+
* not a non-negative integer, or `out` has fewer than `offset + 2 · samples`
|
|
31
|
+
* numbers.
|
|
32
|
+
*/
|
|
33
|
+
export function cubicHermite2Sample(out, offset, p0, m0, p1, m1, samples) {
|
|
34
|
+
assertInteger(samples, "samples", 1);
|
|
35
|
+
assertInteger(offset, "offset", 0);
|
|
36
|
+
if (offset + 2 * samples > out.length) {
|
|
37
|
+
throw new RangeError(`out needs ${offset + 2 * samples} numbers from offset ${offset} (${samples} points), has ${out.length}`);
|
|
38
|
+
}
|
|
39
|
+
cubicHermite2Samples_(out, offset, samples, p0[0], p0[1], m0[0], m0[1], p1[0], p1[1], m1[0], m1[1]);
|
|
40
|
+
return samples;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=hermite2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hermite2.js","sourceRoot":"","sources":["../src/hermite2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAG7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAE/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,UAAU,mBAAmB,CAClC,GAAiB,EACjB,MAAc,EACd,EAAgB,EAChB,EAAgB,EAChB,EAAgB,EAChB,EAAgB,EAChB,OAAe;IAEf,aAAa,CAAC,OAAO,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;IACrC,aAAa,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;IAEnC,IAAI,MAAM,GAAG,CAAC,GAAG,OAAO,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC;QACvC,MAAM,IAAI,UAAU,CACnB,aAAa,MAAM,GAAG,CAAC,GAAG,OAAO,wBAAwB,MAAM,KAAK,OAAO,iBAAiB,GAAG,CAAC,MAAM,EAAE,CACxG,CAAC;IACH,CAAC;IAED,qBAAqB,CACpB,GAAG,EACH,MAAM,EACN,OAAO,EACP,EAAE,CAAC,CAAC,CAAC,EACL,EAAE,CAAC,CAAC,CAAC,EACL,EAAE,CAAC,CAAC,CAAC,EACL,EAAE,CAAC,CAAC,CAAC,EACL,EAAE,CAAC,CAAC,CAAC,EACL,EAAE,CAAC,CAAC,CAAC,EACL,EAAE,CAAC,CAAC,CAAC,EACL,EAAE,CAAC,CAAC,CAAC,CACL,CAAC;IAEF,OAAO,OAAO,CAAC;AAChB,CAAC"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Samples the monotone cubic interpolant through points sorted by x: a
|
|
3
|
+
* piecewise cubic `y(x)` that is monotone on every run where the data is (no
|
|
4
|
+
* overshoot between points), with a continuous first derivative. Fritsch &
|
|
5
|
+
* Carlson, "Monotone piecewise cubic interpolation", SIAM J. Numer. Anal.
|
|
6
|
+
* 17(2), 1980: the tangent at a point is the mean of the two adjacent secant
|
|
7
|
+
* slopes, zero at a local extremum, then reduced where the pair of tangents
|
|
8
|
+
* leaves the monotonicity region (α² + β² > 9). End tangents are the end
|
|
9
|
+
* secants. The samples are evenly spaced in x within a span, and a flat run is
|
|
10
|
+
* exactly flat.
|
|
11
|
+
*
|
|
12
|
+
* Points must be sorted by non-decreasing x (not checked; unsorted input gives
|
|
13
|
+
* a curve that is not monotone). Two points with the same x make a vertical
|
|
14
|
+
* step: the secant slope there is taken as 0. Slopes are computed with x and y
|
|
15
|
+
* scaled by their largest step, so uniformly tiny or huge steps give a finite
|
|
16
|
+
* curve; steps whose ratio leaves [1e−150, 1e150] (a subnormal step beside a
|
|
17
|
+
* unit one) can overflow a slope.
|
|
18
|
+
*
|
|
19
|
+
* Complexity: O(n · samples) time, scratch of 2n numbers.
|
|
20
|
+
*
|
|
21
|
+
* @param out - Destination, ((n − 1) · samples + 1) points; longer is allowed
|
|
22
|
+
* and the rest is left untouched. May share memory with `points` (the points
|
|
23
|
+
* are then copied first).
|
|
24
|
+
* @param points - N points, 2 numbers (x, y) each.
|
|
25
|
+
* @param samples - Points per span, a positive integer.
|
|
26
|
+
* @returns `out`.
|
|
27
|
+
* @throws {RangeError} When `points.length` is odd, `samples` is not a positive
|
|
28
|
+
* integer, or `out` is too short.
|
|
29
|
+
*/
|
|
30
|
+
export declare function monotoneCubicSpline2<T extends Float64Array>(out: T, points: Float64Array, samples: number): T;
|
|
31
|
+
/**
|
|
32
|
+
* Samples the natural cubic spline through the points: the `C²` piecewise cubic
|
|
33
|
+
* that interpolates every point with zero second derivative at both ends, as a
|
|
34
|
+
* parametric curve `(x(s), y(s))` with the points at integer parameters (each
|
|
35
|
+
* coordinate is solved separately, the moments by `tridiagonalSolve` of
|
|
36
|
+
* `@ac-kit/math-linear`; e.g. Burden & Faires, Numerical Analysis, §3.5). The
|
|
37
|
+
* points need not be sorted. It overshoots between points where the data is not
|
|
38
|
+
* smooth; use {@link monotoneCubicSpline2} to forbid that.
|
|
39
|
+
*
|
|
40
|
+
* Complexity: O(n · samples) time, scratch of about 6n numbers.
|
|
41
|
+
*
|
|
42
|
+
* @param out - Destination, ((n − 1) · samples + 1) points; longer is allowed
|
|
43
|
+
* and the rest is left untouched. May share memory with `points` (the points
|
|
44
|
+
* are then copied first).
|
|
45
|
+
* @param points - N points, 2 numbers (x, y) each.
|
|
46
|
+
* @param samples - Points per span, a positive integer.
|
|
47
|
+
* @returns `out`.
|
|
48
|
+
* @throws {RangeError} When `points.length` is odd, `samples` is not a positive
|
|
49
|
+
* integer, or `out` is too short.
|
|
50
|
+
*/
|
|
51
|
+
export declare function naturalCubicSpline2<T extends Float64Array>(out: T, points: Float64Array, samples: number): T;
|
|
52
|
+
/**
|
|
53
|
+
* Samples the uniform cubic B-spline whose control points are the given points:
|
|
54
|
+
* a `C²` curve that approximates rather than interpolates (it is smoother than
|
|
55
|
+
* the polygon, the shape of d3's `curveBasis`). The curve is made to start at
|
|
56
|
+
* the first point and end at the last by extending the polygon with the
|
|
57
|
+
* reflections `2·P₀ − P₁` and `2·Pₙ₋₁ − Pₙ₋₂`, and runs over each span `Pᵢ →
|
|
58
|
+
* Pᵢ₊₁` with the control points `Pᵢ₋₁ … Pᵢ₊₂`; with two points it is the
|
|
59
|
+
* straight segment. (d3 instead starts with a chord to `(5·P₀ + P₁) / 6`.) The
|
|
60
|
+
* inner points are not interpolated: the curve passes through `(Pᵢ₋₁ + 4·Pᵢ +
|
|
61
|
+
* Pᵢ₊₁) / 6`. De Boor, "On calculating with B-splines", J. Approx. Theory 6, 1972.
|
|
62
|
+
*
|
|
63
|
+
* Complexity: O(n · samples) time, no allocation.
|
|
64
|
+
*
|
|
65
|
+
* @param out - Destination, ((n − 1) · samples + 1) points; longer is allowed
|
|
66
|
+
* and the rest is left untouched. May share memory with `points` (the points
|
|
67
|
+
* are then copied first).
|
|
68
|
+
* @param points - N control points, 2 numbers (x, y) each.
|
|
69
|
+
* @param samples - Points per span, a positive integer.
|
|
70
|
+
* @returns `out`.
|
|
71
|
+
* @throws {RangeError} When `points.length` is odd, `samples` is not a positive
|
|
72
|
+
* integer, or `out` is too short.
|
|
73
|
+
*/
|
|
74
|
+
export declare function uniformBSpline2<T extends Float64Array>(out: T, points: Float64Array, samples: number): T;
|
|
75
|
+
/**
|
|
76
|
+
* Samples the cardinal spline through the points: a `C¹` piecewise cubic
|
|
77
|
+
* Hermite curve interpolating every point, whose tangent at `Pᵢ` is `(1 −
|
|
78
|
+
* tension) · (Pᵢ₊₁ − Pᵢ₋₁) / 2` (the end points are repeated, so the end
|
|
79
|
+
* tangents are `(1 − tension) · (P₁ − P₀) / 2`). `tension = 0` is the uniform
|
|
80
|
+
* Catmull–Rom spline, `tension = 1` zero tangents (an eased polyline), and a
|
|
81
|
+
* negative tension loosens the curve; d3's `curveCardinal` parameterisation.
|
|
82
|
+
* The points need not be sorted. Uniform parameterisation: unevenly spaced
|
|
83
|
+
* points can overshoot or form cusps (there is no centripetal variant yet).
|
|
84
|
+
* Catmull & Rom, "A class of local interpolating splines", 1974.
|
|
85
|
+
*
|
|
86
|
+
* Complexity: O(n · samples) time, no allocation.
|
|
87
|
+
*
|
|
88
|
+
* @param out - Destination, ((n − 1) · samples + 1) points; longer is allowed
|
|
89
|
+
* and the rest is left untouched. May share memory with `points` (the points
|
|
90
|
+
* are then copied first).
|
|
91
|
+
* @param points - N points, 2 numbers (x, y) each.
|
|
92
|
+
* @param samples - Points per span, a positive integer.
|
|
93
|
+
* @param tension - Tangent shrink, usually in [0, 1].
|
|
94
|
+
* @returns `out`.
|
|
95
|
+
* @throws {RangeError} When `points.length` is odd, `samples` is not a positive
|
|
96
|
+
* integer, or `out` is too short.
|
|
97
|
+
*/
|
|
98
|
+
export declare function cardinalSpline2<T extends Float64Array>(out: T, points: Float64Array, samples: number, tension: number): T;
|
|
99
|
+
//# sourceMappingURL=spline2.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spline2.d.ts","sourceRoot":"","sources":["../src/spline2.ts"],"names":[],"mappings":"AAqDA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,YAAY,EAC1D,GAAG,EAAE,CAAC,EACN,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,MAAM,GACb,CAAC,CA8GH;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,YAAY,EACzD,GAAG,EAAE,CAAC,EACN,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,MAAM,GACb,CAAC,CA+EH;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,YAAY,EACrD,GAAG,EAAE,CAAC,EACN,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,MAAM,GACb,CAAC,CAoDH;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,YAAY,EACrD,GAAG,EAAE,CAAC,EACN,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,GACb,CAAC,CAiDH"}
|
package/dist/spline2.js
ADDED
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
import { assertInteger, viewsMayOverlap } from "@ac-kit/core";
|
|
2
|
+
import { tridiagonalSolve } from "@ac-kit/math-linear";
|
|
3
|
+
import { cubicHermite2Samples_ } from "./_hermite2-samples.js";
|
|
4
|
+
// Sampled interpolating and approximating splines through `Vec2` buffers (x, y
|
|
5
|
+
// pairs), for the line interpolations of a chart. Every function writes the
|
|
6
|
+
// first point, then `samples` points per span between consecutive input points,
|
|
7
|
+
// the last of them exactly the span's end point, so `out` holds
|
|
8
|
+
// ((n − 1) · samples + 1) points.
|
|
9
|
+
//
|
|
10
|
+
// Every span is a cubic Hermite span sampled by `cubicHermite2Samples_`, which
|
|
11
|
+
// works on differences relative to the span's start: a flat run stays exactly
|
|
12
|
+
// flat, a straight span exactly evenly spaced, and huge coordinates keep their
|
|
13
|
+
// digits. The spline coefficients are built from differences of consecutive
|
|
14
|
+
// points too, never from the coordinates themselves. The arithmetic range is
|
|
15
|
+
// that of lengths (S12): results are guaranteed while the differences between
|
|
16
|
+
// consecutive points lie within about [1e−150, 1e150]; beyond (a subnormal step
|
|
17
|
+
// beside a unit one, a 1e308 bend), a slope or tangent can overflow to
|
|
18
|
+
// Infinity or NaN. Non-finite input propagates NaN or Infinity into the output
|
|
19
|
+
// (S13).
|
|
20
|
+
function expectedLength_(name, out, points, samples) {
|
|
21
|
+
if (points.length % 2 !== 0) {
|
|
22
|
+
throw new RangeError(`${name}: points must be a multiple of 2 long.`);
|
|
23
|
+
}
|
|
24
|
+
assertInteger(samples, "samples", 1);
|
|
25
|
+
const count = points.length / 2;
|
|
26
|
+
const length = count === 0 ? 0 : ((count - 1) * samples + 1) * 2;
|
|
27
|
+
if (out.length < length) {
|
|
28
|
+
throw new RangeError(`${name}: out needs ${length} numbers for ${count} points and ${samples} samples, has ${out.length}.`);
|
|
29
|
+
}
|
|
30
|
+
return count;
|
|
31
|
+
}
|
|
32
|
+
// `points` itself, or a copy when it may share memory with `out` (the same
|
|
33
|
+
// array, overlapping views, or wrappers of one shared memory), so that writing
|
|
34
|
+
// a sample never changes a point still to be read.
|
|
35
|
+
function separate_(out, points) {
|
|
36
|
+
return viewsMayOverlap(out, points) ? points.slice() : points;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Samples the monotone cubic interpolant through points sorted by x: a
|
|
40
|
+
* piecewise cubic `y(x)` that is monotone on every run where the data is (no
|
|
41
|
+
* overshoot between points), with a continuous first derivative. Fritsch &
|
|
42
|
+
* Carlson, "Monotone piecewise cubic interpolation", SIAM J. Numer. Anal.
|
|
43
|
+
* 17(2), 1980: the tangent at a point is the mean of the two adjacent secant
|
|
44
|
+
* slopes, zero at a local extremum, then reduced where the pair of tangents
|
|
45
|
+
* leaves the monotonicity region (α² + β² > 9). End tangents are the end
|
|
46
|
+
* secants. The samples are evenly spaced in x within a span, and a flat run is
|
|
47
|
+
* exactly flat.
|
|
48
|
+
*
|
|
49
|
+
* Points must be sorted by non-decreasing x (not checked; unsorted input gives
|
|
50
|
+
* a curve that is not monotone). Two points with the same x make a vertical
|
|
51
|
+
* step: the secant slope there is taken as 0. Slopes are computed with x and y
|
|
52
|
+
* scaled by their largest step, so uniformly tiny or huge steps give a finite
|
|
53
|
+
* curve; steps whose ratio leaves [1e−150, 1e150] (a subnormal step beside a
|
|
54
|
+
* unit one) can overflow a slope.
|
|
55
|
+
*
|
|
56
|
+
* Complexity: O(n · samples) time, scratch of 2n numbers.
|
|
57
|
+
*
|
|
58
|
+
* @param out - Destination, ((n − 1) · samples + 1) points; longer is allowed
|
|
59
|
+
* and the rest is left untouched. May share memory with `points` (the points
|
|
60
|
+
* are then copied first).
|
|
61
|
+
* @param points - N points, 2 numbers (x, y) each.
|
|
62
|
+
* @param samples - Points per span, a positive integer.
|
|
63
|
+
* @returns `out`.
|
|
64
|
+
* @throws {RangeError} When `points.length` is odd, `samples` is not a positive
|
|
65
|
+
* integer, or `out` is too short.
|
|
66
|
+
*/
|
|
67
|
+
export function monotoneCubicSpline2(out, points, samples) {
|
|
68
|
+
const count = expectedLength_("monotoneCubicSpline2", out, points, samples);
|
|
69
|
+
if (count === 0) {
|
|
70
|
+
return out;
|
|
71
|
+
}
|
|
72
|
+
const source = separate_(out, points);
|
|
73
|
+
out[0] = source[0];
|
|
74
|
+
out[1] = source[1];
|
|
75
|
+
if (count === 1) {
|
|
76
|
+
return out;
|
|
77
|
+
}
|
|
78
|
+
let scaleX = 0;
|
|
79
|
+
let scaleY = 0;
|
|
80
|
+
for (let index = 0; index < count - 1; index++) {
|
|
81
|
+
scaleX = Math.max(scaleX, Math.abs(source[2 * index + 2] - source[2 * index]));
|
|
82
|
+
scaleY = Math.max(scaleY, Math.abs(source[2 * index + 3] - source[2 * index + 1]));
|
|
83
|
+
}
|
|
84
|
+
if (scaleX === 0) {
|
|
85
|
+
scaleX = 1;
|
|
86
|
+
}
|
|
87
|
+
if (scaleY === 0) {
|
|
88
|
+
scaleY = 1;
|
|
89
|
+
}
|
|
90
|
+
// Slopes in the scaled units (y / scaleY) / (x / scaleX).
|
|
91
|
+
const secants = new Float64Array(count - 1);
|
|
92
|
+
for (let index = 0; index < count - 1; index++) {
|
|
93
|
+
const dx = source[2 * index + 2] - source[2 * index];
|
|
94
|
+
secants[index] =
|
|
95
|
+
dx === 0
|
|
96
|
+
? 0
|
|
97
|
+
: (source[2 * index + 3] - source[2 * index + 1]) /
|
|
98
|
+
scaleY /
|
|
99
|
+
(dx / scaleX);
|
|
100
|
+
}
|
|
101
|
+
const tangents = new Float64Array(count);
|
|
102
|
+
tangents[0] = secants[0];
|
|
103
|
+
tangents[count - 1] = secants[count - 2];
|
|
104
|
+
for (let index = 1; index < count - 1; index++) {
|
|
105
|
+
const before = secants[index - 1];
|
|
106
|
+
const after = secants[index];
|
|
107
|
+
tangents[index] = before * after <= 0 ? 0 : (before + after) / 2;
|
|
108
|
+
}
|
|
109
|
+
for (let index = 0; index < count - 1; index++) {
|
|
110
|
+
const secant = secants[index];
|
|
111
|
+
if (secant === 0) {
|
|
112
|
+
tangents[index] = 0;
|
|
113
|
+
tangents[index + 1] = 0;
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
const alpha = tangents[index] / secant;
|
|
117
|
+
const beta = tangents[index + 1] / secant;
|
|
118
|
+
const radiusSquared = alpha * alpha + beta * beta;
|
|
119
|
+
if (radiusSquared > 9) {
|
|
120
|
+
const scale = (3 / Math.sqrt(radiusSquared)) * secant;
|
|
121
|
+
tangents[index] = scale * alpha;
|
|
122
|
+
tangents[index + 1] = scale * beta;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
let offset = 2;
|
|
126
|
+
for (let index = 0; index < count - 1; index++) {
|
|
127
|
+
const x0 = source[2 * index];
|
|
128
|
+
const x1 = source[2 * index + 2];
|
|
129
|
+
const dx = x1 - x0;
|
|
130
|
+
const step = dx / scaleX;
|
|
131
|
+
offset = cubicHermite2Samples_(out, offset, samples, x0, source[2 * index + 1], dx, tangents[index] * step * scaleY, x1, source[2 * index + 3], dx, tangents[index + 1] * step * scaleY);
|
|
132
|
+
}
|
|
133
|
+
return out;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Samples the natural cubic spline through the points: the `C²` piecewise cubic
|
|
137
|
+
* that interpolates every point with zero second derivative at both ends, as a
|
|
138
|
+
* parametric curve `(x(s), y(s))` with the points at integer parameters (each
|
|
139
|
+
* coordinate is solved separately, the moments by `tridiagonalSolve` of
|
|
140
|
+
* `@ac-kit/math-linear`; e.g. Burden & Faires, Numerical Analysis, §3.5). The
|
|
141
|
+
* points need not be sorted. It overshoots between points where the data is not
|
|
142
|
+
* smooth; use {@link monotoneCubicSpline2} to forbid that.
|
|
143
|
+
*
|
|
144
|
+
* Complexity: O(n · samples) time, scratch of about 6n numbers.
|
|
145
|
+
*
|
|
146
|
+
* @param out - Destination, ((n − 1) · samples + 1) points; longer is allowed
|
|
147
|
+
* and the rest is left untouched. May share memory with `points` (the points
|
|
148
|
+
* are then copied first).
|
|
149
|
+
* @param points - N points, 2 numbers (x, y) each.
|
|
150
|
+
* @param samples - Points per span, a positive integer.
|
|
151
|
+
* @returns `out`.
|
|
152
|
+
* @throws {RangeError} When `points.length` is odd, `samples` is not a positive
|
|
153
|
+
* integer, or `out` is too short.
|
|
154
|
+
*/
|
|
155
|
+
export function naturalCubicSpline2(out, points, samples) {
|
|
156
|
+
const count = expectedLength_("naturalCubicSpline2", out, points, samples);
|
|
157
|
+
if (count === 0) {
|
|
158
|
+
return out;
|
|
159
|
+
}
|
|
160
|
+
const source = separate_(out, points);
|
|
161
|
+
out[0] = source[0];
|
|
162
|
+
out[1] = source[1];
|
|
163
|
+
if (count === 1) {
|
|
164
|
+
return out;
|
|
165
|
+
}
|
|
166
|
+
// The second derivatives M at the inner points satisfy
|
|
167
|
+
// M_{i−1} + 4·M_i + M_{i+1} = 6 · ((P_{i+1} − P_i) − (P_i − P_{i−1})),
|
|
168
|
+
// with M_0 = M_{n−1} = 0: strictly diagonally dominant, so the Thomas
|
|
169
|
+
// algorithm is stable and meets no zero pivot.
|
|
170
|
+
const inner = count - 2;
|
|
171
|
+
const momentsX = new Float64Array(inner);
|
|
172
|
+
const momentsY = new Float64Array(inner);
|
|
173
|
+
if (inner > 0) {
|
|
174
|
+
const lower = new Float64Array(inner - 1).fill(1);
|
|
175
|
+
const diagonal = new Float64Array(inner).fill(4);
|
|
176
|
+
const upper = new Float64Array(inner - 1).fill(1);
|
|
177
|
+
const scratch = new Float64Array(inner - 1);
|
|
178
|
+
for (let index = 1; index < count - 1; index++) {
|
|
179
|
+
momentsX[index - 1] =
|
|
180
|
+
6 *
|
|
181
|
+
(source[2 * index + 2] -
|
|
182
|
+
source[2 * index] -
|
|
183
|
+
(source[2 * index] - source[2 * index - 2]));
|
|
184
|
+
momentsY[index - 1] =
|
|
185
|
+
6 *
|
|
186
|
+
(source[2 * index + 3] -
|
|
187
|
+
source[2 * index + 1] -
|
|
188
|
+
(source[2 * index + 1] - source[2 * index - 1]));
|
|
189
|
+
}
|
|
190
|
+
tridiagonalSolve(momentsX, lower, diagonal, upper, momentsX, scratch);
|
|
191
|
+
tridiagonalSolve(momentsY, lower, diagonal, upper, momentsY, scratch);
|
|
192
|
+
}
|
|
193
|
+
let offset = 2;
|
|
194
|
+
for (let index = 0; index < count - 1; index++) {
|
|
195
|
+
const startX = index === 0 ? 0 : momentsX[index - 1];
|
|
196
|
+
const startY = index === 0 ? 0 : momentsY[index - 1];
|
|
197
|
+
const endX = index === count - 2 ? 0 : momentsX[index];
|
|
198
|
+
const endY = index === count - 2 ? 0 : momentsY[index];
|
|
199
|
+
const x0 = source[2 * index];
|
|
200
|
+
const y0 = source[2 * index + 1];
|
|
201
|
+
const x1 = source[2 * index + 2];
|
|
202
|
+
const y1 = source[2 * index + 3];
|
|
203
|
+
const dx = x1 - x0;
|
|
204
|
+
const dy = y1 - y0;
|
|
205
|
+
// S(u) = (1 − u)·P_i + u·P_{i+1} + ((1 − u)³ − (1 − u))·M_i / 6 +
|
|
206
|
+
// (u³ − u)·M_{i+1} / 6, whose end derivatives are these tangents.
|
|
207
|
+
offset = cubicHermite2Samples_(out, offset, samples, x0, y0, dx - (2 * startX + endX) / 6, dy - (2 * startY + endY) / 6, x1, y1, dx + (startX + 2 * endX) / 6, dy + (startY + 2 * endY) / 6);
|
|
208
|
+
}
|
|
209
|
+
return out;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Samples the uniform cubic B-spline whose control points are the given points:
|
|
213
|
+
* a `C²` curve that approximates rather than interpolates (it is smoother than
|
|
214
|
+
* the polygon, the shape of d3's `curveBasis`). The curve is made to start at
|
|
215
|
+
* the first point and end at the last by extending the polygon with the
|
|
216
|
+
* reflections `2·P₀ − P₁` and `2·Pₙ₋₁ − Pₙ₋₂`, and runs over each span `Pᵢ →
|
|
217
|
+
* Pᵢ₊₁` with the control points `Pᵢ₋₁ … Pᵢ₊₂`; with two points it is the
|
|
218
|
+
* straight segment. (d3 instead starts with a chord to `(5·P₀ + P₁) / 6`.) The
|
|
219
|
+
* inner points are not interpolated: the curve passes through `(Pᵢ₋₁ + 4·Pᵢ +
|
|
220
|
+
* Pᵢ₊₁) / 6`. De Boor, "On calculating with B-splines", J. Approx. Theory 6, 1972.
|
|
221
|
+
*
|
|
222
|
+
* Complexity: O(n · samples) time, no allocation.
|
|
223
|
+
*
|
|
224
|
+
* @param out - Destination, ((n − 1) · samples + 1) points; longer is allowed
|
|
225
|
+
* and the rest is left untouched. May share memory with `points` (the points
|
|
226
|
+
* are then copied first).
|
|
227
|
+
* @param points - N control points, 2 numbers (x, y) each.
|
|
228
|
+
* @param samples - Points per span, a positive integer.
|
|
229
|
+
* @returns `out`.
|
|
230
|
+
* @throws {RangeError} When `points.length` is odd, `samples` is not a positive
|
|
231
|
+
* integer, or `out` is too short.
|
|
232
|
+
*/
|
|
233
|
+
export function uniformBSpline2(out, points, samples) {
|
|
234
|
+
const count = expectedLength_("uniformBSpline2", out, points, samples);
|
|
235
|
+
if (count === 0) {
|
|
236
|
+
return out;
|
|
237
|
+
}
|
|
238
|
+
const source = separate_(out, points);
|
|
239
|
+
out[0] = source[0];
|
|
240
|
+
out[1] = source[1];
|
|
241
|
+
if (count === 1) {
|
|
242
|
+
return out;
|
|
243
|
+
}
|
|
244
|
+
let offset = 2;
|
|
245
|
+
for (let index = 0; index < count - 1; index++) {
|
|
246
|
+
const x = source[2 * index];
|
|
247
|
+
const y = source[2 * index + 1];
|
|
248
|
+
const nextX = source[2 * index + 2];
|
|
249
|
+
const nextY = source[2 * index + 3];
|
|
250
|
+
// Steps of the control polygon around the span: P_{i−1} − P_i, P_{i+1} −
|
|
251
|
+
// P_i and P_{i+2} − P_{i+1}, the reflected end points giving −(P_1 − P_0)
|
|
252
|
+
// and P_{n−1} − P_{n−2}.
|
|
253
|
+
const afterX = nextX - x;
|
|
254
|
+
const afterY = nextY - y;
|
|
255
|
+
const beforeX = index === 0 ? -afterX : source[2 * index - 2] - x;
|
|
256
|
+
const beforeY = index === 0 ? -afterY : source[2 * index - 1] - y;
|
|
257
|
+
const farX = index + 2 < count ? source[2 * index + 4] - nextX : afterX;
|
|
258
|
+
const farY = index + 2 < count ? source[2 * index + 5] - nextY : afterY;
|
|
259
|
+
// The span from (P_{i−1} + 4·P_i + P_{i+1}) / 6 to (P_i + 4·P_{i+1} +
|
|
260
|
+
// P_{i+2}) / 6, with the end derivatives (P_{i+1} − P_{i−1}) / 2 and
|
|
261
|
+
// (P_{i+2} − P_i) / 2, all written through the steps.
|
|
262
|
+
offset = cubicHermite2Samples_(out, offset, samples, x + (beforeX + afterX) / 6, y + (beforeY + afterY) / 6, (afterX - beforeX) / 2, (afterY - beforeY) / 2, nextX + (farX - afterX) / 6, nextY + (farY - afterY) / 6, (afterX + farX) / 2, (afterY + farY) / 2);
|
|
263
|
+
}
|
|
264
|
+
return out;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Samples the cardinal spline through the points: a `C¹` piecewise cubic
|
|
268
|
+
* Hermite curve interpolating every point, whose tangent at `Pᵢ` is `(1 −
|
|
269
|
+
* tension) · (Pᵢ₊₁ − Pᵢ₋₁) / 2` (the end points are repeated, so the end
|
|
270
|
+
* tangents are `(1 − tension) · (P₁ − P₀) / 2`). `tension = 0` is the uniform
|
|
271
|
+
* Catmull–Rom spline, `tension = 1` zero tangents (an eased polyline), and a
|
|
272
|
+
* negative tension loosens the curve; d3's `curveCardinal` parameterisation.
|
|
273
|
+
* The points need not be sorted. Uniform parameterisation: unevenly spaced
|
|
274
|
+
* points can overshoot or form cusps (there is no centripetal variant yet).
|
|
275
|
+
* Catmull & Rom, "A class of local interpolating splines", 1974.
|
|
276
|
+
*
|
|
277
|
+
* Complexity: O(n · samples) time, no allocation.
|
|
278
|
+
*
|
|
279
|
+
* @param out - Destination, ((n − 1) · samples + 1) points; longer is allowed
|
|
280
|
+
* and the rest is left untouched. May share memory with `points` (the points
|
|
281
|
+
* are then copied first).
|
|
282
|
+
* @param points - N points, 2 numbers (x, y) each.
|
|
283
|
+
* @param samples - Points per span, a positive integer.
|
|
284
|
+
* @param tension - Tangent shrink, usually in [0, 1].
|
|
285
|
+
* @returns `out`.
|
|
286
|
+
* @throws {RangeError} When `points.length` is odd, `samples` is not a positive
|
|
287
|
+
* integer, or `out` is too short.
|
|
288
|
+
*/
|
|
289
|
+
export function cardinalSpline2(out, points, samples, tension) {
|
|
290
|
+
const count = expectedLength_("cardinalSpline2", out, points, samples);
|
|
291
|
+
if (count === 0) {
|
|
292
|
+
return out;
|
|
293
|
+
}
|
|
294
|
+
const source = separate_(out, points);
|
|
295
|
+
out[0] = source[0];
|
|
296
|
+
out[1] = source[1];
|
|
297
|
+
if (count === 1) {
|
|
298
|
+
return out;
|
|
299
|
+
}
|
|
300
|
+
const scale = (1 - tension) / 2;
|
|
301
|
+
let offset = 2;
|
|
302
|
+
for (let index = 0; index < count - 1; index++) {
|
|
303
|
+
const x0 = source[2 * index];
|
|
304
|
+
const y0 = source[2 * index + 1];
|
|
305
|
+
const x1 = source[2 * index + 2];
|
|
306
|
+
const y1 = source[2 * index + 3];
|
|
307
|
+
const stepX = x1 - x0;
|
|
308
|
+
const stepY = y1 - y0;
|
|
309
|
+
// P_{i+1} − P_{i−1} as the sum of the two steps around each end; a
|
|
310
|
+
// repeated end point contributes a zero step.
|
|
311
|
+
const beforeX = index === 0 ? 0 : x0 - source[2 * index - 2];
|
|
312
|
+
const beforeY = index === 0 ? 0 : y0 - source[2 * index - 1];
|
|
313
|
+
const afterX = index + 2 < count ? source[2 * index + 4] - x1 : 0;
|
|
314
|
+
const afterY = index + 2 < count ? source[2 * index + 5] - y1 : 0;
|
|
315
|
+
offset = cubicHermite2Samples_(out, offset, samples, x0, y0, scale * (beforeX + stepX), scale * (beforeY + stepY), x1, y1, scale * (stepX + afterX), scale * (stepY + afterY));
|
|
316
|
+
}
|
|
317
|
+
return out;
|
|
318
|
+
}
|
|
319
|
+
//# sourceMappingURL=spline2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spline2.js","sourceRoot":"","sources":["../src/spline2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,+EAA+E;AAC/E,4EAA4E;AAC5E,gFAAgF;AAChF,gEAAgE;AAChE,kCAAkC;AAClC,EAAE;AACF,+EAA+E;AAC/E,8EAA8E;AAC9E,+EAA+E;AAC/E,4EAA4E;AAC5E,6EAA6E;AAC7E,8EAA8E;AAC9E,gFAAgF;AAChF,uEAAuE;AACvE,+EAA+E;AAC/E,SAAS;AAET,SAAS,eAAe,CACvB,IAAY,EACZ,GAAiB,EACjB,MAAoB,EACpB,OAAe;IAEf,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,UAAU,CAAC,GAAG,IAAI,wCAAwC,CAAC,CAAC;IACvE,CAAC;IAED,aAAa,CAAC,OAAO,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;IAErC,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;IAChC,MAAM,MAAM,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,OAAO,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;IAEjE,IAAI,GAAG,CAAC,MAA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EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAEnE,MAAM,GAAG,qBAAqB,CAC7B,GAAG,EACH,MAAM,EACN,OAAO,EACP,EAAE,EACF,EAAE,EACF,KAAK,GAAG,CAAC,OAAO,GAAG,KAAK,CAAC,EACzB,KAAK,GAAG,CAAC,OAAO,GAAG,KAAK,CAAC,EACzB,EAAE,EACF,EAAE,EACF,KAAK,GAAG,CAAC,KAAK,GAAG,MAAM,CAAC,EACxB,KAAK,GAAG,CAAC,KAAK,GAAG,MAAM,CAAC,CACxB,CAAC;IACH,CAAC;IAED,OAAO,GAAG,CAAC;AACZ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ac-kit/math-curves",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Parametric curves: Bezier segments, splines, and evaluation, subdivision, arc length and closest point over them.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bezier",
|
|
@@ -44,15 +44,16 @@
|
|
|
44
44
|
"prepack": "yarn build"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@ac-kit/core": "^0.
|
|
48
|
-
"@ac-kit/math-linear": "^0.
|
|
49
|
-
"@ac-kit/math-scalar": "^0.2.3",
|
|
47
|
+
"@ac-kit/core": "^0.12.0",
|
|
48
|
+
"@ac-kit/math-linear": "^0.3.0",
|
|
50
49
|
"@types/web": "^0.0.367"
|
|
51
50
|
},
|
|
52
51
|
"devDependencies": {
|
|
52
|
+
"@ac-kit/math-geometry": "0.3.0",
|
|
53
|
+
"@ac-kit/math-random": "0.4.0",
|
|
53
54
|
"@ac-kit/tsconfig": "0.1.0",
|
|
54
55
|
"@ac-kit/typedoc-config": "0.1.0",
|
|
55
|
-
"@ac-kit/vitest-config": "0.
|
|
56
|
+
"@ac-kit/vitest-config": "0.2.0",
|
|
56
57
|
"@typescript/native": "typescript@7.0.2",
|
|
57
58
|
"rimraf": "6.1.4",
|
|
58
59
|
"typedoc": "0.28.20",
|