curvy 0.3.3 → 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.
Files changed (95) hide show
  1. package/LICENSE.md +21 -0
  2. package/dist/curve/cubic2d.d.mts +27 -0
  3. package/dist/curve/cubic2d.d.ts +27 -0
  4. package/dist/curve/cubic2d.mjs +85 -0
  5. package/dist/curve/linear2d.d.mts +27 -0
  6. package/dist/curve/linear2d.d.ts +27 -0
  7. package/dist/curve/linear2d.mjs +46 -0
  8. package/dist/curve/quadratic2d.d.mts +27 -0
  9. package/dist/curve/quadratic2d.d.ts +27 -0
  10. package/dist/curve/quadratic2d.mjs +74 -0
  11. package/dist/interval.d.mts +58 -0
  12. package/dist/interval.d.ts +58 -0
  13. package/dist/interval.mjs +88 -0
  14. package/dist/matrix/matrix2x2.d.mts +49 -0
  15. package/dist/matrix/matrix2x2.d.ts +49 -0
  16. package/dist/matrix/matrix2x2.mjs +23 -0
  17. package/dist/matrix/matrix3x3.d.mts +63 -0
  18. package/dist/matrix/matrix3x3.d.ts +63 -0
  19. package/dist/matrix/matrix3x3.mjs +26 -0
  20. package/dist/matrix/matrix4x4.d.mts +72 -0
  21. package/dist/matrix/matrix4x4.d.ts +72 -0
  22. package/dist/matrix/matrix4x4.mjs +214 -0
  23. package/dist/path/cubic2d.d.mts +29 -0
  24. package/dist/path/cubic2d.d.ts +29 -0
  25. package/dist/path/cubic2d.mjs +60 -0
  26. package/dist/path/linear2d.d.mts +29 -0
  27. package/dist/path/linear2d.d.ts +29 -0
  28. package/dist/path/linear2d.mjs +54 -0
  29. package/dist/path/quadratic2d.d.mts +29 -0
  30. package/dist/path/quadratic2d.d.ts +29 -0
  31. package/dist/path/quadratic2d.mjs +60 -0
  32. package/dist/polynomial/cubic.d.mts +7 -0
  33. package/dist/polynomial/cubic.d.ts +7 -0
  34. package/dist/polynomial/cubic.mjs +139 -0
  35. package/dist/polynomial/linear.d.mts +7 -0
  36. package/dist/polynomial/linear.d.ts +7 -0
  37. package/dist/polynomial/linear.mjs +19 -0
  38. package/dist/polynomial/quadratic.d.mts +7 -0
  39. package/dist/polynomial/quadratic.d.ts +7 -0
  40. package/dist/polynomial/quadratic.mjs +22 -0
  41. package/dist/shared/curvy.BAW_cKLu.mjs +123 -0
  42. package/dist/shared/curvy.BN-oFBsc.d.mts +26 -0
  43. package/dist/shared/curvy.BN-oFBsc.d.ts +26 -0
  44. package/dist/shared/curvy.Bxxwly94.d.mts +144 -0
  45. package/dist/shared/curvy.C-sUk7ux.mjs +119 -0
  46. package/dist/shared/curvy.CLzGuqek.mjs +124 -0
  47. package/dist/shared/curvy.CO0Wclt0.d.ts +144 -0
  48. package/dist/shared/curvy.CT38g_II.d.mts +22 -0
  49. package/dist/shared/curvy.CT38g_II.d.ts +22 -0
  50. package/dist/shared/curvy.ChkqgKuv.mjs +119 -0
  51. package/dist/shared/curvy.Cty3LrOR.mjs +70 -0
  52. package/dist/shared/curvy.D7bhnwZy.mjs +52 -0
  53. package/dist/shared/curvy.DOLqYbKE.mjs +48 -0
  54. package/dist/shared/curvy.DgRsieUW.mjs +76 -0
  55. package/dist/shared/curvy.DmVFTi0N.mjs +34 -0
  56. package/dist/splines/bezier2d.d.mts +35 -0
  57. package/dist/splines/bezier2d.d.ts +35 -0
  58. package/dist/splines/bezier2d.mjs +122 -0
  59. package/dist/vector/vector2.d.mts +37 -0
  60. package/dist/vector/vector2.d.ts +37 -0
  61. package/dist/vector/vector2.mjs +16 -0
  62. package/dist/vector/vector3.d.mts +38 -0
  63. package/dist/vector/vector3.d.ts +38 -0
  64. package/dist/vector/vector3.mjs +16 -0
  65. package/dist/vector/vector4.d.mts +39 -0
  66. package/dist/vector/vector4.d.ts +39 -0
  67. package/dist/vector/vector4.mjs +16 -0
  68. package/package.json +78 -37
  69. package/dist/axis.cjs +0 -14
  70. package/dist/axis.d.cts +0 -20
  71. package/dist/axis.d.mts +0 -20
  72. package/dist/axis.d.ts +0 -20
  73. package/dist/axis.mjs +0 -3
  74. package/dist/convert.cjs +0 -74
  75. package/dist/convert.d.cts +0 -6
  76. package/dist/convert.d.mts +0 -6
  77. package/dist/convert.d.ts +0 -6
  78. package/dist/convert.mjs +0 -68
  79. package/dist/curve.cjs +0 -365
  80. package/dist/curve.d.cts +0 -20
  81. package/dist/curve.d.mts +0 -20
  82. package/dist/curve.d.ts +0 -20
  83. package/dist/curve.mjs +0 -354
  84. package/dist/shared/curvy.262f6070.cjs +0 -16
  85. package/dist/shared/curvy.7876e09e.mjs +0 -323
  86. package/dist/shared/curvy.9cd8b44c.mjs +0 -13
  87. package/dist/shared/curvy.db103082.cjs +0 -335
  88. package/dist/shared/curvy.df73166c.d.cts +0 -38
  89. package/dist/shared/curvy.df73166c.d.mts +0 -38
  90. package/dist/shared/curvy.df73166c.d.ts +0 -38
  91. package/dist/splines.cjs +0 -150
  92. package/dist/splines.d.cts +0 -27
  93. package/dist/splines.d.mts +0 -27
  94. package/dist/splines.d.ts +0 -27
  95. package/dist/splines.mjs +0 -138
