curvy 2.0.0-alpha.10 → 2.0.0-alpha.12
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/dist/characteristic/index.mjs +1 -1
- package/dist/curve/index.mjs +1 -1
- package/dist/interval/index.mjs +2 -2
- package/dist/interval/interval.d.ts +14 -0
- package/dist/path/index.mjs +27 -378
- package/dist/path/index.mjs.map +1 -1
- package/dist/polynomial/cubic.d.ts +10 -0
- package/dist/polynomial/index.mjs +2 -2
- package/dist/polynomial/linear.d.ts +10 -0
- package/dist/polynomial/quadratic.d.ts +10 -0
- package/dist/shared/{characteristic-B0VEB_OA.mjs → characteristic-Hb7F8SBw.mjs} +2 -2
- package/dist/shared/{characteristic-B0VEB_OA.mjs.map → characteristic-Hb7F8SBw.mjs.map} +1 -1
- package/dist/shared/{cubic-NEn7E6V_.mjs → cubic-DHJrzZJN.mjs} +22 -5
- package/dist/shared/cubic-DHJrzZJN.mjs.map +1 -0
- package/dist/shared/{interval-CqC3ZIqj.mjs → interval-Dm35Xhy4.mjs} +19 -2
- package/dist/shared/interval-Dm35Xhy4.mjs.map +1 -0
- package/dist/shared/{interval2d-C0eduE-V.mjs → interval2d-DPmvk_Qe.mjs} +2 -2
- package/dist/shared/{interval2d-C0eduE-V.mjs.map → interval2d-DPmvk_Qe.mjs.map} +1 -1
- package/dist/shared/{quadratic-Dlxqo2V1.mjs → quadratic-BZmfZE71.mjs} +27 -5
- package/dist/shared/quadratic-BZmfZE71.mjs.map +1 -0
- package/dist/shared/{rationalCubic2d-3S5K69Jy.mjs → rationalCubic2d-D5g3_hTV.mjs} +11 -11
- package/dist/shared/rationalCubic2d-D5g3_hTV.mjs.map +1 -0
- package/dist/shared/{rationalCubic2d-CJY-feGw.mjs → rationalCubic2d-MojACId0.mjs} +402 -20
- package/dist/shared/rationalCubic2d-MojACId0.mjs.map +1 -0
- package/dist/shared/{solution-UKGK826h.mjs → solution-B6KY1E7M.mjs} +2 -2
- package/dist/shared/{solution-UKGK826h.mjs.map → solution-B6KY1E7M.mjs.map} +1 -1
- package/dist/solution/index.mjs +1 -1
- package/dist/splines/index.d.ts +3 -0
- package/dist/splines/index.mjs +218 -120
- package/dist/splines/index.mjs.map +1 -1
- package/dist/splines/linear2d.d.ts +102 -0
- package/dist/splines/linear2d.internal.d.ts +2 -0
- package/package.json +1 -1
- package/dist/shared/cubic-NEn7E6V_.mjs.map +0 -1
- package/dist/shared/interval-CqC3ZIqj.mjs.map +0 -1
- package/dist/shared/quadratic-Dlxqo2V1.mjs.map +0 -1
- package/dist/shared/rationalCubic2d-3S5K69Jy.mjs.map +0 -1
- package/dist/shared/rationalCubic2d-CJY-feGw.mjs.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as characteristic_exports } from "../shared/characteristic-
|
|
1
|
+
import { n as characteristic_exports } from "../shared/characteristic-Hb7F8SBw.mjs";
|
|
2
2
|
export { characteristic_exports as Characteristic };
|
package/dist/curve/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { C as linear2d_exports, g as quadratic2d_exports, o as cubic2d_exports, r as rationalCubic2d_exports } from "../shared/rationalCubic2d-D5g3_hTV.mjs";
|
|
2
2
|
export { cubic2d_exports as CubicCurve2d, linear2d_exports as LinearCurve2d, quadratic2d_exports as QuadraticCurve2d, rationalCubic2d_exports as RationalCubicCurve2d };
|
package/dist/interval/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { s as interval_exports } from "../shared/interval-
|
|
2
|
-
import { n as interval2d_exports } from "../shared/interval2d-
|
|
1
|
+
import { s as interval_exports } from "../shared/interval-Dm35Xhy4.mjs";
|
|
2
|
+
import { n as interval2d_exports } from "../shared/interval2d-DPmvk_Qe.mjs";
|
|
3
3
|
export { interval_exports as Interval, interval2d_exports as Interval2d };
|
|
@@ -240,6 +240,20 @@ export declare const contains: {
|
|
|
240
240
|
*/
|
|
241
241
|
(value: number): (interval: Interval) => boolean;
|
|
242
242
|
};
|
|
243
|
+
/**
|
|
244
|
+
* Float-tolerant containment: returns `true` if `value` is in the interval or
|
|
245
|
+
* within `eps` of either boundary. Endpoint inclusivity is ignored — at the
|
|
246
|
+
* `EPSILON` scale the open/closed distinction loses meaning, and the use case
|
|
247
|
+
* is "is this query approximately in this range, accounting for float drift?".
|
|
248
|
+
* Use {@link contains} if you need kind-strict semantics.
|
|
249
|
+
*
|
|
250
|
+
* @param interval - The interval to check against.
|
|
251
|
+
* @param value - The value to check.
|
|
252
|
+
* @param eps - The absolute tolerance. Defaults to {@link EPSILON}.
|
|
253
|
+
* @returns `true` when `interval.start - eps <= value <= interval.end + eps`.
|
|
254
|
+
* @since 2.0.0
|
|
255
|
+
*/
|
|
256
|
+
export declare const containsApprox: (interval: Interval, value: number, eps?: number) => boolean;
|
|
243
257
|
export declare const containsInterval: {
|
|
244
258
|
/**
|
|
245
259
|
* Checks if `inner` is a subset of `outer` — every point of `inner` is also
|
package/dist/path/index.mjs
CHANGED
|
@@ -1,373 +1,12 @@
|
|
|
1
1
|
import { t as __exportAll } from "../shared/chunk-25Hzd3z8.mjs";
|
|
2
2
|
import { Pipeable, dual, invariant } from "../utils.mjs";
|
|
3
3
|
import { epsEquals } from "../number.mjs";
|
|
4
|
-
import { p as unit } from "../shared/interval-
|
|
5
|
-
import { o as none } from "../shared/solution-
|
|
6
|
-
import {
|
|
7
|
-
import { a as union } from "../shared/interval2d-
|
|
8
|
-
import {
|
|
9
|
-
import { n as rationalCubic2d_exports, r as cubic2d_exports } from "../shared/rationalCubic2d-
|
|
10
|
-
//#region src/path/linear2d.internal.ts
|
|
11
|
-
const LinearPath2dTypeId = Symbol("curvy/path/linear2d");
|
|
12
|
-
/** @internal */
|
|
13
|
-
var LinearPath2dImpl = class extends Pipeable {
|
|
14
|
-
[LinearPath2dTypeId] = LinearPath2dTypeId;
|
|
15
|
-
curves;
|
|
16
|
-
constructor(curves) {
|
|
17
|
-
super();
|
|
18
|
-
this.curves = curves;
|
|
19
|
-
}
|
|
20
|
-
[Symbol.iterator]() {
|
|
21
|
-
return this.curves[Symbol.iterator]();
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
/** @internal */
|
|
25
|
-
const isLinearPath2d$1 = (p) => typeof p === "object" && p !== null && LinearPath2dTypeId in p;
|
|
26
|
-
/** @internal */
|
|
27
|
-
const make$3 = (...curves) => new LinearPath2dImpl(curves);
|
|
28
|
-
/** @internal */
|
|
29
|
-
const fromArray$3 = (curves) => new LinearPath2dImpl(curves);
|
|
30
|
-
/** @internal */
|
|
31
|
-
const append$3 = dual(2, (p, c) => fromArray$3([...p, c]));
|
|
32
|
-
/** @internal */
|
|
33
|
-
const length$3 = (p) => {
|
|
34
|
-
let total = 0;
|
|
35
|
-
for (const curve of p) total += length$4(curve, unit);
|
|
36
|
-
return total;
|
|
37
|
-
};
|
|
38
|
-
/** @internal */
|
|
39
|
-
const solve$3 = dual(2, (p, u) => {
|
|
40
|
-
const curves = p instanceof LinearPath2dImpl ? p.curves : [...p];
|
|
41
|
-
if (u === 1) return solve$4(curves.at(-1), 1);
|
|
42
|
-
const t = u * curves.length;
|
|
43
|
-
const i = Math.floor(t);
|
|
44
|
-
const curve = curves[i];
|
|
45
|
-
return solve$4(curve, t - i);
|
|
46
|
-
});
|
|
47
|
-
/** @internal */
|
|
48
|
-
const toPathData$3 = (p) => {
|
|
49
|
-
let result = "";
|
|
50
|
-
let prevEndX = NaN;
|
|
51
|
-
let prevEndY = NaN;
|
|
52
|
-
for (const curve of p) {
|
|
53
|
-
const startX = curve.x.c0;
|
|
54
|
-
const startY = curve.y.c0;
|
|
55
|
-
const endX = curve.x.c0 + curve.x.c1;
|
|
56
|
-
const endY = curve.y.c0 + curve.y.c1;
|
|
57
|
-
if (!epsEquals(startX, prevEndX) || !epsEquals(startY, prevEndY)) result += ` M ${startX},${startY}`;
|
|
58
|
-
result += ` L ${endX},${endY}`;
|
|
59
|
-
prevEndX = endX;
|
|
60
|
-
prevEndY = endY;
|
|
61
|
-
}
|
|
62
|
-
return result.slice(1);
|
|
63
|
-
};
|
|
64
|
-
/** @internal */
|
|
65
|
-
const isContinuous$3 = (p) => {
|
|
66
|
-
let prevEndX = NaN;
|
|
67
|
-
let prevEndY = NaN;
|
|
68
|
-
let first = true;
|
|
69
|
-
for (const curve of p) {
|
|
70
|
-
const startX = curve.x.c0;
|
|
71
|
-
const startY = curve.y.c0;
|
|
72
|
-
if (!first && (!epsEquals(startX, prevEndX) || !epsEquals(startY, prevEndY))) return false;
|
|
73
|
-
prevEndX = curve.x.c0 + curve.x.c1;
|
|
74
|
-
prevEndY = curve.y.c0 + curve.y.c1;
|
|
75
|
-
first = false;
|
|
76
|
-
}
|
|
77
|
-
return true;
|
|
78
|
-
};
|
|
79
|
-
/** @internal */
|
|
80
|
-
const asContinuous$3 = (p) => {
|
|
81
|
-
invariant(isContinuous$3(p), "linear path is not continuous");
|
|
82
|
-
return p;
|
|
83
|
-
};
|
|
84
|
-
/** @internal */
|
|
85
|
-
const isIncreasingX$3 = (p) => {
|
|
86
|
-
let prevEnd = Number.NEGATIVE_INFINITY;
|
|
87
|
-
for (const c of p) {
|
|
88
|
-
if (!isIncreasing(c.x)) return false;
|
|
89
|
-
if (c.x.c0 < prevEnd - 1e-10) return false;
|
|
90
|
-
prevEnd = c.x.c0 + c.x.c1;
|
|
91
|
-
}
|
|
92
|
-
return true;
|
|
93
|
-
};
|
|
94
|
-
/** @internal */
|
|
95
|
-
const isDecreasingX$3 = (p) => {
|
|
96
|
-
let prevEnd = Number.POSITIVE_INFINITY;
|
|
97
|
-
for (const c of p) {
|
|
98
|
-
if (!isDecreasing(c.x)) return false;
|
|
99
|
-
if (c.x.c0 > prevEnd + 1e-10) return false;
|
|
100
|
-
prevEnd = c.x.c0 + c.x.c1;
|
|
101
|
-
}
|
|
102
|
-
return true;
|
|
103
|
-
};
|
|
104
|
-
/** @internal */
|
|
105
|
-
const isMonotonicX$3 = (p) => isIncreasingX$3(p) || isDecreasingX$3(p);
|
|
106
|
-
/** @internal */
|
|
107
|
-
const isIncreasingY$3 = (p) => {
|
|
108
|
-
let prevEnd = Number.NEGATIVE_INFINITY;
|
|
109
|
-
for (const c of p) {
|
|
110
|
-
if (!isIncreasing(c.y)) return false;
|
|
111
|
-
if (c.y.c0 < prevEnd - 1e-10) return false;
|
|
112
|
-
prevEnd = c.y.c0 + c.y.c1;
|
|
113
|
-
}
|
|
114
|
-
return true;
|
|
115
|
-
};
|
|
116
|
-
/** @internal */
|
|
117
|
-
const isDecreasingY$3 = (p) => {
|
|
118
|
-
let prevEnd = Number.POSITIVE_INFINITY;
|
|
119
|
-
for (const c of p) {
|
|
120
|
-
if (!isDecreasing(c.y)) return false;
|
|
121
|
-
if (c.y.c0 > prevEnd + 1e-10) return false;
|
|
122
|
-
prevEnd = c.y.c0 + c.y.c1;
|
|
123
|
-
}
|
|
124
|
-
return true;
|
|
125
|
-
};
|
|
126
|
-
/** @internal */
|
|
127
|
-
const isMonotonicY$3 = (p) => isIncreasingY$3(p) || isDecreasingY$3(p);
|
|
128
|
-
/** @internal */
|
|
129
|
-
const asIncreasingX$3 = (p) => {
|
|
130
|
-
invariant(isIncreasingX$3(p), "linear path is not increasing in x");
|
|
131
|
-
return p;
|
|
132
|
-
};
|
|
133
|
-
/** @internal */
|
|
134
|
-
const asDecreasingX$3 = (p) => {
|
|
135
|
-
invariant(isDecreasingX$3(p), "linear path is not decreasing in x");
|
|
136
|
-
return p;
|
|
137
|
-
};
|
|
138
|
-
/** @internal */
|
|
139
|
-
const asMonotonicX$3 = (p) => {
|
|
140
|
-
invariant(isMonotonicX$3(p), "linear path is not monotonic in x");
|
|
141
|
-
return p;
|
|
142
|
-
};
|
|
143
|
-
/** @internal */
|
|
144
|
-
const asIncreasingY$3 = (p) => {
|
|
145
|
-
invariant(isIncreasingY$3(p), "linear path is not increasing in y");
|
|
146
|
-
return p;
|
|
147
|
-
};
|
|
148
|
-
/** @internal */
|
|
149
|
-
const asDecreasingY$3 = (p) => {
|
|
150
|
-
invariant(isDecreasingY$3(p), "linear path is not decreasing in y");
|
|
151
|
-
return p;
|
|
152
|
-
};
|
|
153
|
-
/** @internal */
|
|
154
|
-
const asMonotonicY$3 = (p) => {
|
|
155
|
-
invariant(isMonotonicY$3(p), "linear path is not monotonic in y");
|
|
156
|
-
return p;
|
|
157
|
-
};
|
|
158
|
-
/** @internal */
|
|
159
|
-
const solveAtX$3 = dual(2, (p, x) => {
|
|
160
|
-
for (const c of p) {
|
|
161
|
-
const sx = c.x.c0;
|
|
162
|
-
const ex = c.x.c0 + c.x.c1;
|
|
163
|
-
const lo = Math.min(sx, ex);
|
|
164
|
-
const hi = Math.max(sx, ex);
|
|
165
|
-
if (x >= lo - 1e-10 && x <= hi + 1e-10) return solveAtX$4(c, x);
|
|
166
|
-
}
|
|
167
|
-
return none;
|
|
168
|
-
});
|
|
169
|
-
/** @internal */
|
|
170
|
-
const solveAtY$3 = dual(2, (p, y) => {
|
|
171
|
-
for (const c of p) {
|
|
172
|
-
const sy = c.y.c0;
|
|
173
|
-
const ey = c.y.c0 + c.y.c1;
|
|
174
|
-
const lo = Math.min(sy, ey);
|
|
175
|
-
const hi = Math.max(sy, ey);
|
|
176
|
-
if (y >= lo - 1e-10 && y <= hi + 1e-10) return solveAtY$4(c, y);
|
|
177
|
-
}
|
|
178
|
-
return none;
|
|
179
|
-
});
|
|
180
|
-
/** @internal */
|
|
181
|
-
const boundingBox$3 = (p) => {
|
|
182
|
-
const iter = p[Symbol.iterator]();
|
|
183
|
-
let acc = boundingBox$4(iter.next().value);
|
|
184
|
-
for (let next = iter.next(); !next.done; next = iter.next()) acc = union(acc, boundingBox$4(next.value));
|
|
185
|
-
return acc;
|
|
186
|
-
};
|
|
187
|
-
//#endregion
|
|
188
|
-
//#region src/path/linear2d.ts
|
|
189
|
-
var linear2d_exports = /* @__PURE__ */ __exportAll({
|
|
190
|
-
append: () => append$2,
|
|
191
|
-
asContinuous: () => asContinuous$2,
|
|
192
|
-
asDecreasingX: () => asDecreasingX$2,
|
|
193
|
-
asDecreasingY: () => asDecreasingY$2,
|
|
194
|
-
asIncreasingX: () => asIncreasingX$2,
|
|
195
|
-
asIncreasingY: () => asIncreasingY$2,
|
|
196
|
-
asMonotonicX: () => asMonotonicX$2,
|
|
197
|
-
asMonotonicY: () => asMonotonicY$2,
|
|
198
|
-
boundingBox: () => boundingBox$2,
|
|
199
|
-
fromArray: () => fromArray$2,
|
|
200
|
-
isContinuous: () => isContinuous$2,
|
|
201
|
-
isDecreasingX: () => isDecreasingX$2,
|
|
202
|
-
isDecreasingY: () => isDecreasingY$2,
|
|
203
|
-
isIncreasingX: () => isIncreasingX$2,
|
|
204
|
-
isIncreasingY: () => isIncreasingY$2,
|
|
205
|
-
isLinearPath2d: () => isLinearPath2d,
|
|
206
|
-
isMonotonicX: () => isMonotonicX$2,
|
|
207
|
-
isMonotonicY: () => isMonotonicY$2,
|
|
208
|
-
length: () => length$2,
|
|
209
|
-
make: () => make$2,
|
|
210
|
-
solve: () => solve$2,
|
|
211
|
-
solveAtX: () => solveAtX$2,
|
|
212
|
-
solveAtY: () => solveAtY$2,
|
|
213
|
-
toPathData: () => toPathData$2
|
|
214
|
-
});
|
|
215
|
-
/**
|
|
216
|
-
* Creates a new `LinearPath2d` instance from a sequence of curves.
|
|
217
|
-
*
|
|
218
|
-
* @param curves - The curves to create the path from.
|
|
219
|
-
* @returns A new `LinearPath2d` instance.
|
|
220
|
-
* @since 2.0.0
|
|
221
|
-
*/
|
|
222
|
-
const make$2 = make$3;
|
|
223
|
-
/**
|
|
224
|
-
* Creates a new `LinearPath2d` instance from an array of curves.
|
|
225
|
-
*
|
|
226
|
-
* @param curves - The curves to create the path from.
|
|
227
|
-
* @returns A new `LinearPath2d` instance.
|
|
228
|
-
* @since 2.0.0
|
|
229
|
-
*/
|
|
230
|
-
const fromArray$2 = fromArray$3;
|
|
231
|
-
/**
|
|
232
|
-
* Checks if a value is a `LinearPath2d`.
|
|
233
|
-
*
|
|
234
|
-
* @param p - The value to check.
|
|
235
|
-
* @returns `true` if the value is a `LinearPath2d`, `false` otherwise.
|
|
236
|
-
* @since 1.0.0
|
|
237
|
-
*/
|
|
238
|
-
const isLinearPath2d = isLinearPath2d$1;
|
|
239
|
-
const append$2 = append$3;
|
|
240
|
-
/**
|
|
241
|
-
* Calculates the length of a linear path.
|
|
242
|
-
*
|
|
243
|
-
* @param p - The linear path to calculate the length of.
|
|
244
|
-
* @returns The length of the linear path.
|
|
245
|
-
* @since 1.0.0
|
|
246
|
-
*/
|
|
247
|
-
const length$2 = length$3;
|
|
248
|
-
const solve$2 = solve$3;
|
|
249
|
-
/**
|
|
250
|
-
* Serializes a linear path as an SVG path data string (the value of a `<path>`
|
|
251
|
-
* element's `d` attribute), using `M` and `L` commands. Discontinuities between
|
|
252
|
-
* curves emit a fresh `M` command.
|
|
253
|
-
*
|
|
254
|
-
* @param p - The linear path to serialize.
|
|
255
|
-
* @returns The SVG path data string.
|
|
256
|
-
* @since 2.0.0
|
|
257
|
-
*/
|
|
258
|
-
const toPathData$2 = toPathData$3;
|
|
259
|
-
/**
|
|
260
|
-
* Type-narrowing predicate: refines `LinearPath2d<T>` to
|
|
261
|
-
* `LinearPath2d<T & Continuous>` when adjacent curves connect at their join
|
|
262
|
-
* points.
|
|
263
|
-
*
|
|
264
|
-
* @param p - The linear path to check.
|
|
265
|
-
* @returns `true` when the path is continuous (G⁰).
|
|
266
|
-
* @since 2.0.0
|
|
267
|
-
*/
|
|
268
|
-
const isContinuous$2 = isContinuous$3;
|
|
269
|
-
/**
|
|
270
|
-
* Asserts that the linear path is continuous, throwing on failure.
|
|
271
|
-
*
|
|
272
|
-
* @param p - The linear path to assert against.
|
|
273
|
-
* @returns The same path, typed with the `Continuous` brand.
|
|
274
|
-
* @throws When the path has a discontinuity between adjacent curves.
|
|
275
|
-
* @since 2.0.0
|
|
276
|
-
*/
|
|
277
|
-
const asContinuous$2 = asContinuous$3;
|
|
278
|
-
/**
|
|
279
|
-
* Type-narrowing predicate: refines `LinearPath2d<T>` to
|
|
280
|
-
* `LinearPath2d<T & IncreasingX>` when every segment's x-polynomial is
|
|
281
|
-
* strictly increasing and adjacent segments' x-ranges don't overlap.
|
|
282
|
-
*
|
|
283
|
-
* @since 2.0.0
|
|
284
|
-
*/
|
|
285
|
-
const isIncreasingX$2 = isIncreasingX$3;
|
|
286
|
-
/**
|
|
287
|
-
* Type-narrowing predicate: refines `LinearPath2d<T>` to
|
|
288
|
-
* `LinearPath2d<T & DecreasingX>` when every segment's x-polynomial is
|
|
289
|
-
* strictly decreasing and adjacent segments' x-ranges don't overlap.
|
|
290
|
-
*
|
|
291
|
-
* @since 2.0.0
|
|
292
|
-
*/
|
|
293
|
-
const isDecreasingX$2 = isDecreasingX$3;
|
|
294
|
-
/**
|
|
295
|
-
* Type-narrowing predicate: refines `LinearPath2d<T>` to
|
|
296
|
-
* `LinearPath2d<T & MonotonicX>` when the path is either increasing or
|
|
297
|
-
* decreasing in x along its full parameter domain.
|
|
298
|
-
*
|
|
299
|
-
* @since 2.0.0
|
|
300
|
-
*/
|
|
301
|
-
const isMonotonicX$2 = isMonotonicX$3;
|
|
302
|
-
/**
|
|
303
|
-
* Type-narrowing predicate: refines `LinearPath2d<T>` to
|
|
304
|
-
* `LinearPath2d<T & IncreasingY>`. The y-axis analog of {@link isIncreasingX}.
|
|
305
|
-
*
|
|
306
|
-
* @since 2.0.0
|
|
307
|
-
*/
|
|
308
|
-
const isIncreasingY$2 = isIncreasingY$3;
|
|
309
|
-
/**
|
|
310
|
-
* Type-narrowing predicate: refines `LinearPath2d<T>` to
|
|
311
|
-
* `LinearPath2d<T & DecreasingY>`. The y-axis analog of {@link isDecreasingX}.
|
|
312
|
-
*
|
|
313
|
-
* @since 2.0.0
|
|
314
|
-
*/
|
|
315
|
-
const isDecreasingY$2 = isDecreasingY$3;
|
|
316
|
-
/**
|
|
317
|
-
* Type-narrowing predicate: refines `LinearPath2d<T>` to
|
|
318
|
-
* `LinearPath2d<T & MonotonicY>`. The y-axis analog of {@link isMonotonicX}.
|
|
319
|
-
*
|
|
320
|
-
* @since 2.0.0
|
|
321
|
-
*/
|
|
322
|
-
const isMonotonicY$2 = isMonotonicY$3;
|
|
323
|
-
/**
|
|
324
|
-
* Asserts that the path is strictly increasing in x, throwing on failure.
|
|
325
|
-
*
|
|
326
|
-
* @since 2.0.0
|
|
327
|
-
*/
|
|
328
|
-
const asIncreasingX$2 = asIncreasingX$3;
|
|
329
|
-
/**
|
|
330
|
-
* Asserts that the path is strictly decreasing in x, throwing on failure.
|
|
331
|
-
*
|
|
332
|
-
* @since 2.0.0
|
|
333
|
-
*/
|
|
334
|
-
const asDecreasingX$2 = asDecreasingX$3;
|
|
335
|
-
/**
|
|
336
|
-
* Asserts that the path is monotonic in x, throwing on failure.
|
|
337
|
-
*
|
|
338
|
-
* @since 2.0.0
|
|
339
|
-
*/
|
|
340
|
-
const asMonotonicX$2 = asMonotonicX$3;
|
|
341
|
-
/**
|
|
342
|
-
* Asserts that the path is strictly increasing in y, throwing on failure.
|
|
343
|
-
*
|
|
344
|
-
* @since 2.0.0
|
|
345
|
-
*/
|
|
346
|
-
const asIncreasingY$2 = asIncreasingY$3;
|
|
347
|
-
/**
|
|
348
|
-
* Asserts that the path is strictly decreasing in y, throwing on failure.
|
|
349
|
-
*
|
|
350
|
-
* @since 2.0.0
|
|
351
|
-
*/
|
|
352
|
-
const asDecreasingY$2 = asDecreasingY$3;
|
|
353
|
-
/**
|
|
354
|
-
* Asserts that the path is monotonic in y, throwing on failure.
|
|
355
|
-
*
|
|
356
|
-
* @since 2.0.0
|
|
357
|
-
*/
|
|
358
|
-
const asMonotonicY$2 = asMonotonicY$3;
|
|
359
|
-
const solveAtX$2 = solveAtX$3;
|
|
360
|
-
const solveAtY$2 = solveAtY$3;
|
|
361
|
-
/**
|
|
362
|
-
* Computes the axis-aligned bounding box of the path — the smallest closed
|
|
363
|
-
* `Box2d` enclosing every segment.
|
|
364
|
-
*
|
|
365
|
-
* @param p - The linear path.
|
|
366
|
-
* @returns A closed `Box2d` enclosing the path.
|
|
367
|
-
* @since 2.0.0
|
|
368
|
-
*/
|
|
369
|
-
const boundingBox$2 = boundingBox$3;
|
|
370
|
-
//#endregion
|
|
4
|
+
import { p as unit } from "../shared/interval-Dm35Xhy4.mjs";
|
|
5
|
+
import { o as none, r as isNone, s as one } from "../shared/solution-B6KY1E7M.mjs";
|
|
6
|
+
import { n as isDecreasing, r as isIncreasing } from "../shared/quadratic-BZmfZE71.mjs";
|
|
7
|
+
import { a as union } from "../shared/interval2d-DPmvk_Qe.mjs";
|
|
8
|
+
import { _ as solve$2, h as length$2, m as boundingBox$2, v as solveAtX$2, y as solveAtY$2 } from "../shared/rationalCubic2d-D5g3_hTV.mjs";
|
|
9
|
+
import { n as rationalCubic2d_exports, o as linear2d_exports, r as cubic2d_exports } from "../shared/rationalCubic2d-MojACId0.mjs";
|
|
371
10
|
//#region src/path/quadratic2d.internal.ts
|
|
372
11
|
const QuadraticPath2dTypeId = Symbol("curvy/path/quadratic2d");
|
|
373
12
|
/** @internal */
|
|
@@ -393,17 +32,17 @@ const append$1 = dual(2, (p, c) => fromArray$1([...p, c]));
|
|
|
393
32
|
/** @internal */
|
|
394
33
|
const length$1 = (p) => {
|
|
395
34
|
let total = 0;
|
|
396
|
-
for (const curve of p) total += length$
|
|
35
|
+
for (const curve of p) total += length$2(curve, unit);
|
|
397
36
|
return total;
|
|
398
37
|
};
|
|
399
38
|
/** @internal */
|
|
400
39
|
const solve$1 = dual(2, (p, u) => {
|
|
401
40
|
const curves = p instanceof QuadraticPath2dImpl ? p.curves : [...p];
|
|
402
|
-
if (u === 1) return solve$
|
|
41
|
+
if (u === 1) return solve$2(curves.at(-1), 1);
|
|
403
42
|
const t = u * curves.length;
|
|
404
43
|
const i = Math.floor(t);
|
|
405
44
|
const curve = curves[i];
|
|
406
|
-
return solve$
|
|
45
|
+
return solve$2(curve, t - i);
|
|
407
46
|
});
|
|
408
47
|
/** @internal */
|
|
409
48
|
const toPathData$1 = (p) => {
|
|
@@ -454,7 +93,7 @@ const asContinuous$1 = (p) => {
|
|
|
454
93
|
const isIncreasingX$1 = (p) => {
|
|
455
94
|
let prevEnd = Number.NEGATIVE_INFINITY;
|
|
456
95
|
for (const c of p) {
|
|
457
|
-
if (!isIncreasing
|
|
96
|
+
if (!isIncreasing(c.x, unit)) return false;
|
|
458
97
|
if (c.x.c0 < prevEnd - 1e-10) return false;
|
|
459
98
|
prevEnd = c.x.c0 + c.x.c1 + c.x.c2;
|
|
460
99
|
}
|
|
@@ -464,7 +103,7 @@ const isIncreasingX$1 = (p) => {
|
|
|
464
103
|
const isDecreasingX$1 = (p) => {
|
|
465
104
|
let prevEnd = Number.POSITIVE_INFINITY;
|
|
466
105
|
for (const c of p) {
|
|
467
|
-
if (!isDecreasing
|
|
106
|
+
if (!isDecreasing(c.x, unit)) return false;
|
|
468
107
|
if (c.x.c0 > prevEnd + 1e-10) return false;
|
|
469
108
|
prevEnd = c.x.c0 + c.x.c1 + c.x.c2;
|
|
470
109
|
}
|
|
@@ -476,7 +115,7 @@ const isMonotonicX$1 = (p) => isIncreasingX$1(p) || isDecreasingX$1(p);
|
|
|
476
115
|
const isIncreasingY$1 = (p) => {
|
|
477
116
|
let prevEnd = Number.NEGATIVE_INFINITY;
|
|
478
117
|
for (const c of p) {
|
|
479
|
-
if (!isIncreasing
|
|
118
|
+
if (!isIncreasing(c.y, unit)) return false;
|
|
480
119
|
if (c.y.c0 < prevEnd - 1e-10) return false;
|
|
481
120
|
prevEnd = c.y.c0 + c.y.c1 + c.y.c2;
|
|
482
121
|
}
|
|
@@ -486,7 +125,7 @@ const isIncreasingY$1 = (p) => {
|
|
|
486
125
|
const isDecreasingY$1 = (p) => {
|
|
487
126
|
let prevEnd = Number.POSITIVE_INFINITY;
|
|
488
127
|
for (const c of p) {
|
|
489
|
-
if (!isDecreasing
|
|
128
|
+
if (!isDecreasing(c.y, unit)) return false;
|
|
490
129
|
if (c.y.c0 > prevEnd + 1e-10) return false;
|
|
491
130
|
prevEnd = c.y.c0 + c.y.c1 + c.y.c2;
|
|
492
131
|
}
|
|
@@ -531,7 +170,12 @@ const solveAtX$1 = dual(2, (p, x) => {
|
|
|
531
170
|
const ex = c.x.c0 + c.x.c1 + c.x.c2;
|
|
532
171
|
const lo = Math.min(sx, ex);
|
|
533
172
|
const hi = Math.max(sx, ex);
|
|
534
|
-
if (x >= lo - 1e-10 && x <= hi + 1e-10)
|
|
173
|
+
if (x >= lo - 1e-10 && x <= hi + 1e-10) {
|
|
174
|
+
if (epsEquals(x, sx)) return one(c.y.c0);
|
|
175
|
+
if (epsEquals(x, ex)) return one(c.y.c0 + c.y.c1 + c.y.c2);
|
|
176
|
+
const sol = solveAtX$2(c, x);
|
|
177
|
+
if (!isNone(sol)) return sol;
|
|
178
|
+
}
|
|
535
179
|
}
|
|
536
180
|
return none;
|
|
537
181
|
});
|
|
@@ -542,15 +186,20 @@ const solveAtY$1 = dual(2, (p, y) => {
|
|
|
542
186
|
const ey = c.y.c0 + c.y.c1 + c.y.c2;
|
|
543
187
|
const lo = Math.min(sy, ey);
|
|
544
188
|
const hi = Math.max(sy, ey);
|
|
545
|
-
if (y >= lo - 1e-10 && y <= hi + 1e-10)
|
|
189
|
+
if (y >= lo - 1e-10 && y <= hi + 1e-10) {
|
|
190
|
+
if (epsEquals(y, sy)) return one(c.x.c0);
|
|
191
|
+
if (epsEquals(y, ey)) return one(c.x.c0 + c.x.c1 + c.x.c2);
|
|
192
|
+
const sol = solveAtY$2(c, y);
|
|
193
|
+
if (!isNone(sol)) return sol;
|
|
194
|
+
}
|
|
546
195
|
}
|
|
547
196
|
return none;
|
|
548
197
|
});
|
|
549
198
|
/** @internal */
|
|
550
199
|
const boundingBox$1 = (p) => {
|
|
551
200
|
const iter = p[Symbol.iterator]();
|
|
552
|
-
let acc = boundingBox$
|
|
553
|
-
for (let next = iter.next(); !next.done; next = iter.next()) acc = union(acc, boundingBox$
|
|
201
|
+
let acc = boundingBox$2(iter.next().value);
|
|
202
|
+
for (let next = iter.next(); !next.done; next = iter.next()) acc = union(acc, boundingBox$2(next.value));
|
|
554
203
|
return acc;
|
|
555
204
|
};
|
|
556
205
|
//#endregion
|