@margoengine/splines 0.0.0-stage → 1.0.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/LICENSE +201 -0
- package/NOTICE +4 -0
- package/README.md +175 -2
- package/dist/closest.d.ts +36 -0
- package/dist/closest.js +101 -0
- package/dist/fit.d.ts +29 -0
- package/dist/fit.js +175 -0
- package/dist/frames.d.ts +48 -0
- package/dist/frames.js +113 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.js +86 -0
- package/dist/kinds.d.ts +27 -0
- package/dist/kinds.js +76 -0
- package/dist/knots.d.ts +81 -0
- package/dist/knots.js +196 -0
- package/dist/mesh.d.ts +72 -0
- package/dist/mesh.js +106 -0
- package/dist/offset.d.ts +33 -0
- package/dist/offset.js +176 -0
- package/dist/polynomial-we3se7Ae.js +40 -0
- package/dist/polynomial.d.ts +6 -0
- package/dist/query.d.ts +50 -0
- package/dist/query.js +394 -0
- package/package.json +76 -4
package/dist/knots.js
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { Spline as e } from "./index.js";
|
|
2
|
+
//#region src/knots.ts
|
|
3
|
+
var t = [
|
|
4
|
+
"auto",
|
|
5
|
+
"linear",
|
|
6
|
+
"broken"
|
|
7
|
+
], n = (e, t) => {
|
|
8
|
+
if (!e || e.length !== 3 || !(Number.isFinite(e[0]) && Number.isFinite(e[1]) && Number.isFinite(e[2]))) throw TypeError(`${t} must be a finite 3D vector`);
|
|
9
|
+
return [
|
|
10
|
+
e[0],
|
|
11
|
+
e[1],
|
|
12
|
+
e[2]
|
|
13
|
+
];
|
|
14
|
+
}, r = (e, t, n) => [
|
|
15
|
+
e[0] + (t[0] - e[0]) * n,
|
|
16
|
+
e[1] + (t[1] - e[1]) * n,
|
|
17
|
+
e[2] + (t[2] - e[2]) * n
|
|
18
|
+
], i = (e, t) => [
|
|
19
|
+
e[0] + t[0],
|
|
20
|
+
e[1] + t[1],
|
|
21
|
+
e[2] + t[2]
|
|
22
|
+
], a = (e, t) => [
|
|
23
|
+
e[0] - t[0],
|
|
24
|
+
e[1] - t[1],
|
|
25
|
+
e[2] - t[2]
|
|
26
|
+
], o = class o {
|
|
27
|
+
constructor(e, { closed: t = !1 } = {}) {
|
|
28
|
+
if (this.knots = [], typeof t != "boolean") throw TypeError("closed must be a boolean");
|
|
29
|
+
this.closed = t;
|
|
30
|
+
let n = t ? 3 : 2;
|
|
31
|
+
if (e.length < n || e.length > 1e6) throw RangeError(`A ${t ? "closed" : "open"} path needs ${n} to 1,000,000 knots`);
|
|
32
|
+
for (let t of e) this.knots.push(this.make(t));
|
|
33
|
+
this.checkData(), this.freezeBroken(0, this.knots.length);
|
|
34
|
+
}
|
|
35
|
+
make(e) {
|
|
36
|
+
let r = e.mode ?? "auto";
|
|
37
|
+
if (!t.includes(r)) throw RangeError("mode must be 'auto', 'linear' or 'broken'");
|
|
38
|
+
let i = e.data ? Array.from(e.data) : [];
|
|
39
|
+
for (let e of i) if (!Number.isFinite(e)) throw RangeError("Knot data must be finite");
|
|
40
|
+
return {
|
|
41
|
+
position: n(e.position, "position"),
|
|
42
|
+
mode: r,
|
|
43
|
+
tangentIn: e.tangentIn ? n(e.tangentIn, "tangentIn") : [
|
|
44
|
+
NaN,
|
|
45
|
+
0,
|
|
46
|
+
0
|
|
47
|
+
],
|
|
48
|
+
tangentOut: e.tangentOut ? n(e.tangentOut, "tangentOut") : [
|
|
49
|
+
NaN,
|
|
50
|
+
0,
|
|
51
|
+
0
|
|
52
|
+
],
|
|
53
|
+
data: i
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
checkData() {
|
|
57
|
+
let e = this.knots[0].data.length;
|
|
58
|
+
for (let t of this.knots) if (t.data.length !== e) throw RangeError("Every knot needs the same number of data values");
|
|
59
|
+
}
|
|
60
|
+
freezeBroken(e, t) {
|
|
61
|
+
for (let n = e; n < t; n++) {
|
|
62
|
+
let e = this.knots[n];
|
|
63
|
+
if (e.mode !== "broken") continue;
|
|
64
|
+
let t = this.handles(n, !0);
|
|
65
|
+
Number.isNaN(e.tangentIn[0]) && (e.tangentIn = t.tangentIn), Number.isNaN(e.tangentOut[0]) && (e.tangentOut = t.tangentOut);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
get count() {
|
|
69
|
+
return this.knots.length;
|
|
70
|
+
}
|
|
71
|
+
get segments() {
|
|
72
|
+
return this.closed ? this.knots.length : this.knots.length - 1;
|
|
73
|
+
}
|
|
74
|
+
neighbor(e, t) {
|
|
75
|
+
let n = this.knots.length, r = e + t;
|
|
76
|
+
return this.closed ? this.knots[(r + n) % n] : this.knots[r];
|
|
77
|
+
}
|
|
78
|
+
handles(e, t = !1) {
|
|
79
|
+
let n = this.knots[e];
|
|
80
|
+
if (!n) throw RangeError("No knot at that index; pass 0 to count - 1");
|
|
81
|
+
if (n.mode === "broken" && !t) return {
|
|
82
|
+
tangentIn: [...n.tangentIn],
|
|
83
|
+
tangentOut: [...n.tangentOut]
|
|
84
|
+
};
|
|
85
|
+
let r = n.position, i = this.neighbor(e, -1)?.position, a = this.neighbor(e, 1)?.position;
|
|
86
|
+
if (n.mode === "linear" || !i || !a) {
|
|
87
|
+
let e = (e, t) => e ? [
|
|
88
|
+
(e[0] - r[0]) / 3,
|
|
89
|
+
(e[1] - r[1]) / 3,
|
|
90
|
+
(e[2] - r[2]) / 3
|
|
91
|
+
] : t ? [
|
|
92
|
+
-(t[0] - r[0]) / 3,
|
|
93
|
+
-(t[1] - r[1]) / 3,
|
|
94
|
+
-(t[2] - r[2]) / 3
|
|
95
|
+
] : [
|
|
96
|
+
0,
|
|
97
|
+
0,
|
|
98
|
+
0
|
|
99
|
+
];
|
|
100
|
+
return {
|
|
101
|
+
tangentIn: e(i, a),
|
|
102
|
+
tangentOut: e(a, i)
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
let o = [
|
|
106
|
+
(a[0] - i[0]) / 6,
|
|
107
|
+
(a[1] - i[1]) / 6,
|
|
108
|
+
(a[2] - i[2]) / 6
|
|
109
|
+
];
|
|
110
|
+
return {
|
|
111
|
+
tangentIn: [
|
|
112
|
+
-o[0],
|
|
113
|
+
-o[1],
|
|
114
|
+
-o[2]
|
|
115
|
+
],
|
|
116
|
+
tangentOut: o
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
setMode(e, r, i = {}) {
|
|
120
|
+
let a = this.knots[e];
|
|
121
|
+
if (!a) throw RangeError("No knot at that index; pass 0 to count - 1");
|
|
122
|
+
if (!t.includes(r)) throw RangeError("mode must be 'auto', 'linear' or 'broken'");
|
|
123
|
+
let o = this.handles(e);
|
|
124
|
+
a.mode = r, r === "broken" && (a.tangentIn = i.tangentIn ? n(i.tangentIn, "tangentIn") : o.tangentIn, a.tangentOut = i.tangentOut ? n(i.tangentOut, "tangentOut") : o.tangentOut);
|
|
125
|
+
}
|
|
126
|
+
insert(e, t) {
|
|
127
|
+
if (!Number.isInteger(e) || e < 0 || e > this.knots.length) throw RangeError("index must be from 0 to count");
|
|
128
|
+
if (this.knots.length >= 1e6) throw RangeError("A path holds at most 1,000,000 knots");
|
|
129
|
+
let n = this.make(t);
|
|
130
|
+
if (this.knots.length && n.data.length !== this.knots[0].data.length) throw RangeError("Every knot needs the same number of data values");
|
|
131
|
+
return this.knots.splice(e, 0, n), this.freezeBroken(e, e + 1), e;
|
|
132
|
+
}
|
|
133
|
+
insertAt(e, t, n = !0) {
|
|
134
|
+
if (!Number.isInteger(e) || e < 0 || e >= this.segments) throw RangeError("No segment at that index; pass 0 to segments - 1");
|
|
135
|
+
if (!Number.isFinite(t) || t <= 0 || t >= 1) throw RangeError("u must be between 0 and 1, exclusive");
|
|
136
|
+
let o = this.knots.length, s = this.knots[e], c = (e + 1) % o, l = this.knots[c], u = this.handles(e), d = this.handles(c), f = s.position, p = l.position, m = i(f, u.tangentOut), h = i(p, d.tangentIn), g = r(f, m, t), _ = r(m, h, t), v = r(h, p, t), y = r(g, _, t), b = r(_, v, t), x = r(y, b, t), S = s.data.map((e, n) => e + (l.data[n] - e) * t);
|
|
137
|
+
n && (this.setMode(e, "broken"), this.setMode(c, "broken"), s.tangentOut = a(g, f), l.tangentIn = a(v, p));
|
|
138
|
+
let C = {
|
|
139
|
+
position: x,
|
|
140
|
+
mode: n ? "broken" : "auto",
|
|
141
|
+
tangentIn: a(y, x),
|
|
142
|
+
tangentOut: a(b, x),
|
|
143
|
+
data: S
|
|
144
|
+
};
|
|
145
|
+
return this.knots.splice(e + 1, 0, C), e + 1;
|
|
146
|
+
}
|
|
147
|
+
remove(e) {
|
|
148
|
+
let t = this.closed ? 3 : 2;
|
|
149
|
+
if (!Number.isInteger(e) || e < 0 || e >= this.knots.length) throw RangeError("No knot at that index; pass 0 to count - 1");
|
|
150
|
+
if (this.knots.length <= t) throw RangeError(`A ${this.closed ? "closed" : "open"} path needs at least ${t} knots`);
|
|
151
|
+
this.knots.splice(e, 1);
|
|
152
|
+
}
|
|
153
|
+
split(e) {
|
|
154
|
+
let t = this.knots.length;
|
|
155
|
+
if (!Number.isInteger(e) || e < 0 || e >= t) throw RangeError("No knot at that index; pass 0 to count - 1");
|
|
156
|
+
let n = (e) => {
|
|
157
|
+
let t = this.knots[e];
|
|
158
|
+
return {
|
|
159
|
+
position: t.position,
|
|
160
|
+
mode: "broken",
|
|
161
|
+
...this.handles(e),
|
|
162
|
+
data: t.data
|
|
163
|
+
};
|
|
164
|
+
}, r = (e) => new o(e.map(n), {});
|
|
165
|
+
if (this.closed) {
|
|
166
|
+
let n = [];
|
|
167
|
+
for (let r = 0; r <= t; r++) n.push((e + r) % t);
|
|
168
|
+
return [r(n)];
|
|
169
|
+
}
|
|
170
|
+
if (e === 0 || e === t - 1) throw RangeError("An open path can only be split at an interior knot; pass 1 to count - 2");
|
|
171
|
+
let i = [], a = [];
|
|
172
|
+
for (let t = 0; t <= e; t++) i.push(t);
|
|
173
|
+
for (let n = e; n < t; n++) a.push(n);
|
|
174
|
+
return [r(i), r(a)];
|
|
175
|
+
}
|
|
176
|
+
dataAt(e, t = []) {
|
|
177
|
+
if (!Number.isFinite(e) || e < 0 || e > 1) throw RangeError("Curve parameter must be 0..1");
|
|
178
|
+
let n = this.segments, r = e * n, i = Math.min(n - 1, Math.floor(r)), a = r - i, o = this.knots[i].data, s = this.knots[(i + 1) % this.knots.length].data;
|
|
179
|
+
t.length = o.length;
|
|
180
|
+
for (let e = 0; e < o.length; e++) t[e] = o[e] + (s[e] - o[e]) * a;
|
|
181
|
+
return t;
|
|
182
|
+
}
|
|
183
|
+
toSpline(t = {}) {
|
|
184
|
+
let n = this.knots.length, r = [];
|
|
185
|
+
for (let e = 0; e < this.segments; e++) {
|
|
186
|
+
let t = this.knots[e], a = this.knots[(e + 1) % n];
|
|
187
|
+
r.push(t.position, i(t.position, this.handles(e).tangentOut), i(a.position, this.handles((e + 1) % n).tangentIn));
|
|
188
|
+
}
|
|
189
|
+
return r.push(this.knots[this.closed ? 0 : n - 1].position), new e(r, {
|
|
190
|
+
...t,
|
|
191
|
+
kind: "bezier"
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
//#endregion
|
|
196
|
+
export { o as KnotPath };
|
package/dist/mesh.d.ts
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { Spline } from './index.js';
|
|
2
|
+
import { SplineFrames, type SplineFrame, type SplineFramesOptions } from './frames.js';
|
|
3
|
+
/** Which local axis of the placed or bent mesh runs along the spline. */
|
|
4
|
+
export type ForwardAxis = 'x' | 'y' | 'z';
|
|
5
|
+
/** Frames to use: a ready {@link SplineFrames}, or options to build them from the spline. */
|
|
6
|
+
export type SplineFrameSource = SplineFrames | SplineFramesOptions;
|
|
7
|
+
/**
|
|
8
|
+
* The rotation that puts a mesh's `forward` axis along a frame's tangent and its up axis on the frame normal: 9 numbers,
|
|
9
|
+
* three columns, x then y then z, the same turn {@link placeAlongSpline} gives its instances.
|
|
10
|
+
* @throws RangeError for an unknown axis.
|
|
11
|
+
*/
|
|
12
|
+
export declare function frameBasis(frame: SplineFrame, forward?: ForwardAxis, out?: Float64Array): Float64Array;
|
|
13
|
+
/** Options for {@link placeAlongSpline}. */
|
|
14
|
+
export interface SplinePlaceOptions {
|
|
15
|
+
/** Distance between instances, above 0. Give this or `count`. */
|
|
16
|
+
spacing?: number;
|
|
17
|
+
/** Number of instances, an integer 1..1,000,000; spread evenly from `start` to `end`. Give this or `spacing`. */
|
|
18
|
+
count?: number;
|
|
19
|
+
/** Arc-length position of the first instance. Default 0. */
|
|
20
|
+
start?: number;
|
|
21
|
+
/** Arc-length position the run stops at. Default the spline length. */
|
|
22
|
+
end?: number;
|
|
23
|
+
/** With `spacing`: stretch the gaps slightly so the last instance sits exactly on `end`. Default false. */
|
|
24
|
+
fit?: boolean;
|
|
25
|
+
/** Local axis that points along the spline. Default 'z'. */
|
|
26
|
+
forward?: ForwardAxis;
|
|
27
|
+
/** Uniform scale or per-axis scale of every instance. Default 1. */
|
|
28
|
+
scale?: number | ArrayLike<number>;
|
|
29
|
+
/** Keep instances upright and facing the same way instead of following the curve. Default false. */
|
|
30
|
+
align?: boolean;
|
|
31
|
+
frames?: SplineFrameSource;
|
|
32
|
+
}
|
|
33
|
+
/** Matrices from {@link placeAlongSpline}: `count` column-major 4x4 matrices in one array. */
|
|
34
|
+
export interface SplinePlacement {
|
|
35
|
+
count: number;
|
|
36
|
+
/** 16 numbers per instance, ready for an instance buffer. */
|
|
37
|
+
matrices: Float32Array;
|
|
38
|
+
/** Arc-length position of each instance. */
|
|
39
|
+
distances: Float64Array;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Instance matrices at a spacing along a spline, for fences, rails, lamp posts and the like. Each matrix puts the
|
|
43
|
+
* mesh's `forward` axis along the tangent and its up axis on the frame normal, so the run follows hills and turns
|
|
44
|
+
* without flipping (see {@link SplineFrames}); `align: false` keeps every instance upright with no turning at all.
|
|
45
|
+
*/
|
|
46
|
+
export declare function placeAlongSpline(spline: Spline, options: SplinePlaceOptions): SplinePlacement;
|
|
47
|
+
/** Options for {@link deformAlongSpline}. */
|
|
48
|
+
export interface SplineDeformOptions {
|
|
49
|
+
/** Local axis of the mesh that runs along the spline. Default 'z'. */
|
|
50
|
+
axis?: ForwardAxis;
|
|
51
|
+
/** Arc-length position the mesh's low end sits at. Default 0. */
|
|
52
|
+
offset?: number;
|
|
53
|
+
/** 'none' keeps the mesh's own length; 'stretch' scales its length to run from `offset` to the spline's end. Default 'none'. */
|
|
54
|
+
fit?: 'none' | 'stretch';
|
|
55
|
+
/** Past the spline's ends: 'clamp' holds the end frame (the mesh squashes flat), 'extend' continues straight along the end tangent. Default 'extend'. */
|
|
56
|
+
overflow?: 'clamp' | 'extend';
|
|
57
|
+
/** Unit normals (3 per vertex) to rotate with the bend. */
|
|
58
|
+
normals?: ArrayLike<number>;
|
|
59
|
+
frames?: SplineFrameSource;
|
|
60
|
+
}
|
|
61
|
+
/** Result of {@link deformAlongSpline}. */
|
|
62
|
+
export interface SplineDeformed {
|
|
63
|
+
positions: Float32Array | Float64Array;
|
|
64
|
+
/** Present when `normals` was given. Rotated with the frame, not re-derived, so a hard bend leaves them slightly off. */
|
|
65
|
+
normals?: Float32Array | Float64Array;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Bend a mesh along a spline, for pipes, roads and rails. The vertex position along `axis` becomes a distance along
|
|
69
|
+
* the curve, and its other two coordinates become offsets in the frame there. A mesh that is long and straight
|
|
70
|
+
* along its axis follows the curve; one with few segments bends in straight chords, so subdivide it first.
|
|
71
|
+
*/
|
|
72
|
+
export declare function deformAlongSpline(spline: Spline, positions: ArrayLike<number>, options?: SplineDeformOptions): SplineDeformed;
|
package/dist/mesh.js
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { SplineFrames as e, newFrame as t } from "./frames.js";
|
|
2
|
+
//#region src/mesh.ts
|
|
3
|
+
var n = {
|
|
4
|
+
x: {
|
|
5
|
+
f: 0,
|
|
6
|
+
u: 1,
|
|
7
|
+
w: 2,
|
|
8
|
+
sign: 1
|
|
9
|
+
},
|
|
10
|
+
y: {
|
|
11
|
+
f: 1,
|
|
12
|
+
u: 2,
|
|
13
|
+
w: 0,
|
|
14
|
+
sign: 1
|
|
15
|
+
},
|
|
16
|
+
z: {
|
|
17
|
+
f: 2,
|
|
18
|
+
u: 1,
|
|
19
|
+
w: 0,
|
|
20
|
+
sign: -1
|
|
21
|
+
}
|
|
22
|
+
}, r = (e) => {
|
|
23
|
+
let t = n[e];
|
|
24
|
+
if (!t) throw RangeError("axis must be 'x', 'y' or 'z'");
|
|
25
|
+
return t;
|
|
26
|
+
}, i = (t, n) => n instanceof e ? n : new e(t, n), a = (e, t, n) => {
|
|
27
|
+
for (let r = 0; r < 3; r++) n[t.f * 3 + r] = e.tangent[r], n[t.u * 3 + r] = e.normal[r], n[t.w * 3 + r] = e.binormal[r] * t.sign;
|
|
28
|
+
};
|
|
29
|
+
function o(e, t = "z", n = /* @__PURE__ */ new Float64Array(9)) {
|
|
30
|
+
return a(e, r(t), n), n;
|
|
31
|
+
}
|
|
32
|
+
function s(e, n) {
|
|
33
|
+
let { spacing: o, count: s, start: c = 0, forward: l = "z", fit: u = !1, align: d = !0, scale: f = 1 } = n, p = r(l), m = n.end ?? e.length;
|
|
34
|
+
if (o === void 0 == (s === void 0)) throw RangeError("Give exactly one of spacing or count");
|
|
35
|
+
if (!(Number.isFinite(c) && Number.isFinite(m)) || c < 0 || m > e.length || m < c) throw RangeError("start and end must satisfy 0 <= start <= end <= spline length");
|
|
36
|
+
let h = typeof f == "number" ? [
|
|
37
|
+
f,
|
|
38
|
+
f,
|
|
39
|
+
f
|
|
40
|
+
] : Array.from(f);
|
|
41
|
+
if (h.length !== 3 || !h.every(Number.isFinite)) throw RangeError("scale must be a finite number or 3 numbers");
|
|
42
|
+
let g, _;
|
|
43
|
+
if (s !== void 0) {
|
|
44
|
+
if (!Number.isInteger(s) || s < 1 || s > 1e6) throw RangeError("count must be an integer from 1 to 1,000,000");
|
|
45
|
+
g = s, _ = g > 1 ? (m - c) / (g - 1) : 0;
|
|
46
|
+
} else {
|
|
47
|
+
if (!(Number.isFinite(o) && o > 0)) throw RangeError("spacing must be above 0");
|
|
48
|
+
let e = (m - c) / o;
|
|
49
|
+
if (e > 1e6) throw RangeError("That spacing gives more than 1,000,000 instances; raise spacing or shorten the run");
|
|
50
|
+
g = Math.floor(e + 1e-9) + 1, _ = u && g > 1 ? (m - c) / (g - 1) : o;
|
|
51
|
+
}
|
|
52
|
+
let v = i(e, n.frames), y = t(), b = /* @__PURE__ */ new Float64Array(9), x = new Float32Array(g * 16), S = new Float64Array(g);
|
|
53
|
+
for (let t = 0; t < g; t++) {
|
|
54
|
+
let n = Math.min(e.length, c + t * _);
|
|
55
|
+
S[t] = n, v.frameAt(n, y), d ? a(y, p, b) : b.set([
|
|
56
|
+
1,
|
|
57
|
+
0,
|
|
58
|
+
0,
|
|
59
|
+
0,
|
|
60
|
+
1,
|
|
61
|
+
0,
|
|
62
|
+
0,
|
|
63
|
+
0,
|
|
64
|
+
1
|
|
65
|
+
]);
|
|
66
|
+
let r = t * 16;
|
|
67
|
+
for (let e = 0; e < 3; e++) for (let t = 0; t < 3; t++) x[r + e * 4 + t] = b[e * 3 + t] * h[e];
|
|
68
|
+
x[r + 12] = y.position[0], x[r + 13] = y.position[1], x[r + 14] = y.position[2], x[r + 15] = 1;
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
count: g,
|
|
72
|
+
matrices: x,
|
|
73
|
+
distances: S
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function c(e, n, o = {}) {
|
|
77
|
+
let { axis: s = "z", offset: c = 0, fit: l = "none", overflow: u = "extend", normals: d } = o, f = r(s);
|
|
78
|
+
if (n.length % 3) throw RangeError("positions must hold 3 numbers per vertex");
|
|
79
|
+
if (d && d.length !== n.length) throw RangeError("normals must match positions in length");
|
|
80
|
+
if (!Number.isFinite(c) || c < 0 || c > e.length) throw RangeError("offset must be within the spline length");
|
|
81
|
+
if (l !== "none" && l !== "stretch") throw RangeError("fit must be 'none' or 'stretch'");
|
|
82
|
+
if (u !== "clamp" && u !== "extend") throw RangeError("overflow must be 'clamp' or 'extend'");
|
|
83
|
+
let p = n.length / 3, m = Infinity, h = -Infinity;
|
|
84
|
+
for (let e = 0; e < p; e++) {
|
|
85
|
+
let t = n[e * 3 + f.f];
|
|
86
|
+
if (!Number.isFinite(t) || !Number.isFinite(n[e * 3 + f.u]) || !Number.isFinite(n[e * 3 + f.w])) throw RangeError("positions must be finite");
|
|
87
|
+
t < m && (m = t), t > h && (h = t);
|
|
88
|
+
}
|
|
89
|
+
let g = l === "stretch" && h > m ? (e.length - c) / (h - m) : 1, _ = i(e, o.frames), v = n instanceof Float64Array || d instanceof Float64Array, y = v ? new Float64Array(n.length) : new Float32Array(n.length), b = d ? v ? new Float64Array(n.length) : new Float32Array(n.length) : void 0, x = /* @__PURE__ */ new Float64Array(9), S = /* @__PURE__ */ new Map();
|
|
90
|
+
for (let r = 0; r < p; r++) {
|
|
91
|
+
let i = r * 3, o = c + (n[i + f.f] - m) * g, s = Math.min(e.length, Math.max(0, o)), l = o, p = S.get(l);
|
|
92
|
+
p || (p = {
|
|
93
|
+
frame: _.frameAt(s, t()),
|
|
94
|
+
extra: u === "extend" ? o - s : 0
|
|
95
|
+
}, S.set(l, p)), a(p.frame, f, x);
|
|
96
|
+
let h = p.extra, v = n[i + f.u], C = n[i + f.w];
|
|
97
|
+
for (let e = 0; e < 3; e++) y[i + e] = p.frame.position[e] + h * p.frame.tangent[e] + v * x[f.u * 3 + e] + C * x[f.w * 3 + e];
|
|
98
|
+
if (d && b) for (let e = 0; e < 3; e++) b[i + e] = d[i + f.f] * x[f.f * 3 + e] + d[i + f.u] * x[f.u * 3 + e] + d[i + f.w] * x[f.w * 3 + e];
|
|
99
|
+
}
|
|
100
|
+
return b ? {
|
|
101
|
+
positions: y,
|
|
102
|
+
normals: b
|
|
103
|
+
} : { positions: y };
|
|
104
|
+
}
|
|
105
|
+
//#endregion
|
|
106
|
+
export { c as deformAlongSpline, o as frameBasis, s as placeAlongSpline };
|
package/dist/offset.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Spline } from './index.js';
|
|
2
|
+
import { CubicSpline } from './kinds.js';
|
|
3
|
+
/** Parallel-curve fitting options; all distances use the source's world units. */
|
|
4
|
+
export interface SplineOffsetOptions {
|
|
5
|
+
/** Reference-plane normal; positive offset is normal cross tangent. Default [0,0,1]. */
|
|
6
|
+
normal?: ArrayLike<number>;
|
|
7
|
+
/** Conservative spatial error bound for the returned cubic approximation. Default 0.001. */
|
|
8
|
+
tolerance?: number;
|
|
9
|
+
/** Maximum fitting subdivisions per source piece. Default 20. */
|
|
10
|
+
maxDepth?: number;
|
|
11
|
+
/** Maximum output cubic pieces. Default 16384. */
|
|
12
|
+
maxSegments?: number;
|
|
13
|
+
/** Maximum interval verification nodes. Default 1000000. */
|
|
14
|
+
maxWork?: number;
|
|
15
|
+
/** Arc-length lookup resolution for the result. Default max(256,8*pieces), capped at 1000000. */
|
|
16
|
+
divisions?: number;
|
|
17
|
+
}
|
|
18
|
+
/** Cubic offset approximation with source-parameter mapping and a conservative verified error bound. */
|
|
19
|
+
export interface SplineOffsetResult {
|
|
20
|
+
spline: CubicSpline;
|
|
21
|
+
/** Source t0,t1 for each output piece; a zero-width range denotes a bevel join. */
|
|
22
|
+
ranges: Float64Array;
|
|
23
|
+
/** Maximum interval enclosure of approximation error, including roundoff allowance; excludes bevel joins. */
|
|
24
|
+
maxError: number;
|
|
25
|
+
/** Deterministic interval verification work, not elapsed time. */
|
|
26
|
+
work: number;
|
|
27
|
+
}
|
|
28
|
+
/** Exact signed-distance offset at a source parameter; no polynomial approximation or arc-length remapping. */
|
|
29
|
+
export declare function offsetSplineAt(spline: Spline, t: number, distance: number, normal?: ArrayLike<number>, output?: Float64Array<ArrayBuffer>): Float64Array;
|
|
30
|
+
/** Build cubic parallel pieces; interval verification bounds error everywhere, including between fit samples. */
|
|
31
|
+
export declare function offsetSpline(source: Spline, distance: number, options?: SplineOffsetOptions): SplineOffsetResult;
|
|
32
|
+
/** Reverse every cubic exactly, preserving source geometry, closure and global t -> 1-t correspondence. */
|
|
33
|
+
export declare function reverseSpline(source: Spline): CubicSpline;
|
package/dist/offset.js
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { a as e, i as t, n, r, t as i } from "./polynomial-we3se7Ae.js";
|
|
2
|
+
import { CubicSpline as a } from "./kinds.js";
|
|
3
|
+
//#region src/offset.ts
|
|
4
|
+
var o = (e, t) => e[0] * t[0] + e[1] * t[1] + e[2] * t[2];
|
|
5
|
+
function s(e) {
|
|
6
|
+
i(e);
|
|
7
|
+
let t = Math.hypot(e[0], e[1], e[2]);
|
|
8
|
+
if (!t) throw RangeError("Invalid offset normal; pass a nonzero plane normal.");
|
|
9
|
+
return Float64Array.from(e, (e) => e / t);
|
|
10
|
+
}
|
|
11
|
+
function c(e, n, i, a) {
|
|
12
|
+
let s = t(e, n, 0), c = t(e, n, 1);
|
|
13
|
+
if (!i) return [s, c];
|
|
14
|
+
let l = r(a, c), u = r(a, t(e, n, 2)), d = Math.hypot(...l);
|
|
15
|
+
if (!d) throw Object.assign(/* @__PURE__ */ RangeError("Offset normal is undefined; remove stationary points or choose a normal transverse to the tangent."), { code: "singular" });
|
|
16
|
+
let f = o(l, u) / d ** 3;
|
|
17
|
+
for (let e = 0; e < 3; e++) s[e] += i * l[e] / d, c[e] += i * (u[e] / d - l[e] * f);
|
|
18
|
+
return [s, c];
|
|
19
|
+
}
|
|
20
|
+
function l(t, r, i, a = [
|
|
21
|
+
0,
|
|
22
|
+
0,
|
|
23
|
+
1
|
|
24
|
+
], o = /* @__PURE__ */ new Float64Array(3)) {
|
|
25
|
+
if (!Number.isFinite(i) || !Number.isFinite(r) || r < 0 || r > 1 || o.length !== 3) throw RangeError("Invalid offset point; pass finite distance, t in 0..1 and output length three.");
|
|
26
|
+
let l = e(t), u = (t.closed && r === 1 ? 0 : r) * l, d = Math.min(l - 1, Math.floor(u));
|
|
27
|
+
return o.set(c(n(t, d), u - d, i, s(a))[0]), o;
|
|
28
|
+
}
|
|
29
|
+
function u(e) {
|
|
30
|
+
let t = e.slice(), n = /* @__PURE__ */ new Float64Array(12), r = /* @__PURE__ */ new Float64Array(12);
|
|
31
|
+
for (let e = 0; e < 4; e++) {
|
|
32
|
+
n.set(t.subarray(0, 3), e * 3), r.set(t.subarray((3 - e) * 3, (4 - e) * 3), (3 - e) * 3);
|
|
33
|
+
for (let n = 0; n < 3 - e; n++) for (let e = 0; e < 3; e++) t[n * 3 + e] = (t[n * 3 + e] + t[(n + 1) * 3 + e]) / 2;
|
|
34
|
+
}
|
|
35
|
+
return [n, r];
|
|
36
|
+
}
|
|
37
|
+
function d(e, t, n, i) {
|
|
38
|
+
if (!n) return Math.max(...t.map(Math.abs)) * Math.sqrt(3);
|
|
39
|
+
let a = [
|
|
40
|
+
0,
|
|
41
|
+
1,
|
|
42
|
+
2
|
|
43
|
+
].map((t) => r(i, new Float64Array([
|
|
44
|
+
0,
|
|
45
|
+
1,
|
|
46
|
+
2
|
|
47
|
+
].map((n) => 3 * (e[(t + 1) * 3 + n] - e[t * 3 + n]))))), o = [
|
|
48
|
+
0,
|
|
49
|
+
1,
|
|
50
|
+
2
|
|
51
|
+
].map((e) => Math.min(...a.map((t) => t[e]))), s = [
|
|
52
|
+
0,
|
|
53
|
+
1,
|
|
54
|
+
2
|
|
55
|
+
].map((e) => Math.max(...a.map((t) => t[e]))), c = Math.hypot(...o.map((e, t) => e > 0 ? e : s[t] < 0 ? -s[t] : 0)), l = Math.hypot(...o.map((e, t) => Math.max(Math.abs(e), Math.abs(s[t]))));
|
|
56
|
+
if (!c) return Infinity;
|
|
57
|
+
let u = 0;
|
|
58
|
+
for (let e = 0; e < 3; e++) {
|
|
59
|
+
let r = [
|
|
60
|
+
o[e] / c,
|
|
61
|
+
o[e] / l,
|
|
62
|
+
s[e] / c,
|
|
63
|
+
s[e] / l
|
|
64
|
+
], i = Math.max(-1, Math.min(...r)) * n, a = Math.min(1, Math.max(...r)) * n, d = [
|
|
65
|
+
0,
|
|
66
|
+
1,
|
|
67
|
+
2,
|
|
68
|
+
3
|
|
69
|
+
].map((n) => t[n * 3 + e]), f = Math.min(...d) - Math.max(i, a), p = Math.max(...d) - Math.min(i, a);
|
|
70
|
+
u += Math.max(Math.abs(f), Math.abs(p)) ** 2;
|
|
71
|
+
}
|
|
72
|
+
let d = 128 * 2 ** -52 * Math.max(1, Math.abs(n), ...e.map(Math.abs));
|
|
73
|
+
return Math.sqrt(u) + d;
|
|
74
|
+
}
|
|
75
|
+
function f(r, i, o = {}) {
|
|
76
|
+
let l = s(o.normal ?? [
|
|
77
|
+
0,
|
|
78
|
+
0,
|
|
79
|
+
1
|
|
80
|
+
]), f = o.tolerance ?? .001, p = o.maxDepth ?? 20, m = o.maxSegments ?? 16384, h = o.maxWork ?? 1e6;
|
|
81
|
+
if (!Number.isFinite(i) || !Number.isFinite(f) || f <= 0 || !Number.isInteger(p) || p < 0 || p > 30 || !Number.isSafeInteger(m) || m < 1 || m > 333333 || !Number.isSafeInteger(h) || h < 1) throw RangeError("Invalid offset options; pass finite distance, positive tolerance, maxDepth 0..30 and positive bounded work/segment counts.");
|
|
82
|
+
let g = [], _ = [], v = e(r), y = 0, b = 0, x = (e, n) => {
|
|
83
|
+
let r = [{
|
|
84
|
+
p: e,
|
|
85
|
+
r: n.map((t, n) => t - e[n]),
|
|
86
|
+
depth: 0
|
|
87
|
+
}], a = 0;
|
|
88
|
+
for (; r.length;) {
|
|
89
|
+
if (++y > h) throw Object.assign(/* @__PURE__ */ RangeError("Offset verification work limit reached; raise maxWork or choose a larger tolerance."), { code: "limit" });
|
|
90
|
+
let e = r.pop(), n = d(e.p, e.r, i, l);
|
|
91
|
+
if (n <= f) {
|
|
92
|
+
a = Math.max(a, n);
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
let o = c(e.p, .5, i, l)[0], s = t(e.p, .5, 0), p = t(e.r, .5, 0);
|
|
96
|
+
if (Math.hypot(...o.map((e, t) => e - s[t] - p[t])) > f || e.depth >= 20) return Infinity;
|
|
97
|
+
let m = u(e.p), g = u(e.r);
|
|
98
|
+
for (let t = 0; t < 2; t++) r.push({
|
|
99
|
+
p: m[t],
|
|
100
|
+
r: g[t],
|
|
101
|
+
depth: e.depth + 1
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
return a;
|
|
105
|
+
}, S = (e, n, r, a) => {
|
|
106
|
+
let [o, s] = c(e, 0, i, l), [d, h] = c(e, 1, i, l), v = /* @__PURE__ */ new Float64Array(12);
|
|
107
|
+
v.set(o), v.set(d, 9);
|
|
108
|
+
for (let e = 0; e < 3; e++) v[e + 3] = o[e] + s[e] / 3, v[e + 6] = d[e] - h[e] / 3;
|
|
109
|
+
let y = 0;
|
|
110
|
+
for (let n of [
|
|
111
|
+
.125,
|
|
112
|
+
.25,
|
|
113
|
+
.375,
|
|
114
|
+
.5,
|
|
115
|
+
.625,
|
|
116
|
+
.75,
|
|
117
|
+
.875
|
|
118
|
+
]) {
|
|
119
|
+
let r = c(e, n, i, l)[0], a = t(v, n, 0);
|
|
120
|
+
y = Math.max(y, Math.hypot(...r.map((e, t) => e - a[t])));
|
|
121
|
+
}
|
|
122
|
+
let C = y <= f / 2 ? x(e, v) : Infinity;
|
|
123
|
+
if (C <= f) {
|
|
124
|
+
if (g.length >= m) throw Object.assign(/* @__PURE__ */ RangeError("Offset segment limit reached; raise maxSegments or choose a larger tolerance."), { code: "limit" });
|
|
125
|
+
if (g.length) {
|
|
126
|
+
let e = g[g.length - 1].subarray(9, 12);
|
|
127
|
+
if (Math.hypot(...o.map((t, n) => t - e[n])) > 128 * 2 ** -52 * Math.max(1, ...e.map(Math.abs), ...o.map(Math.abs))) {
|
|
128
|
+
if (g.length + 1 >= m) throw Object.assign(/* @__PURE__ */ RangeError("Offset join segment limit reached; raise maxSegments."), { code: "limit" });
|
|
129
|
+
let t = /* @__PURE__ */ new Float64Array(12);
|
|
130
|
+
for (let n = 0; n < 4; n++) for (let r = 0; r < 3; r++) t[n * 3 + r] = e[r] + (o[r] - e[r]) * n / 3;
|
|
131
|
+
g.push(t), _.push(n, n);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
g.push(v), _.push(n, r), b = Math.max(b, C);
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
if (a >= p) throw Object.assign(/* @__PURE__ */ RangeError("Offset fit depth reached; raise maxDepth or choose a larger tolerance."), { code: "limit" });
|
|
138
|
+
let [w, T] = u(e), E = (n + r) / 2;
|
|
139
|
+
S(w, n, E, a + 1), S(T, E, r, a + 1);
|
|
140
|
+
};
|
|
141
|
+
for (let e = 0; e < v; e++) S(n(r, e), e / v, (e + 1) / v, 0);
|
|
142
|
+
let C = [];
|
|
143
|
+
for (let e of g) C.length || C.push(e.slice(0, 3)), C.push(e.slice(3, 6), e.slice(6, 9), e.slice(9, 12));
|
|
144
|
+
if (r.closed) {
|
|
145
|
+
let e = C[0], t = C[C.length - 1];
|
|
146
|
+
if (Math.hypot(...e.map((e, n) => e - t[n])) > 128 * 2 ** -52 * Math.max(1, ...e.map(Math.abs), ...t.map(Math.abs))) {
|
|
147
|
+
if (g.length >= m) throw Object.assign(/* @__PURE__ */ RangeError("Offset closing join limit reached; raise maxSegments."), { code: "limit" });
|
|
148
|
+
for (let n = 1; n <= 3; n++) C.push(t.map((t, r) => t + (e[r] - t) * n / 3));
|
|
149
|
+
g.push(/* @__PURE__ */ new Float64Array(12)), _.push(1, 1);
|
|
150
|
+
}
|
|
151
|
+
C[C.length - 1] = C[0].slice();
|
|
152
|
+
}
|
|
153
|
+
let w = r.closed;
|
|
154
|
+
return {
|
|
155
|
+
spline: new a(C, {
|
|
156
|
+
closed: w,
|
|
157
|
+
divisions: o.divisions ?? Math.min(1e6, Math.max(256, g.length * 8))
|
|
158
|
+
}),
|
|
159
|
+
ranges: Float64Array.from(_),
|
|
160
|
+
maxError: b,
|
|
161
|
+
work: y
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
function p(t) {
|
|
165
|
+
let r = e(t), i = [];
|
|
166
|
+
for (let e = r - 1; e >= 0; e--) {
|
|
167
|
+
let r = n(t, e);
|
|
168
|
+
i.length || i.push(r.slice(9, 12)), i.push(r.slice(6, 9), r.slice(3, 6), r.slice(0, 3));
|
|
169
|
+
}
|
|
170
|
+
return new a(i, {
|
|
171
|
+
closed: t.closed,
|
|
172
|
+
divisions: t.arcLengths.length - 1
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
//#endregion
|
|
176
|
+
export { f as offsetSpline, l as offsetSplineAt, p as reverseSpline };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
//#region src/polynomial.ts
|
|
2
|
+
var e = (e) => e.kind === "bezier" ? (e.points.length / 3 - 1) / 3 : e.points.length / 3 - !e.closed;
|
|
3
|
+
function t(t, n) {
|
|
4
|
+
if (t.kind === "bezier") return t.points.slice(n * 9, n * 9 + 12);
|
|
5
|
+
let r = e(t), i = [
|
|
6
|
+
0,
|
|
7
|
+
1 / 3,
|
|
8
|
+
2 / 3,
|
|
9
|
+
1
|
|
10
|
+
].map((e) => t.at((n + e) / r, /* @__PURE__ */ new Float64Array(3))), a = /* @__PURE__ */ new Float64Array(12);
|
|
11
|
+
for (let e = 0; e < 3; e++) {
|
|
12
|
+
let [t, n, r, o] = i.map((t) => t[e]);
|
|
13
|
+
a[e] = t, a[e + 3] = (-5 * t + 18 * n - 9 * r + 2 * o) / 6, a[e + 6] = (2 * t - 9 * n + 18 * r - 5 * o) / 6, a[e + 9] = o;
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
}
|
|
17
|
+
function n(e, t, n, r = /* @__PURE__ */ new Float64Array(3)) {
|
|
18
|
+
let i = 1 - t;
|
|
19
|
+
for (let a = 0; a < 3; a++) {
|
|
20
|
+
let o = e[a], s = e[a + 3], c = e[a + 6], l = e[a + 9];
|
|
21
|
+
r[a] = n === 0 ? i * i * i * o + 3 * i * i * t * s + 3 * i * t * t * c + t * t * t * l : n === 1 ? 3 * (i * i * (s - o) + 2 * i * t * (c - s) + t * t * (l - c)) : n === 2 ? 6 * (i * (c - 2 * s + o) + t * (l - 2 * c + s)) : 6 * (l - 3 * c + 3 * s - o);
|
|
22
|
+
}
|
|
23
|
+
return r;
|
|
24
|
+
}
|
|
25
|
+
function r(e, t) {
|
|
26
|
+
return new Float64Array([
|
|
27
|
+
e[1] * t[2] - e[2] * t[1],
|
|
28
|
+
e[2] * t[0] - e[0] * t[2],
|
|
29
|
+
e[0] * t[1] - e[1] * t[0]
|
|
30
|
+
]);
|
|
31
|
+
}
|
|
32
|
+
function i(e) {
|
|
33
|
+
if (e.length !== 3 || ![
|
|
34
|
+
e[0],
|
|
35
|
+
e[1],
|
|
36
|
+
e[2]
|
|
37
|
+
].every(Number.isFinite)) throw RangeError("Invalid vector; pass three finite components.");
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
export { e as a, n as i, t as n, r, i as t };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Spline } from './index.js';
|
|
2
|
+
export declare const segmentCount: (spline: Spline) => number;
|
|
3
|
+
export declare function controls(spline: Spline, segment: number): Float64Array;
|
|
4
|
+
export declare function evaluate(p: Float64Array, t: number, order: number, out?: Float64Array<ArrayBuffer>): Float64Array;
|
|
5
|
+
export declare function cross(a: ArrayLike<number>, b: ArrayLike<number>): Float64Array;
|
|
6
|
+
export declare function checkVector(v: ArrayLike<number>): void;
|
package/dist/query.d.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { Spline } from './index.js';
|
|
2
|
+
/** Axis-aligned bounds of the complete curve, including its analytic extrema. */
|
|
3
|
+
export interface SplineBounds {
|
|
4
|
+
min: Float64Array;
|
|
5
|
+
max: Float64Array;
|
|
6
|
+
}
|
|
7
|
+
/** Parameters of stationary coordinates, excluding constant coordinates and endpoints. */
|
|
8
|
+
export interface SplineExtrema {
|
|
9
|
+
x: number[];
|
|
10
|
+
y: number[];
|
|
11
|
+
z: number[];
|
|
12
|
+
values: number[];
|
|
13
|
+
}
|
|
14
|
+
/** Intersection precision and bounded subdivision work. */
|
|
15
|
+
export interface SplineQueryOptions {
|
|
16
|
+
/** Spatial acceptance tolerance in world units. Default 1e-7. */
|
|
17
|
+
tolerance?: number;
|
|
18
|
+
/** Parameter deduplication tolerance. Default 1e-7. */
|
|
19
|
+
parameterTolerance?: number;
|
|
20
|
+
/** Maximum curve-pair subdivision nodes. Default 200000. */
|
|
21
|
+
maxWork?: number;
|
|
22
|
+
}
|
|
23
|
+
/** An isolated curve hit; otherT is the second curve parameter or the ray parameter. */
|
|
24
|
+
export interface SplineIntersection {
|
|
25
|
+
t: number;
|
|
26
|
+
otherT?: number;
|
|
27
|
+
point: Float64Array;
|
|
28
|
+
}
|
|
29
|
+
/** A continuous intersection, represented explicitly rather than as infinitely many point hits. */
|
|
30
|
+
export interface SplineOverlap {
|
|
31
|
+
t0: number;
|
|
32
|
+
t1: number;
|
|
33
|
+
otherT0?: number;
|
|
34
|
+
otherT1?: number;
|
|
35
|
+
}
|
|
36
|
+
/** Ordered isolated points and continuous overlap spans. */
|
|
37
|
+
export interface SplineIntersections {
|
|
38
|
+
points: SplineIntersection[];
|
|
39
|
+
overlaps: SplineOverlap[];
|
|
40
|
+
}
|
|
41
|
+
/** Solve derivative quadratics per piece; includes joins as candidates for extrema of a piecewise curve. */
|
|
42
|
+
export declare function splineExtrema(spline: Spline): SplineExtrema;
|
|
43
|
+
/** Tight analytic bounds; unaffected by the spline's arc-length sampling resolution. */
|
|
44
|
+
export declare function splineBounds(spline: Spline): SplineBounds;
|
|
45
|
+
/** Intersect normal dot point + constant = 0; coplanar pieces become overlaps. Normal need not be unit length. */
|
|
46
|
+
export declare function intersectSplinePlane(spline: Spline, normal: ArrayLike<number>, constant?: number, options?: SplineQueryOptions): SplineIntersections;
|
|
47
|
+
/** Intersect a forward ray origin + direction * otherT, including collinear spans and 3D separation checks. */
|
|
48
|
+
export declare function intersectSplineRay(spline: Spline, origin: ArrayLike<number>, direction: ArrayLike<number>, options?: SplineQueryOptions): SplineIntersections;
|
|
49
|
+
/** 3D curve intersections by convex-hull subdivision and analytic Newton refinement. Identical/reversed pieces report overlap. */
|
|
50
|
+
export declare function intersectSplines(first: Spline, second: Spline, options?: SplineQueryOptions): SplineIntersections;
|