package/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Tim Morris
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,27 @@
1
+ import { e as TwoDimensional } from '../shared/curvy.CT38g_II.mjs';
2
+ import { P as Pipeable } from '../shared/curvy.BN-oFBsc.mjs';
3
+ import { Interval } from '../interval.mjs';
4
+ import { C as CubicPolynomial } from '../shared/curvy.Bxxwly94.mjs';
5
+ import { Vector2 } from '../vector/vector2.mjs';
6
+ import '../vector/vector3.mjs';
7
+ import '../vector/vector4.mjs';
8
+
9
+ declare const CubicCurve2dTypeId: unique symbol;
10
+ type CubicCurve2dTypeId = typeof CubicCurve2dTypeId;
11
+
12
+ interface CubicCurve2d extends Pipeable, TwoDimensional<CubicPolynomial> {
13
+ readonly [CubicCurve2dTypeId]: CubicCurve2dTypeId;
14
+ }
15
+ declare const fromPolynomials: (x: CubicPolynomial, y: CubicPolynomial) => CubicCurve2d;
16
+ declare const fromPoints: (p0: Vector2, p1: Vector2, p2: Vector2, p3: Vector2) => CubicCurve2d;
17
+ declare const isCubicCurve2d: (c: unknown) => c is CubicCurve2d;
18
+ declare const solve: {
19
+ (t: number): (c: CubicCurve2d) => Vector2;
20
+ (c: CubicCurve2d, t: number): Vector2;
21
+ };
22
+ declare const length: {
23
+ (c: CubicCurve2d, i: Interval): number;
24
+ (i: Interval): (c: CubicCurve2d) => number;
25
+ };
26
+
27
+ export { type CubicCurve2d, fromPoints, fromPolynomials, isCubicCurve2d, length, solve };
@@ -0,0 +1,27 @@
1
+ import { e as TwoDimensional } from '../shared/curvy.CT38g_II.js';
2
+ import { P as Pipeable } from '../shared/curvy.BN-oFBsc.js';
3
+ import { Interval } from '../interval.js';
4
+ import { C as CubicPolynomial } from '../shared/curvy.CO0Wclt0.js';
5
+ import { Vector2 } from '../vector/vector2.js';
6
+ import '../vector/vector3.js';
7
+ import '../vector/vector4.js';
8
+
9
+ declare const CubicCurve2dTypeId: unique symbol;
10
+ type CubicCurve2dTypeId = typeof CubicCurve2dTypeId;
11
+
12
+ interface CubicCurve2d extends Pipeable, TwoDimensional<CubicPolynomial> {
13
+ readonly [CubicCurve2dTypeId]: CubicCurve2dTypeId;
14
+ }
15
+ declare const fromPolynomials: (x: CubicPolynomial, y: CubicPolynomial) => CubicCurve2d;
16
+ declare const fromPoints: (p0: Vector2, p1: Vector2, p2: Vector2, p3: Vector2) => CubicCurve2d;
17
+ declare const isCubicCurve2d: (c: unknown) => c is CubicCurve2d;
18
+ declare const solve: {
19
+ (t: number): (c: CubicCurve2d) => Vector2;
20
+ (c: CubicCurve2d, t: number): Vector2;
21
+ };
22
+ declare const length: {
23
+ (c: CubicCurve2d, i: Interval): number;
24
+ (i: Interval): (c: CubicCurve2d) => number;
25
+ };
26
+
27
+ export { type CubicCurve2d, fromPoints, fromPolynomials, isCubicCurve2d, length, solve };
@@ -0,0 +1,85 @@
1
+ import { d as dual, r as round, P as Pipeable } from '../shared/curvy.ChkqgKuv.mjs';
2
+ import { size, scaleShift, biunit } from '../interval.mjs';
3
+ import { G as GL32_W0, a as GL32_X0, b as GL32_W1, c as GL32_X1, d as GL32_W2, e as GL32_X2, f as GL32_W3, g as GL32_X3, h as GL32_W4, i as GL32_X4, j as GL32_W5, k as GL32_X5, l as GL32_W6, m as GL32_X6, n as GL32_W7, o as GL32_X7, p as GL32_W8, q as GL32_X8, r as GL32_W9, s as GL32_X9, t as GL32_W10, u as GL32_X10, v as GL32_W11, w as GL32_X11, x as GL32_W12, y as GL32_X12, z as GL32_W13, A as GL32_X13, B as GL32_W14, C as GL32_X14, D as GL32_W15, E as GL32_X15 } from '../shared/curvy.DmVFTi0N.mjs';
4
+ import { make, solve as solve$2, derivative as derivative$1 } from '../polynomial/cubic.mjs';
5
+ import { make as make$2 } from '../polynomial/quadratic.mjs';
6
+ import { make as make$1, magnitude } from '../vector/vector2.mjs';
7
+ import { length as length$2, fromPolynomials as fromPolynomials$2, solve as solve$3 } from './quadratic2d.mjs';
8
+ import '../shared/curvy.CLzGuqek.mjs';
9
+ import '../shared/curvy.DgRsieUW.mjs';
10
+ import '../shared/curvy.DOLqYbKE.mjs';
11
+ import '../polynomial/linear.mjs';
12
+ import './linear2d.mjs';
13
+
14
+ const CubicCurve2dTypeId = Symbol("curvy/curve/cubic2d");
15
+ class CubicCurve2dImpl extends Pipeable {
16
+ [CubicCurve2dTypeId] = CubicCurve2dTypeId;
17
+ x;
18
+ y;
19
+ constructor(c0, c1) {
20
+ super();
21
+ this.x = c0;
22
+ this.y = c1;
23
+ }
24
+ get [0]() {
25
+ return this.x;
26
+ }
27
+ get [1]() {
28
+ return this.y;
29
+ }
30
+ }
31
+ const fromPolynomials$1 = (c0, c1) => new CubicCurve2dImpl(c0, c1);
32
+ const fromPoints$1 = (p0, p1, p2, p3) => new CubicCurve2dImpl(
33
+ make(p0.x, p1.x, p2.x, p3.x),
34
+ make(p0.y, p1.y, p2.y, p3.y)
35
+ );
36
+ const isCubicCurve2d$1 = (c) => typeof c === "object" && c !== null && CubicCurve2dTypeId in c;
37
+ const solve$1 = dual(
38
+ 2,
39
+ (c, t) => make$1(solve$2(c.x, t), solve$2(c.y, t))
40
+ );
41
+ const derivative = (c) => fromPolynomials$2(
42
+ derivative$1(c.x),
43
+ derivative$1(c.y)
44
+ );
45
+ const length$1 = dual(2, (c, i) => {
46
+ if (size(i) === 0) {
47
+ return 0;
48
+ }
49
+ if (c.x.c3 === 0 && c.y.c3 === 0) {
50
+ return length$2(
51
+ fromPolynomials$2(
52
+ make$2(c.x.c0, c.x.c1, c.x.c2),
53
+ make$2(c.y.c0, c.y.c1, c.y.c2)
54
+ ),
55
+ i
56
+ );
57
+ }
58
+ const d = derivative(c);
59
+ const { scale, shift } = scaleShift(biunit, i);
60
+ return round(
61
+ (GL32_W0 * magnitude(solve$3(d, shift + scale * -GL32_X0)) + GL32_W0 * magnitude(solve$3(d, shift + scale * GL32_X0)) + GL32_W1 * magnitude(solve$3(d, shift + scale * -GL32_X1)) + GL32_W1 * magnitude(solve$3(d, shift + scale * GL32_X1)) + GL32_W2 * magnitude(solve$3(d, shift + scale * -GL32_X2)) + GL32_W2 * magnitude(solve$3(d, shift + scale * GL32_X2)) + GL32_W3 * magnitude(solve$3(d, shift + scale * -GL32_X3)) + GL32_W3 * magnitude(solve$3(d, shift + scale * GL32_X3)) + GL32_W4 * magnitude(solve$3(d, shift + scale * -GL32_X4)) + GL32_W4 * magnitude(solve$3(d, shift + scale * GL32_X4)) + GL32_W5 * magnitude(solve$3(d, shift + scale * -GL32_X5)) + GL32_W5 * magnitude(solve$3(d, shift + scale * GL32_X5)) + GL32_W6 * magnitude(solve$3(d, shift + scale * -GL32_X6)) + GL32_W6 * magnitude(solve$3(d, shift + scale * GL32_X6)) + GL32_W7 * magnitude(solve$3(d, shift + scale * -GL32_X7)) + GL32_W7 * magnitude(solve$3(d, shift + scale * GL32_X7)) + GL32_W8 * magnitude(solve$3(d, shift + scale * -GL32_X8)) + GL32_W8 * magnitude(solve$3(d, shift + scale * GL32_X8)) + GL32_W9 * magnitude(solve$3(d, shift + scale * -GL32_X9)) + GL32_W9 * magnitude(solve$3(d, shift + scale * GL32_X9)) + GL32_W10 * magnitude(
62
+ solve$3(d, shift + scale * -GL32_X10)
63
+ ) + GL32_W10 * magnitude(solve$3(d, shift + scale * GL32_X10)) + GL32_W11 * magnitude(
64
+ solve$3(d, shift + scale * -GL32_X11)
65
+ ) + GL32_W11 * magnitude(solve$3(d, shift + scale * GL32_X11)) + GL32_W12 * magnitude(
66
+ solve$3(d, shift + scale * -GL32_X12)
67
+ ) + GL32_W12 * magnitude(solve$3(d, shift + scale * GL32_X12)) + GL32_W13 * magnitude(
68
+ solve$3(d, shift + scale * -GL32_X13)
69
+ ) + GL32_W13 * magnitude(solve$3(d, shift + scale * GL32_X13)) + GL32_W14 * magnitude(
70
+ solve$3(d, shift + scale * -GL32_X14)
71
+ ) + GL32_W14 * magnitude(solve$3(d, shift + scale * GL32_X14)) + GL32_W15 * magnitude(
72
+ solve$3(d, shift + scale * -GL32_X15)
73
+ ) + GL32_W15 * magnitude(
74
+ solve$3(d, shift + scale * GL32_X15)
75
+ )) * scale
76
+ );
77
+ });
78
+
79
+ const fromPolynomials = fromPolynomials$1;
80
+ const fromPoints = fromPoints$1;
81
+ const isCubicCurve2d = isCubicCurve2d$1;
82
+ const solve = solve$1;
83
+ const length = length$1;
84
+
85
+ export { fromPoints, fromPolynomials, isCubicCurve2d, length, solve };
@@ -0,0 +1,27 @@
1
+ import { e as TwoDimensional } from '../shared/curvy.CT38g_II.mjs';
2
+ import { P as Pipeable } from '../shared/curvy.BN-oFBsc.mjs';
3
+ import { Interval } from '../interval.mjs';
4
+ import { L as LinearPolynomial } from '../shared/curvy.Bxxwly94.mjs';
5
+ import { Vector2 } from '../vector/vector2.mjs';
6
+ import '../vector/vector3.mjs';
7
+ import '../vector/vector4.mjs';
8
+
9
+ declare const LinearCurve2dTypeId: unique symbol;
10
+ type LinearCurve2dTypeId = typeof LinearCurve2dTypeId;
11
+
12
+ interface LinearCurve2d extends Pipeable, TwoDimensional<LinearPolynomial> {
13
+ readonly [LinearCurve2dTypeId]: LinearCurve2dTypeId;
14
+ }
15
+ declare const fromPolynomials: (x: LinearPolynomial, y: LinearPolynomial) => LinearCurve2d;
16
+ declare const fromPoints: (p0: Vector2, p1: Vector2) => LinearCurve2d;
17
+ declare const isLinearCurve2d: (c: unknown) => c is LinearCurve2d;
18
+ declare const solve: {
19
+ (t: number): (c: LinearCurve2d) => Vector2;
20
+ (c: LinearCurve2d, t: number): Vector2;
21
+ };
22
+ declare const length: {
23
+ (c: LinearCurve2d, i: Interval): number;
24
+ (i: Interval): (c: LinearCurve2d) => number;
25
+ };
26
+
27
+ export { type LinearCurve2d, fromPoints, fromPolynomials, isLinearCurve2d, length, solve };
@@ -0,0 +1,27 @@
1
+ import { e as TwoDimensional } from '../shared/curvy.CT38g_II.js';
2
+ import { P as Pipeable } from '../shared/curvy.BN-oFBsc.js';
3
+ import { Interval } from '../interval.js';
4
+ import { L as LinearPolynomial } from '../shared/curvy.CO0Wclt0.js';
5
+ import { Vector2 } from '../vector/vector2.js';
6
+ import '../vector/vector3.js';
7
+ import '../vector/vector4.js';
8
+
9
+ declare const LinearCurve2dTypeId: unique symbol;
10
+ type LinearCurve2dTypeId = typeof LinearCurve2dTypeId;
11
+
12
+ interface LinearCurve2d extends Pipeable, TwoDimensional<LinearPolynomial> {
13
+ readonly [LinearCurve2dTypeId]: LinearCurve2dTypeId;
14
+ }
15
+ declare const fromPolynomials: (x: LinearPolynomial, y: LinearPolynomial) => LinearCurve2d;
16
+ declare const fromPoints: (p0: Vector2, p1: Vector2) => LinearCurve2d;
17
+ declare const isLinearCurve2d: (c: unknown) => c is LinearCurve2d;
18
+ declare const solve: {
19
+ (t: number): (c: LinearCurve2d) => Vector2;
20
+ (c: LinearCurve2d, t: number): Vector2;
21
+ };
22
+ declare const length: {
23
+ (c: LinearCurve2d, i: Interval): number;
24
+ (i: Interval): (c: LinearCurve2d) => number;
25
+ };
26
+
27
+ export { type LinearCurve2d, fromPoints, fromPolynomials, isLinearCurve2d, length, solve };
@@ -0,0 +1,46 @@
1
+ import { d as dual, r as round, P as Pipeable } from '../shared/curvy.ChkqgKuv.mjs';
2
+ import { make, solve as solve$2 } from '../polynomial/linear.mjs';
3
+ import { make as make$1 } from '../vector/vector2.mjs';
4
+ import '../shared/curvy.DgRsieUW.mjs';
5
+ import '../interval.mjs';
6
+ import '../shared/curvy.DOLqYbKE.mjs';
7
+
8
+ const LinearCurve2dTypeId = Symbol("curvy/curve/linear2d");
9
+ class LinearCurve2dImpl extends Pipeable {
10
+ [LinearCurve2dTypeId] = LinearCurve2dTypeId;
11
+ x;
12
+ y;
13
+ constructor(c0, c1) {
14
+ super();
15
+ this.x = c0;
16
+ this.y = c1;
17
+ }
18
+ get [0]() {
19
+ return this.x;
20
+ }
21
+ get [1]() {
22
+ return this.y;
23
+ }
24
+ }
25
+ const fromPolynomials$1 = (c0, c1) => new LinearCurve2dImpl(c0, c1);
26
+ const fromPoints$1 = (p0, p1) => new LinearCurve2dImpl(
27
+ make(p0.x, p1.x),
28
+ make(p0.y, p1.y)
29
+ );
30
+ const isLinearCurve2d$1 = (c) => typeof c === "object" && c !== null && LinearCurve2dTypeId in c;
31
+ const solve$1 = dual(
32
+ 2,
33
+ (c, t) => make$1(solve$2(c.x, t), solve$2(c.y, t))
34
+ );
35
+ const length$1 = dual(
36
+ 2,
37
+ (c, i) => round(Math.sqrt(c.x.c1 ** 2 + c.y.c1 ** 2) * Math.abs(i.end - i.start))
38
+ );
39
+
40
+ const fromPolynomials = fromPolynomials$1;
41
+ const fromPoints = fromPoints$1;
42
+ const isLinearCurve2d = isLinearCurve2d$1;
43
+ const solve = solve$1;
44
+ const length = length$1;
45
+
46
+ export { fromPoints, fromPolynomials, isLinearCurve2d, length, solve };
@@ -0,0 +1,27 @@
1
+ import { e as TwoDimensional } from '../shared/curvy.CT38g_II.mjs';
2
+ import { P as Pipeable } from '../shared/curvy.BN-oFBsc.mjs';
3
+ import { Interval } from '../interval.mjs';
4
+ import { Q as QuadraticPolynomial } from '../shared/curvy.Bxxwly94.mjs';
5
+ import { Vector2 } from '../vector/vector2.mjs';
6
+ import '../vector/vector3.mjs';
7
+ import '../vector/vector4.mjs';
8
+
9
+ declare const QuadraticCurve2dTypeId: unique symbol;
10
+ type QuadraticCurve2dTypeId = typeof QuadraticCurve2dTypeId;
11
+
12
+ interface QuadraticCurve2d extends Pipeable, TwoDimensional<QuadraticPolynomial> {
13
+ readonly [QuadraticCurve2dTypeId]: QuadraticCurve2dTypeId;
14
+ }
15
+ declare const fromPolynomials: (c0: QuadraticPolynomial, c1: QuadraticPolynomial) => QuadraticCurve2d;
16
+ declare const fromPoints: (p0: Vector2, p1: Vector2, p2: Vector2) => QuadraticCurve2d;
17
+ declare const isQuadraticCurve2d: (c: unknown) => c is QuadraticCurve2d;
18
+ declare const solve: {
19
+ (t: number): (c: QuadraticCurve2d) => Vector2;
20
+ (c: QuadraticCurve2d, t: number): Vector2;
21
+ };
22
+ declare const length: {
23
+ (c: QuadraticCurve2d, i: Interval): number;
24
+ (i: Interval): (c: QuadraticCurve2d) => number;
25
+ };
26
+
27
+ export { type QuadraticCurve2d, fromPoints, fromPolynomials, isQuadraticCurve2d, length, solve };
@@ -0,0 +1,27 @@
1
+ import { e as TwoDimensional } from '../shared/curvy.CT38g_II.js';
2
+ import { P as Pipeable } from '../shared/curvy.BN-oFBsc.js';
3
+ import { Interval } from '../interval.js';
4
+ import { Q as QuadraticPolynomial } from '../shared/curvy.CO0Wclt0.js';
5
+ import { Vector2 } from '../vector/vector2.js';
6
+ import '../vector/vector3.js';
7
+ import '../vector/vector4.js';
8
+
9
+ declare const QuadraticCurve2dTypeId: unique symbol;
10
+ type QuadraticCurve2dTypeId = typeof QuadraticCurve2dTypeId;
11
+
12
+ interface QuadraticCurve2d extends Pipeable, TwoDimensional<QuadraticPolynomial> {
13
+ readonly [QuadraticCurve2dTypeId]: QuadraticCurve2dTypeId;
14
+ }
15
+ declare const fromPolynomials: (c0: QuadraticPolynomial, c1: QuadraticPolynomial) => QuadraticCurve2d;
16
+ declare const fromPoints: (p0: Vector2, p1: Vector2, p2: Vector2) => QuadraticCurve2d;
17
+ declare const isQuadraticCurve2d: (c: unknown) => c is QuadraticCurve2d;
18
+ declare const solve: {
19
+ (t: number): (c: QuadraticCurve2d) => Vector2;
20
+ (c: QuadraticCurve2d, t: number): Vector2;
21
+ };
22
+ declare const length: {
23
+ (c: QuadraticCurve2d, i: Interval): number;
24
+ (i: Interval): (c: QuadraticCurve2d) => number;
25
+ };
26
+
27
+ export { type QuadraticCurve2d, fromPoints, fromPolynomials, isQuadraticCurve2d, length, solve };
@@ -0,0 +1,74 @@
1
+ import { d as dual, r as round, P as Pipeable } from '../shared/curvy.ChkqgKuv.mjs';
2
+ import { size, scaleShift, biunit } from '../interval.mjs';
3
+ import { G as GL32_W0, a as GL32_X0, b as GL32_W1, c as GL32_X1, d as GL32_W2, e as GL32_X2, f as GL32_W3, g as GL32_X3, h as GL32_W4, i as GL32_X4, j as GL32_W5, k as GL32_X5, l as GL32_W6, m as GL32_X6, n as GL32_W7, o as GL32_X7, p as GL32_W8, q as GL32_X8, r as GL32_W9, s as GL32_X9, t as GL32_W10, u as GL32_X10, v as GL32_W11, w as GL32_X11, x as GL32_W12, y as GL32_X12, z as GL32_W13, A as GL32_X13, B as GL32_W14, C as GL32_X14, D as GL32_W15, E as GL32_X15 } from '../shared/curvy.DmVFTi0N.mjs';
4
+ import { make as make$2 } from '../polynomial/linear.mjs';
5
+ import { make, solve as solve$2, derivative as derivative$1 } from '../polynomial/quadratic.mjs';
6
+ import { make as make$1, magnitude } from '../vector/vector2.mjs';
7
+ import { length as length$2, fromPolynomials as fromPolynomials$2, solve as solve$3 } from './linear2d.mjs';
8
+ import '../shared/curvy.DgRsieUW.mjs';
9
+ import '../shared/curvy.CLzGuqek.mjs';
10
+ import '../shared/curvy.DOLqYbKE.mjs';
11
+
12
+ const QuadraticCurve2dTypeId = Symbol(
13
+ "curvy/curve/quadratic2d"
14
+ );
15
+ class QuadraticCurve2dImpl extends Pipeable {
16
+ [QuadraticCurve2dTypeId] = QuadraticCurve2dTypeId;
17
+ x;
18
+ y;
19
+ constructor(c0, c1) {
20
+ super();
21
+ this.x = c0;
22
+ this.y = c1;
23
+ }
24
+ get [0]() {
25
+ return this.x;
26
+ }
27
+ get [1]() {
28
+ return this.y;
29
+ }
30
+ }
31
+ const fromPolynomials$1 = (c0, c1) => new QuadraticCurve2dImpl(c0, c1);
32
+ const fromPoints$1 = (p0, p1, p2) => new QuadraticCurve2dImpl(
33
+ make(p0.x, p1.x, p2.x),
34
+ make(p0.y, p1.y, p2.y)
35
+ );
36
+ const isQuadraticCurve2d$1 = (c) => typeof c === "object" && c !== null && QuadraticCurve2dTypeId in c;
37
+ const solve$1 = dual(
38
+ 2,
39
+ (c, t) => make$1(
40
+ solve$2(c.x, t),
41
+ solve$2(c.y, t)
42
+ )
43
+ );
44
+ const derivative = (c) => fromPolynomials$2(
45
+ derivative$1(c.x),
46
+ derivative$1(c.y)
47
+ );
48
+ const length$1 = dual(2, (c, i) => {
49
+ if (size(i) === 0) {
50
+ return 0;
51
+ }
52
+ if (c.x.c2 === 0 && c.y.c2 === 0) {
53
+ return length$2(
54
+ fromPolynomials$2(
55
+ make$2(c.x.c0, c.x.c1),
56
+ make$2(c.y.c0, c.y.c1)
57
+ ),
58
+ i
59
+ );
60
+ }
61
+ const d = derivative(c);
62
+ const { scale, shift } = scaleShift(biunit, i);
63
+ return round(
64
+ (GL32_W0 * magnitude(solve$3(d, shift + scale * -GL32_X0)) + GL32_W0 * magnitude(solve$3(d, shift + scale * GL32_X0)) + GL32_W1 * magnitude(solve$3(d, shift + scale * -GL32_X1)) + GL32_W1 * magnitude(solve$3(d, shift + scale * GL32_X1)) + GL32_W2 * magnitude(solve$3(d, shift + scale * -GL32_X2)) + GL32_W2 * magnitude(solve$3(d, shift + scale * GL32_X2)) + GL32_W3 * magnitude(solve$3(d, shift + scale * -GL32_X3)) + GL32_W3 * magnitude(solve$3(d, shift + scale * GL32_X3)) + GL32_W4 * magnitude(solve$3(d, shift + scale * -GL32_X4)) + GL32_W4 * magnitude(solve$3(d, shift + scale * GL32_X4)) + GL32_W5 * magnitude(solve$3(d, shift + scale * -GL32_X5)) + GL32_W5 * magnitude(solve$3(d, shift + scale * GL32_X5)) + GL32_W6 * magnitude(solve$3(d, shift + scale * -GL32_X6)) + GL32_W6 * magnitude(solve$3(d, shift + scale * GL32_X6)) + GL32_W7 * magnitude(solve$3(d, shift + scale * -GL32_X7)) + GL32_W7 * magnitude(solve$3(d, shift + scale * GL32_X7)) + GL32_W8 * magnitude(solve$3(d, shift + scale * -GL32_X8)) + GL32_W8 * magnitude(solve$3(d, shift + scale * GL32_X8)) + GL32_W9 * magnitude(solve$3(d, shift + scale * -GL32_X9)) + GL32_W9 * magnitude(solve$3(d, shift + scale * GL32_X9)) + GL32_W10 * magnitude(solve$3(d, shift + scale * -GL32_X10)) + GL32_W10 * magnitude(solve$3(d, shift + scale * GL32_X10)) + GL32_W11 * magnitude(solve$3(d, shift + scale * -GL32_X11)) + GL32_W11 * magnitude(solve$3(d, shift + scale * GL32_X11)) + GL32_W12 * magnitude(solve$3(d, shift + scale * -GL32_X12)) + GL32_W12 * magnitude(solve$3(d, shift + scale * GL32_X12)) + GL32_W13 * magnitude(solve$3(d, shift + scale * -GL32_X13)) + GL32_W13 * magnitude(solve$3(d, shift + scale * GL32_X13)) + GL32_W14 * magnitude(solve$3(d, shift + scale * -GL32_X14)) + GL32_W14 * magnitude(solve$3(d, shift + scale * GL32_X14)) + GL32_W15 * magnitude(solve$3(d, shift + scale * -GL32_X15)) + GL32_W15 * magnitude(solve$3(d, shift + scale * GL32_X15))) * scale
65
+ );
66
+ });
67
+
68
+ const fromPolynomials = fromPolynomials$1;
69
+ const fromPoints = fromPoints$1;
70
+ const isQuadraticCurve2d = isQuadraticCurve2d$1;
71
+ const solve = solve$1;
72
+ const length = length$1;
73
+
74
+ export { fromPoints, fromPolynomials, isQuadraticCurve2d, length, solve };
@@ -0,0 +1,58 @@
1
+ import { P as Pipeable } from './shared/curvy.BN-oFBsc.mjs';
2
+
3
+ interface Interval extends Pipeable {
4
+ readonly start: number;
5
+ readonly end: number;
6
+ }
7
+ declare const isInterval: (v: unknown) => v is Interval;
8
+ declare const make: {
9
+ (point: number): Interval;
10
+ (start: number, end: number): Interval;
11
+ };
12
+ declare const fromSize: {
13
+ (size: number): Interval;
14
+ (start: number, size: number): Interval;
15
+ };
16
+ declare const fromMinMax: (...values: ReadonlyArray<number>) => Interval;
17
+ declare const size: (i: Interval) => number;
18
+ declare const contains: {
19
+ (interval: Interval, value: number, options?: {
20
+ includeStart?: boolean;
21
+ includeEnd?: boolean;
22
+ }): boolean;
23
+ (value: number, options?: {
24
+ includeStart?: boolean;
25
+ includeEnd?: boolean;
26
+ }): (interval: Interval) => boolean;
27
+ };
28
+ declare const filter: {
29
+ <V extends ReadonlyArray<number>>(interval: Interval, value: V, options?: {
30
+ includeStart?: boolean;
31
+ includeEnd?: boolean;
32
+ }): V;
33
+ <V extends ReadonlyArray<number>>(value: V, options?: {
34
+ includeStart?: boolean;
35
+ includeEnd?: boolean;
36
+ }): (interval: Interval) => V;
37
+ };
38
+ declare const clamp: {
39
+ (interval: Interval, value: number): number;
40
+ (value: number): (interval: Interval) => number;
41
+ (interval: Interval, value: ReadonlyArray<number>): ReadonlyArray<number>;
42
+ (value: ReadonlyArray<number>): (interval: Interval) => ReadonlyArray<number>;
43
+ };
44
+ declare const unit: Interval;
45
+ declare const biunit: Interval;
46
+ declare const lerp: (interval: Interval, t: number) => number;
47
+ declare const toLerpFn: (interval: Interval) => (t: number) => number;
48
+ declare const normalize: (interval: Interval, x: number) => number;
49
+ declare const toNormalizeFn: (interval: Interval) => (x: number) => number;
50
+ declare const remap: (source: Interval, target: Interval, x: number) => number;
51
+ declare const toRemapFn: (source: Interval, target: Interval) => (x: number) => number;
52
+ interface ScaleShift {
53
+ readonly scale: number;
54
+ readonly shift: number;
55
+ }
56
+ declare const scaleShift: (source: Interval, target: Interval) => ScaleShift;
57
+
58
+ export { type Interval, type ScaleShift, biunit, clamp, contains, filter, fromMinMax, fromSize, isInterval, lerp, make, normalize, remap, scaleShift, size, toLerpFn, toNormalizeFn, toRemapFn, unit };
@@ -0,0 +1,58 @@
1
+ import { P as Pipeable } from './shared/curvy.BN-oFBsc.js';
2
+
3
+ interface Interval extends Pipeable {
4
+ readonly start: number;
5
+ readonly end: number;
6
+ }
7
+ declare const isInterval: (v: unknown) => v is Interval;
8
+ declare const make: {
9
+ (point: number): Interval;
10
+ (start: number, end: number): Interval;
11
+ };
12
+ declare const fromSize: {
13
+ (size: number): Interval;
14
+ (start: number, size: number): Interval;
15
+ };
16
+ declare const fromMinMax: (...values: ReadonlyArray<number>) => Interval;
17
+ declare const size: (i: Interval) => number;
18
+ declare const contains: {
19
+ (interval: Interval, value: number, options?: {
20
+ includeStart?: boolean;
21
+ includeEnd?: boolean;
22
+ }): boolean;
23
+ (value: number, options?: {
24
+ includeStart?: boolean;
25
+ includeEnd?: boolean;
26
+ }): (interval: Interval) => boolean;
27
+ };
28
+ declare const filter: {
29
+ <V extends ReadonlyArray<number>>(interval: Interval, value: V, options?: {
30
+ includeStart?: boolean;
31
+ includeEnd?: boolean;
32
+ }): V;
33
+ <V extends ReadonlyArray<number>>(value: V, options?: {
34
+ includeStart?: boolean;
35
+ includeEnd?: boolean;
36
+ }): (interval: Interval) => V;
37
+ };
38
+ declare const clamp: {
39
+ (interval: Interval, value: number): number;
40
+ (value: number): (interval: Interval) => number;
41
+ (interval: Interval, value: ReadonlyArray<number>): ReadonlyArray<number>;
42
+ (value: ReadonlyArray<number>): (interval: Interval) => ReadonlyArray<number>;
43
+ };
44
+ declare const unit: Interval;
45
+ declare const biunit: Interval;
46
+ declare const lerp: (interval: Interval, t: number) => number;
47
+ declare const toLerpFn: (interval: Interval) => (t: number) => number;
48
+ declare const normalize: (interval: Interval, x: number) => number;
49
+ declare const toNormalizeFn: (interval: Interval) => (x: number) => number;
50
+ declare const remap: (source: Interval, target: Interval, x: number) => number;
51
+ declare const toRemapFn: (source: Interval, target: Interval) => (x: number) => number;
52
+ interface ScaleShift {
53
+ readonly scale: number;
54
+ readonly shift: number;
55
+ }
56
+ declare const scaleShift: (source: Interval, target: Interval) => ScaleShift;
57
+
58
+ export { type Interval, type ScaleShift, biunit, clamp, contains, filter, fromMinMax, fromSize, isInterval, lerp, make, normalize, remap, scaleShift, size, toLerpFn, toNormalizeFn, toRemapFn, unit };
@@ -0,0 +1,88 @@
1
+ import { d as dual, P as Pipeable, r as round } from './shared/curvy.ChkqgKuv.mjs';
2
+
3
+ const TypeId = Symbol.for("curvy/interval");
4
+ class IntervalImpl extends Pipeable {
5
+ [TypeId] = TypeId;
6
+ start;
7
+ end;
8
+ constructor(start = 0, end = start) {
9
+ super();
10
+ if (end < start) {
11
+ throw new Error("Interval end must be greater than or equal to start");
12
+ }
13
+ this.start = round(start);
14
+ this.end = round(end);
15
+ }
16
+ get [Symbol.toStringTag]() {
17
+ return `Interval [${this.start}, ${this.end}]`;
18
+ }
19
+ get [Symbol.for("nodejs.util.inspect.custom")]() {
20
+ return this[Symbol.toStringTag];
21
+ }
22
+ }
23
+ const isInterval$1 = (v) => typeof v === "object" && v !== null && TypeId in v;
24
+ const make$1 = (start, end) => new IntervalImpl(start, end ?? start);
25
+ const fromSize$1 = (a, b) => {
26
+ if (b === void 0) {
27
+ return new IntervalImpl(0, a);
28
+ }
29
+ return new IntervalImpl(a, a + b);
30
+ };
31
+ const fromMinMax$1 = (...values) => new IntervalImpl(Math.min(...values), Math.max(...values));
32
+ const size$1 = (i) => Math.abs(i.end - i.start);
33
+ const contains$1 = dual(
34
+ (args) => isInterval$1(args[0]),
35
+ (interval, value, { includeStart = true, includeEnd = true } = {}) => value > interval.start && value < interval.end || includeStart && value === interval.start || includeEnd && value === interval.end
36
+ );
37
+ const filter$1 = dual(
38
+ (args) => isInterval$1(args[0]),
39
+ (interval, value, options) => {
40
+ return value.filter((v) => contains$1(interval, v, options));
41
+ }
42
+ );
43
+ const clamp$1 = dual(
44
+ 2,
45
+ (interval, value) => {
46
+ if (Array.isArray(value)) {
47
+ return value.map((v) => clamp$1(interval, v));
48
+ }
49
+ return contains$1(interval, value) ? value : value < interval.start ? interval.start : interval.end;
50
+ }
51
+ );
52
+ const unit$1 = make$1(0, 1);
53
+ const biunit$1 = make$1(-1, 1);
54
+ const lerp$1 = (interval, t) => (1 - t) * interval.start + t * interval.end;
55
+ const toLerpFn$1 = (interval) => (t) => lerp$1(interval, t);
56
+ const normalize$1 = (interval, x) => (x - interval.start) / size$1(interval);
57
+ const toNormalizeFn$1 = (interval) => (x) => normalize$1(interval, x);
58
+ const remap$1 = (source, target, x) => {
59
+ return target.start + (x - source.start) * size$1(target) / size$1(source);
60
+ };
61
+ const toRemapFn$1 = (source, target) => (x) => remap$1(source, target, x);
62
+ const scaleShift$1 = (source, target) => {
63
+ const scale = size$1(target) / size$1(source);
64
+ return {
65
+ scale,
66
+ shift: target.start - source.start * scale
67
+ };
68
+ };
69
+
70
+ const isInterval = isInterval$1;
71
+ const make = make$1;
72
+ const fromSize = fromSize$1;
73
+ const fromMinMax = fromMinMax$1;
74
+ const size = size$1;
75
+ const contains = contains$1;
76
+ const filter = filter$1;
77
+ const clamp = clamp$1;
78
+ const unit = unit$1;
79
+ const biunit = biunit$1;
80
+ const lerp = lerp$1;
81
+ const toLerpFn = toLerpFn$1;
82
+ const normalize = normalize$1;
83
+ const toNormalizeFn = toNormalizeFn$1;
84
+ const remap = remap$1;
85
+ const toRemapFn = toRemapFn$1;
86
+ const scaleShift = scaleShift$1;
87
+
88
+ export { biunit, clamp, contains, filter, fromMinMax, fromSize, isInterval, lerp, make, normalize, remap, scaleShift, size, toLerpFn, toNormalizeFn, toRemapFn, unit };
@@ -0,0 +1,49 @@
1
+ import { c as TwoDimensionalIndex, d as TwoDimensionalComponent } from '../shared/curvy.CT38g_II.mjs';
2
+ import { P as Pipeable } from '../shared/curvy.BN-oFBsc.mjs';
3
+ import { Vector2 } from '../vector/vector2.mjs';
4
+
5
+ declare const Matrix2x2TypeId: unique symbol;
6
+ type Matrix2x2TypeId = typeof Matrix2x2TypeId;
7
+
8
+ type Matrix2x2Coordinate = TwoDimensionalIndex | TwoDimensionalComponent;
9
+ interface Matrix2x2 extends Pipeable {
10
+ readonly [Matrix2x2TypeId]: Matrix2x2TypeId;
11
+ readonly m00: number;
12
+ readonly m01: number;
13
+ readonly m10: number;
14
+ readonly m11: number;
15
+ }
16
+ declare const isMatrix2x2: (m: unknown) => m is Matrix2x2;
17
+ declare const matrix2x2: (m00?: number, m01?: number, m10?: number, m11?: number) => Matrix2x2;
18
+ declare const fromRows: (v0: Vector2, v1: Vector2) => Matrix2x2;
19
+ declare const fromColumns: (v0: Vector2, v1: Vector2) => Matrix2x2;
20
+ declare const setRow: {
21
+ (m: Matrix2x2, row: Matrix2x2Coordinate, v: Vector2): Matrix2x2;
22
+ (row: Matrix2x2Coordinate, v: Vector2): (m: Matrix2x2) => Matrix2x2;
23
+ };
24
+ declare const setColumn: {
25
+ (m: Matrix2x2, column: Matrix2x2Coordinate, v: Vector2): Matrix2x2;
26
+ (column: Matrix2x2Coordinate, v: Vector2): (m: Matrix2x2) => Matrix2x2;
27
+ };
28
+ declare const determinant: (m: Matrix2x2) => number;
29
+ declare const vectorProductLeft: {
30
+ (m: Matrix2x2, v: Vector2): Vector2;
31
+ (v: Vector2): (m: Matrix2x2) => Vector2;
32
+ };
33
+ declare const vectorProductRight: {
34
+ (m: Matrix2x2, v: Vector2): Vector2;
35
+ (v: Vector2): (m: Matrix2x2) => Vector2;
36
+ };
37
+ declare const solveSystem: {
38
+ (m: Matrix2x2, v: Vector2): Vector2;
39
+ (v: Vector2): (m: Matrix2x2) => Vector2;
40
+ };
41
+ declare const toRows: (m: Matrix2x2) => [Vector2, Vector2];
42
+ declare const toColumns: (m: Matrix2x2) => [Vector2, Vector2];
43
+ declare const rowVector: (m: Matrix2x2, row: Matrix2x2Coordinate) => Vector2;
44
+ declare const columnVector: (m: Matrix2x2, column: Matrix2x2Coordinate) => Vector2;
45
+ declare const transpose: (m: Matrix2x2) => Matrix2x2;
46
+ declare const reverseRows: (m: Matrix2x2) => Matrix2x2;
47
+ declare const reverseColumns: (m: Matrix2x2) => Matrix2x2;
48
+
49
+ export { type Matrix2x2, type Matrix2x2Coordinate, columnVector, determinant, fromColumns, fromRows, isMatrix2x2, matrix2x2, reverseColumns, reverseRows, rowVector, setColumn, setRow, solveSystem, toColumns, toRows, transpose, vectorProductLeft, vectorProductRight };