curvy 1.0.7 → 1.0.9

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 (109) hide show
  1. package/dist/curve/cubic2d.d.mts +80 -2
  2. package/dist/curve/cubic2d.d.ts +80 -2
  3. package/dist/curve/cubic2d.mjs +9 -26
  4. package/dist/curve/cubic2d.mjs.map +1 -0
  5. package/dist/curve/linear2d.d.mts +68 -2
  6. package/dist/curve/linear2d.d.ts +68 -2
  7. package/dist/curve/linear2d.mjs +11 -14
  8. package/dist/curve/linear2d.mjs.map +1 -0
  9. package/dist/curve/quadratic2d.d.mts +86 -2
  10. package/dist/curve/quadratic2d.d.ts +86 -2
  11. package/dist/curve/quadratic2d.mjs +10 -15
  12. package/dist/curve/quadratic2d.mjs.map +1 -0
  13. package/dist/interval.d.mts +195 -2
  14. package/dist/interval.d.ts +195 -2
  15. package/dist/interval.mjs +9 -12
  16. package/dist/interval.mjs.map +1 -0
  17. package/dist/matrix/matrix2x2.d.mts +273 -2
  18. package/dist/matrix/matrix2x2.d.ts +273 -2
  19. package/dist/matrix/matrix2x2.mjs +5 -4
  20. package/dist/matrix/matrix2x2.mjs.map +1 -0
  21. package/dist/matrix/matrix3x3.d.mts +308 -1
  22. package/dist/matrix/matrix3x3.d.ts +308 -1
  23. package/dist/matrix/matrix3x3.mjs +5 -4
  24. package/dist/matrix/matrix3x3.mjs.map +1 -0
  25. package/dist/matrix/matrix4x4.d.mts +310 -1
  26. package/dist/matrix/matrix4x4.d.ts +310 -1
  27. package/dist/matrix/matrix4x4.mjs +24 -61
  28. package/dist/matrix/matrix4x4.mjs.map +1 -0
  29. package/dist/path/cubic2d.d.mts +68 -2
  30. package/dist/path/cubic2d.d.ts +68 -2
  31. package/dist/path/cubic2d.mjs +10 -12
  32. package/dist/path/cubic2d.mjs.map +1 -0
  33. package/dist/path/linear2d.d.mts +68 -2
  34. package/dist/path/linear2d.d.ts +68 -2
  35. package/dist/path/linear2d.mjs +7 -9
  36. package/dist/path/linear2d.mjs.map +1 -0
  37. package/dist/path/quadratic2d.d.mts +67 -2
  38. package/dist/path/quadratic2d.d.ts +67 -2
  39. package/dist/path/quadratic2d.mjs +9 -13
  40. package/dist/path/quadratic2d.mjs.map +1 -0
  41. package/dist/pipe.mjs +1 -0
  42. package/dist/pipe.mjs.map +1 -0
  43. package/dist/polynomial/cubic.d.mts +1 -1
  44. package/dist/polynomial/cubic.d.ts +1 -1
  45. package/dist/polynomial/cubic.mjs +13 -28
  46. package/dist/polynomial/cubic.mjs.map +1 -0
  47. package/dist/polynomial/linear.d.mts +1 -1
  48. package/dist/polynomial/linear.d.ts +1 -1
  49. package/dist/polynomial/linear.mjs +2 -1
  50. package/dist/polynomial/linear.mjs.map +1 -0
  51. package/dist/polynomial/quadratic.d.mts +2 -2
  52. package/dist/polynomial/quadratic.d.ts +2 -2
  53. package/dist/polynomial/quadratic.mjs +5 -2
  54. package/dist/polynomial/quadratic.mjs.map +1 -0
  55. package/dist/shared/{curvy.Cps2R_RU.mjs → curvy.BkkW8Tx9.mjs} +11 -29
  56. package/dist/shared/curvy.BkkW8Tx9.mjs.map +1 -0
  57. package/dist/shared/{curvy.BzVmUIKm.mjs → curvy.BxdGW9he.mjs} +17 -32
  58. package/dist/shared/curvy.BxdGW9he.mjs.map +1 -0
  59. package/dist/shared/{curvy.C2XGH0R0.mjs → curvy.C_sCeg9J.mjs} +15 -24
  60. package/dist/shared/curvy.C_sCeg9J.mjs.map +1 -0
  61. package/dist/shared/curvy.Cg8lZVUz.d.ts +688 -0
  62. package/dist/shared/{curvy.CE4X6_Is.mjs → curvy.DCt1gGII.mjs} +11 -45
  63. package/dist/shared/curvy.DCt1gGII.mjs.map +1 -0
  64. package/dist/shared/{curvy.BZ_mTkJe.mjs → curvy.DJ4xO0al.mjs} +9 -6
  65. package/dist/shared/curvy.DJ4xO0al.mjs.map +1 -0
  66. package/dist/shared/curvy.DmVFTi0N.mjs +1 -0
  67. package/dist/shared/curvy.DmVFTi0N.mjs.map +1 -0
  68. package/dist/shared/curvy.FDaj5rlj.d.mts +688 -0
  69. package/dist/shared/{curvy.NLeFCr-9.mjs → curvy.lktriTpx.mjs} +19 -42
  70. package/dist/shared/curvy.lktriTpx.mjs.map +1 -0
  71. package/dist/shared/{curvy.Ck0of1PI.mjs → curvy.mLFprrGm.mjs} +26 -22
  72. package/dist/shared/curvy.mLFprrGm.mjs.map +1 -0
  73. package/dist/shared/{curvy.BDhiZ7He.mjs → curvy.r6f1j287.mjs} +8 -12
  74. package/dist/shared/curvy.r6f1j287.mjs.map +1 -0
  75. package/dist/splines/basis2d.d.mts +94 -2
  76. package/dist/splines/basis2d.d.ts +94 -2
  77. package/dist/splines/basis2d.mjs +13 -12
  78. package/dist/splines/basis2d.mjs.map +1 -0
  79. package/dist/splines/bezier2d.d.mts +136 -2
  80. package/dist/splines/bezier2d.d.ts +136 -2
  81. package/dist/splines/bezier2d.mjs +10 -9
  82. package/dist/splines/bezier2d.mjs.map +1 -0
  83. package/dist/splines/cardinal2d.d.mts +131 -2
  84. package/dist/splines/cardinal2d.d.ts +131 -2
  85. package/dist/splines/cardinal2d.mjs +15 -24
  86. package/dist/splines/cardinal2d.mjs.map +1 -0
  87. package/dist/splines/hermite2d.d.mts +94 -3
  88. package/dist/splines/hermite2d.d.ts +94 -3
  89. package/dist/splines/hermite2d.mjs +22 -36
  90. package/dist/splines/hermite2d.mjs.map +1 -0
  91. package/dist/utils.d.mts +179 -1
  92. package/dist/utils.d.ts +179 -1
  93. package/dist/utils.mjs +16 -7
  94. package/dist/utils.mjs.map +1 -0
  95. package/dist/vector/vector2.d.mts +259 -1
  96. package/dist/vector/vector2.d.ts +259 -1
  97. package/dist/vector/vector2.mjs +4 -2
  98. package/dist/vector/vector2.mjs.map +1 -0
  99. package/dist/vector/vector3.d.mts +345 -1
  100. package/dist/vector/vector3.d.ts +345 -1
  101. package/dist/vector/vector3.mjs +9 -2
  102. package/dist/vector/vector3.mjs.map +1 -0
  103. package/dist/vector/vector4.d.mts +163 -1
  104. package/dist/vector/vector4.d.ts +163 -1
  105. package/dist/vector/vector4.mjs +4 -2
  106. package/dist/vector/vector4.mjs.map +1 -0
  107. package/package.json +4 -4
  108. package/dist/shared/curvy.BsHoYJNv.d.ts +0 -155
  109. package/dist/shared/curvy.NsmY7zcr.d.mts +0 -155
@@ -1,7 +1,7 @@
1
1
  import { T as TwoDimensional } from '../shared/curvy.Bf5TIk31.mjs';
2
2
  import { Interval } from '../interval.mjs';
3
3
  import { Pipeable } from '../pipe.mjs';
4
- import { C as CubicPolynomial } from '../shared/curvy.NsmY7zcr.mjs';
4
+ import { C as CubicPolynomial } from '../shared/curvy.FDaj5rlj.mjs';
5
5
  import { Vector2 } from '../vector/vector2.mjs';
6
6
  import '../vector/vector3.mjs';
7
7
  import '../vector/vector4.mjs';
@@ -9,23 +9,101 @@ import '../vector/vector4.mjs';
9
9
  declare const CubicCurve2dTypeId: unique symbol;
10
10
  type CubicCurve2dTypeId = typeof CubicCurve2dTypeId;
11
11
 
12
+ /**
13
+ * A cubic curve in 2D space.
14
+ *
15
+ * All fields are readonly and immutable, and all operations create new instances.
16
+ *
17
+ * @since 1.0.0
18
+ */
12
19
  interface CubicCurve2d extends Pipeable, TwoDimensional<CubicPolynomial> {
13
20
  readonly [CubicCurve2dTypeId]: CubicCurve2dTypeId;
14
21
  }
22
+ /**
23
+ * Creates a new `CubicCurve2d` instance from polynomial parameters.
24
+ *
25
+ * @param x - The x polynomial.
26
+ * @param y - The y polynomial.
27
+ * @returns A new `CubicCurve2d` instance.
28
+ * @since 1.0.0
29
+ */
15
30
  declare const fromPolynomials: (x: CubicPolynomial, y: CubicPolynomial) => CubicCurve2d;
31
+ /**
32
+ * Creates a new `CubicCurve2d` instance from pairs of coefficients.
33
+ *
34
+ * @param p0 - The x^0 coefficients for the x and y polynomials.
35
+ * @param p1 - The x^1 coefficients for the x and y polynomials.
36
+ * @param p2 - The x^2 coefficients for the x and y polynomials.
37
+ * @param p3 - The x^3 coefficients for the x and y polynomials.
38
+ * @returns A new `CubicCurve2d` instance.
39
+ * @since 1.0.0
40
+ */
16
41
  declare const fromPoints: (p0: Vector2, p1: Vector2, p2: Vector2, p3: Vector2) => CubicCurve2d;
42
+ /**
43
+ * Checks if a value is a `CubicCurve2d`.
44
+ *
45
+ * @param c - The value to check.
46
+ * @returns `true` if the value is a `CubicCurve2d`, `false` otherwise.
47
+ * @since 1.0.0
48
+ */
17
49
  declare const isCubicCurve2d: (c: unknown) => c is CubicCurve2d;
18
50
  declare const solve: {
51
+ /**
52
+ * Solves the cubic curve for a given parameter t.
53
+ *
54
+ * @param t - The parameter value.
55
+ * @returns A function that takes a cubic curve and returns the point on the curve at parameter t.
56
+ * @since 1.0.0
57
+ */
19
58
  (t: number): (c: CubicCurve2d) => Vector2;
59
+ /**
60
+ * Solves the cubic curve for a given parameter t.
61
+ *
62
+ * @param c - The cubic curve to solve.
63
+ * @param t - The parameter value.
64
+ * @returns The point on the curve at parameter t.
65
+ * @since 1.0.0
66
+ */
20
67
  (c: CubicCurve2d, t: number): Vector2;
21
68
  };
22
69
  declare const length: {
70
+ /**
71
+ * Calculates (approximates) the length of a cubic curve.
72
+ *
73
+ * @param c - The cubic curve to calculate the length of.
74
+ * @param i - The interval over which to calculate the length.
75
+ * @returns The length of the cubic curve.
76
+ * @since 1.0.0
77
+ */
23
78
  (c: CubicCurve2d, i: Interval): number;
79
+ /**
80
+ * Calculates (approximates) the length of a cubic curve.
81
+ *
82
+ * @param i - The interval over which to calculate the length.
83
+ * @returns A function that takes a cubic curve and returns the length of the cubic curve.
84
+ * @since 1.0.0
85
+ */
24
86
  (i: Interval): (c: CubicCurve2d) => number;
25
87
  };
26
88
  declare const curvature: {
89
+ /**
90
+ * Calculates the curvature of a cubic curve at a given parameter.
91
+ *
92
+ * @param c - The cubic curve to calculate the curvature for.
93
+ * @param t - The parameter value.
94
+ * @returns The curvature of the cubic curve at parameter t.
95
+ * @since 1.0.0
96
+ */
27
97
  (c: CubicCurve2d, t: number): number;
98
+ /**
99
+ * Calculates the curvature of a cubic curve at a given parameter.
100
+ *
101
+ * @param t - The parameter value.
102
+ * @returns A function that takes a cubic curve and returns the curvature of the cubic curve at parameter t.
103
+ * @since 1.0.0
104
+ */
28
105
  (t: number): (c: CubicCurve2d) => number;
29
106
  };
30
107
 
31
- export { type CubicCurve2d, curvature, fromPoints, fromPolynomials, isCubicCurve2d, length, solve };
108
+ export { curvature, fromPoints, fromPolynomials, isCubicCurve2d, length, solve };
109
+ export type { CubicCurve2d };
@@ -1,7 +1,7 @@
1
1
  import { T as TwoDimensional } from '../shared/curvy.Bf5TIk31.js';
2
2
  import { Interval } from '../interval.js';
3
3
  import { Pipeable } from '../pipe.js';
4
- import { C as CubicPolynomial } from '../shared/curvy.BsHoYJNv.js';
4
+ import { C as CubicPolynomial } from '../shared/curvy.Cg8lZVUz.js';
5
5
  import { Vector2 } from '../vector/vector2.js';
6
6
  import '../vector/vector3.js';
7
7
  import '../vector/vector4.js';
@@ -9,23 +9,101 @@ import '../vector/vector4.js';
9
9
  declare const CubicCurve2dTypeId: unique symbol;
10
10
  type CubicCurve2dTypeId = typeof CubicCurve2dTypeId;
11
11
 
12
+ /**
13
+ * A cubic curve in 2D space.
14
+ *
15
+ * All fields are readonly and immutable, and all operations create new instances.
16
+ *
17
+ * @since 1.0.0
18
+ */
12
19
  interface CubicCurve2d extends Pipeable, TwoDimensional<CubicPolynomial> {
13
20
  readonly [CubicCurve2dTypeId]: CubicCurve2dTypeId;
14
21
  }
22
+ /**
23
+ * Creates a new `CubicCurve2d` instance from polynomial parameters.
24
+ *
25
+ * @param x - The x polynomial.
26
+ * @param y - The y polynomial.
27
+ * @returns A new `CubicCurve2d` instance.
28
+ * @since 1.0.0
29
+ */
15
30
  declare const fromPolynomials: (x: CubicPolynomial, y: CubicPolynomial) => CubicCurve2d;
31
+ /**
32
+ * Creates a new `CubicCurve2d` instance from pairs of coefficients.
33
+ *
34
+ * @param p0 - The x^0 coefficients for the x and y polynomials.
35
+ * @param p1 - The x^1 coefficients for the x and y polynomials.
36
+ * @param p2 - The x^2 coefficients for the x and y polynomials.
37
+ * @param p3 - The x^3 coefficients for the x and y polynomials.
38
+ * @returns A new `CubicCurve2d` instance.
39
+ * @since 1.0.0
40
+ */
16
41
  declare const fromPoints: (p0: Vector2, p1: Vector2, p2: Vector2, p3: Vector2) => CubicCurve2d;
42
+ /**
43
+ * Checks if a value is a `CubicCurve2d`.
44
+ *
45
+ * @param c - The value to check.
46
+ * @returns `true` if the value is a `CubicCurve2d`, `false` otherwise.
47
+ * @since 1.0.0
48
+ */
17
49
  declare const isCubicCurve2d: (c: unknown) => c is CubicCurve2d;
18
50
  declare const solve: {
51
+ /**
52
+ * Solves the cubic curve for a given parameter t.
53
+ *
54
+ * @param t - The parameter value.
55
+ * @returns A function that takes a cubic curve and returns the point on the curve at parameter t.
56
+ * @since 1.0.0
57
+ */
19
58
  (t: number): (c: CubicCurve2d) => Vector2;
59
+ /**
60
+ * Solves the cubic curve for a given parameter t.
61
+ *
62
+ * @param c - The cubic curve to solve.
63
+ * @param t - The parameter value.
64
+ * @returns The point on the curve at parameter t.
65
+ * @since 1.0.0
66
+ */
20
67
  (c: CubicCurve2d, t: number): Vector2;
21
68
  };
22
69
  declare const length: {
70
+ /**
71
+ * Calculates (approximates) the length of a cubic curve.
72
+ *
73
+ * @param c - The cubic curve to calculate the length of.
74
+ * @param i - The interval over which to calculate the length.
75
+ * @returns The length of the cubic curve.
76
+ * @since 1.0.0
77
+ */
23
78
  (c: CubicCurve2d, i: Interval): number;
79
+ /**
80
+ * Calculates (approximates) the length of a cubic curve.
81
+ *
82
+ * @param i - The interval over which to calculate the length.
83
+ * @returns A function that takes a cubic curve and returns the length of the cubic curve.
84
+ * @since 1.0.0
85
+ */
24
86
  (i: Interval): (c: CubicCurve2d) => number;
25
87
  };
26
88
  declare const curvature: {
89
+ /**
90
+ * Calculates the curvature of a cubic curve at a given parameter.
91
+ *
92
+ * @param c - The cubic curve to calculate the curvature for.
93
+ * @param t - The parameter value.
94
+ * @returns The curvature of the cubic curve at parameter t.
95
+ * @since 1.0.0
96
+ */
27
97
  (c: CubicCurve2d, t: number): number;
98
+ /**
99
+ * Calculates the curvature of a cubic curve at a given parameter.
100
+ *
101
+ * @param t - The parameter value.
102
+ * @returns A function that takes a cubic curve and returns the curvature of the cubic curve at parameter t.
103
+ * @since 1.0.0
104
+ */
28
105
  (t: number): (c: CubicCurve2d) => number;
29
106
  };
30
107
 
31
- export { type CubicCurve2d, curvature, fromPoints, fromPolynomials, isCubicCurve2d, length, solve };
108
+ export { curvature, fromPoints, fromPolynomials, isCubicCurve2d, length, solve };
109
+ export type { CubicCurve2d };
@@ -7,18 +7,17 @@ import { round } from '../utils.mjs';
7
7
  import { make as make$1, magnitude, cross } from '../vector/vector2.mjs';
8
8
  import { solve as solve$4 } from './linear2d.mjs';
9
9
  import { length as length$2, fromPolynomials as fromPolynomials$2, solve as solve$3, derivative as derivative$1 } from './quadratic2d.mjs';
10
- import '../shared/curvy.BzVmUIKm.mjs';
11
- import '../shared/curvy.BDhiZ7He.mjs';
12
- import '../shared/curvy.BZ_mTkJe.mjs';
10
+ import '../shared/curvy.BxdGW9he.mjs';
11
+ import '../shared/curvy.r6f1j287.mjs';
12
+ import '../shared/curvy.DJ4xO0al.mjs';
13
13
  import '../polynomial/linear.mjs';
14
14
 
15
+ var _a, _b;
15
16
  const CubicCurve2dTypeId = Symbol("curvy/curve/cubic2d");
16
- class CubicCurve2dImpl extends Pipeable {
17
- [CubicCurve2dTypeId] = CubicCurve2dTypeId;
18
- x;
19
- y;
17
+ class CubicCurve2dImpl extends (_b = Pipeable, _a = CubicCurve2dTypeId, _b) {
20
18
  constructor(c0, c1) {
21
19
  super();
20
+ this[_a] = CubicCurve2dTypeId;
22
21
  this.x = c0;
23
22
  this.y = c1;
24
23
  }
@@ -39,10 +38,7 @@ const solve$1 = dual(
39
38
  2,
40
39
  (c, t) => make$1(solve$2(c.x, t), solve$2(c.y, t))
41
40
  );
42
- const derivative = (c) => fromPolynomials$2(
43
- derivative$2(c.x),
44
- derivative$2(c.y)
45
- );
41
+ const derivative = (c) => fromPolynomials$2(derivative$2(c.x), derivative$2(c.y));
46
42
  const length$1 = dual(2, (c, i) => {
47
43
  if (size(i) === 0) {
48
44
  return 0;
@@ -59,21 +55,7 @@ const length$1 = dual(2, (c, i) => {
59
55
  const d = derivative(c);
60
56
  const { scale, shift } = scaleShift(biunit, i);
61
57
  return round(
62
- (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(
63
- solve$3(d, shift + scale * -GL32_X10)
64
- ) + GL32_W10 * magnitude(solve$3(d, shift + scale * GL32_X10)) + GL32_W11 * magnitude(
65
- solve$3(d, shift + scale * -GL32_X11)
66
- ) + GL32_W11 * magnitude(solve$3(d, shift + scale * GL32_X11)) + GL32_W12 * magnitude(
67
- solve$3(d, shift + scale * -GL32_X12)
68
- ) + GL32_W12 * magnitude(solve$3(d, shift + scale * GL32_X12)) + GL32_W13 * magnitude(
69
- solve$3(d, shift + scale * -GL32_X13)
70
- ) + GL32_W13 * magnitude(solve$3(d, shift + scale * GL32_X13)) + GL32_W14 * magnitude(
71
- solve$3(d, shift + scale * -GL32_X14)
72
- ) + GL32_W14 * magnitude(solve$3(d, shift + scale * GL32_X14)) + GL32_W15 * magnitude(
73
- solve$3(d, shift + scale * -GL32_X15)
74
- ) + GL32_W15 * magnitude(
75
- solve$3(d, shift + scale * GL32_X15)
76
- )) * scale
58
+ (GL32_W0 * magnitude(solve$3(d, shift + scale * -0.9972638618494816)) + GL32_W0 * magnitude(solve$3(d, shift + scale * GL32_X0)) + GL32_W1 * magnitude(solve$3(d, shift + scale * -0.9856115115452684)) + GL32_W1 * magnitude(solve$3(d, shift + scale * GL32_X1)) + GL32_W2 * magnitude(solve$3(d, shift + scale * -0.9647622555875064)) + GL32_W2 * magnitude(solve$3(d, shift + scale * GL32_X2)) + GL32_W3 * magnitude(solve$3(d, shift + scale * -0.9349060759377397)) + GL32_W3 * magnitude(solve$3(d, shift + scale * GL32_X3)) + GL32_W4 * magnitude(solve$3(d, shift + scale * -0.8963211557660521)) + GL32_W4 * magnitude(solve$3(d, shift + scale * GL32_X4)) + GL32_W5 * magnitude(solve$3(d, shift + scale * -0.84936761373257)) + GL32_W5 * magnitude(solve$3(d, shift + scale * GL32_X5)) + GL32_W6 * magnitude(solve$3(d, shift + scale * -0.7944837959679424)) + GL32_W6 * magnitude(solve$3(d, shift + scale * GL32_X6)) + GL32_W7 * magnitude(solve$3(d, shift + scale * -0.7321821187402897)) + GL32_W7 * magnitude(solve$3(d, shift + scale * GL32_X7)) + GL32_W8 * magnitude(solve$3(d, shift + scale * -0.6630442669302152)) + GL32_W8 * magnitude(solve$3(d, shift + scale * GL32_X8)) + GL32_W9 * magnitude(solve$3(d, shift + scale * -0.5877157572407623)) + GL32_W9 * magnitude(solve$3(d, shift + scale * GL32_X9)) + GL32_W10 * magnitude(solve$3(d, shift + scale * -0.5068999089322294)) + GL32_W10 * magnitude(solve$3(d, shift + scale * GL32_X10)) + GL32_W11 * magnitude(solve$3(d, shift + scale * -0.42135127613063533)) + GL32_W11 * magnitude(solve$3(d, shift + scale * GL32_X11)) + GL32_W12 * magnitude(solve$3(d, shift + scale * -0.33186860228212767)) + GL32_W12 * magnitude(solve$3(d, shift + scale * GL32_X12)) + GL32_W13 * magnitude(solve$3(d, shift + scale * -0.23928736225213706)) + GL32_W13 * magnitude(solve$3(d, shift + scale * GL32_X13)) + GL32_W14 * magnitude(solve$3(d, shift + scale * -0.1444719615827965)) + GL32_W14 * magnitude(solve$3(d, shift + scale * GL32_X14)) + GL32_W15 * magnitude(solve$3(d, shift + scale * -0.04830766568773831)) + GL32_W15 * magnitude(solve$3(d, shift + scale * GL32_X15))) * scale
77
59
  );
78
60
  });
79
61
  const curvature$1 = dual(2, (c, t) => {
@@ -95,3 +77,4 @@ const length = length$1;
95
77
  const curvature = curvature$1;
96
78
 
97
79
  export { curvature, fromPoints, fromPolynomials, isCubicCurve2d, length, solve };
80
+ //# sourceMappingURL=cubic2d.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cubic2d.mjs","sources":["../../src/curve/cubic2d.internal.ts","../../src/curve/cubic2d.ts"],"sourcesContent":["import * as Interval from '../interval'\nimport {\n GL32_W0,\n GL32_W1,\n GL32_W2,\n GL32_W3,\n GL32_W4,\n GL32_W5,\n GL32_W6,\n GL32_W7,\n GL32_W8,\n GL32_W9,\n GL32_W10,\n GL32_W11,\n GL32_W12,\n GL32_W13,\n GL32_W14,\n GL32_W15,\n GL32_X0,\n GL32_X1,\n GL32_X2,\n GL32_X3,\n GL32_X4,\n GL32_X5,\n GL32_X6,\n GL32_X7,\n GL32_X8,\n GL32_X9,\n GL32_X10,\n GL32_X11,\n GL32_X12,\n GL32_X13,\n GL32_X14,\n GL32_X15,\n} from '../length'\nimport { Pipeable } from '../pipe'\nimport { dual } from '../pipe'\nimport * as CubicPolynomial from '../polynomial/cubic'\nimport * as QuadraticPolynomial from '../polynomial/quadratic'\nimport { round } from '../utils'\nimport * as Vector2 from '../vector/vector2'\nimport type { CubicCurve2d } from './cubic2d'\nimport * as LinearCurve2d from './linear2d'\nimport * as QuadraticCurve2d from './quadratic2d'\n\nexport const CubicCurve2dTypeId: unique symbol = Symbol('curvy/curve/cubic2d')\nexport type CubicCurve2dTypeId = typeof CubicCurve2dTypeId\n\nexport class CubicCurve2dImpl extends Pipeable implements CubicCurve2d {\n readonly [CubicCurve2dTypeId]: CubicCurve2dTypeId = CubicCurve2dTypeId\n\n readonly x: CubicPolynomial.CubicPolynomial\n readonly y: CubicPolynomial.CubicPolynomial\n\n constructor(c0: CubicPolynomial.CubicPolynomial, c1: CubicPolynomial.CubicPolynomial) {\n super()\n this.x = c0\n this.y = c1\n }\n\n get [0]() {\n return this.x\n }\n\n get [1]() {\n return this.y\n }\n}\n\nexport const fromPolynomials: (\n c0: CubicPolynomial.CubicPolynomial,\n c1: CubicPolynomial.CubicPolynomial,\n) => CubicCurve2d = (c0, c1) => new CubicCurve2dImpl(c0, c1)\n\nexport const fromPoints: (\n p0: Vector2.Vector2,\n p1: Vector2.Vector2,\n p2: Vector2.Vector2,\n p3: Vector2.Vector2,\n) => CubicCurve2d = (p0, p1, p2, p3) =>\n new CubicCurve2dImpl(\n CubicPolynomial.make(p0.x, p1.x, p2.x, p3.x),\n CubicPolynomial.make(p0.y, p1.y, p2.y, p3.y),\n )\n\nexport const isCubicCurve2d = (c: unknown): c is CubicCurve2d =>\n typeof c === 'object' && c !== null && CubicCurve2dTypeId in c\n\nexport const solve = dual<\n (t: number) => (c: CubicCurve2d) => Vector2.Vector2,\n (c: CubicCurve2d, t: number) => Vector2.Vector2\n>(2, (c: CubicCurve2d, t: number) =>\n Vector2.make(CubicPolynomial.solve(c.x, t), CubicPolynomial.solve(c.y, t)),\n)\n\nexport const derivative = (c: CubicCurve2d) =>\n QuadraticCurve2d.fromPolynomials(CubicPolynomial.derivative(c.x), CubicPolynomial.derivative(c.y))\n\nexport const length = dual(2, (c: CubicCurve2d, i: Interval.Interval) => {\n if (Interval.size(i) === 0) {\n return 0\n }\n\n if (c.x.c3 === 0 && c.y.c3 === 0) {\n return QuadraticCurve2d.length(\n QuadraticCurve2d.fromPolynomials(\n QuadraticPolynomial.make(c.x.c0, c.x.c1, c.x.c2),\n QuadraticPolynomial.make(c.y.c0, c.y.c1, c.y.c2),\n ),\n i,\n )\n }\n\n const d = derivative(c)\n\n const { scale, shift } = Interval.scaleShift(Interval.biunit, i)\n\n return round(\n (GL32_W0 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * -GL32_X0)) +\n GL32_W0 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * GL32_X0)) +\n GL32_W1 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * -GL32_X1)) +\n GL32_W1 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * GL32_X1)) +\n GL32_W2 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * -GL32_X2)) +\n GL32_W2 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * GL32_X2)) +\n GL32_W3 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * -GL32_X3)) +\n GL32_W3 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * GL32_X3)) +\n GL32_W4 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * -GL32_X4)) +\n GL32_W4 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * GL32_X4)) +\n GL32_W5 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * -GL32_X5)) +\n GL32_W5 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * GL32_X5)) +\n GL32_W6 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * -GL32_X6)) +\n GL32_W6 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * GL32_X6)) +\n GL32_W7 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * -GL32_X7)) +\n GL32_W7 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * GL32_X7)) +\n GL32_W8 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * -GL32_X8)) +\n GL32_W8 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * GL32_X8)) +\n GL32_W9 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * -GL32_X9)) +\n GL32_W9 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * GL32_X9)) +\n GL32_W10 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * -GL32_X10)) +\n GL32_W10 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * GL32_X10)) +\n GL32_W11 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * -GL32_X11)) +\n GL32_W11 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * GL32_X11)) +\n GL32_W12 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * -GL32_X12)) +\n GL32_W12 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * GL32_X12)) +\n GL32_W13 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * -GL32_X13)) +\n GL32_W13 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * GL32_X13)) +\n GL32_W14 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * -GL32_X14)) +\n GL32_W14 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * GL32_X14)) +\n GL32_W15 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * -GL32_X15)) +\n GL32_W15 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * GL32_X15))) *\n scale,\n )\n})\n\nexport const curvature = dual(2, (c: CubicCurve2d, t: number) => {\n const d = derivative(c)\n\n const v = QuadraticCurve2d.solve(d, t)\n const a = LinearCurve2d.solve(QuadraticCurve2d.derivative(d), t)\n\n const vMag = Vector2.magnitude(v)\n\n if (vMag === 0) {\n return 0\n }\n\n return round(Math.abs(Vector2.cross(v, a)) / vMag ** 3)\n})\n","import type { TwoDimensional } from '../dimensions'\nimport type { Interval } from '../interval'\nimport type { Pipeable } from '../pipe'\nimport type { CubicPolynomial } from '../polynomial/cubic'\nimport type { Vector2 } from '../vector/vector2'\nimport type { CubicCurve2dTypeId } from './cubic2d.internal'\nimport * as internal from './cubic2d.internal'\n\n/**\n * A cubic curve in 2D space.\n *\n * All fields are readonly and immutable, and all operations create new instances.\n *\n * @since 1.0.0\n */\nexport interface CubicCurve2d extends Pipeable, TwoDimensional<CubicPolynomial> {\n readonly [CubicCurve2dTypeId]: CubicCurve2dTypeId\n}\n\n/**\n * Creates a new `CubicCurve2d` instance from polynomial parameters.\n *\n * @param x - The x polynomial.\n * @param y - The y polynomial.\n * @returns A new `CubicCurve2d` instance.\n * @since 1.0.0\n */\nexport const fromPolynomials: (x: CubicPolynomial, y: CubicPolynomial) => CubicCurve2d =\n internal.fromPolynomials\n\n/**\n * Creates a new `CubicCurve2d` instance from pairs of coefficients.\n *\n * @param p0 - The x^0 coefficients for the x and y polynomials.\n * @param p1 - The x^1 coefficients for the x and y polynomials.\n * @param p2 - The x^2 coefficients for the x and y polynomials.\n * @param p3 - The x^3 coefficients for the x and y polynomials.\n * @returns A new `CubicCurve2d` instance.\n * @since 1.0.0\n */\nexport const fromPoints: (p0: Vector2, p1: Vector2, p2: Vector2, p3: Vector2) => CubicCurve2d =\n internal.fromPoints\n\n/**\n * Checks if a value is a `CubicCurve2d`.\n *\n * @param c - The value to check.\n * @returns `true` if the value is a `CubicCurve2d`, `false` otherwise.\n * @since 1.0.0\n */\nexport const isCubicCurve2d: (c: unknown) => c is CubicCurve2d = internal.isCubicCurve2d\n\nexport const solve: {\n /**\n * Solves the cubic curve for a given parameter t.\n *\n * @param t - The parameter value.\n * @returns A function that takes a cubic curve and returns the point on the curve at parameter t.\n * @since 1.0.0\n */\n (t: number): (c: CubicCurve2d) => Vector2\n /**\n * Solves the cubic curve for a given parameter t.\n *\n * @param c - The cubic curve to solve.\n * @param t - The parameter value.\n * @returns The point on the curve at parameter t.\n * @since 1.0.0\n */\n (c: CubicCurve2d, t: number): Vector2\n} = internal.solve\n\nexport const length: {\n /**\n * Calculates (approximates) the length of a cubic curve.\n *\n * @param c - The cubic curve to calculate the length of.\n * @param i - The interval over which to calculate the length.\n * @returns The length of the cubic curve.\n * @since 1.0.0\n */\n (c: CubicCurve2d, i: Interval): number\n /**\n * Calculates (approximates) the length of a cubic curve.\n *\n * @param i - The interval over which to calculate the length.\n * @returns A function that takes a cubic curve and returns the length of the cubic curve.\n * @since 1.0.0\n */\n (i: Interval): (c: CubicCurve2d) => number\n} = internal.length\n\nexport const curvature: {\n /**\n * Calculates the curvature of a cubic curve at a given parameter.\n *\n * @param c - The cubic curve to calculate the curvature for.\n * @param t - The parameter value.\n * @returns The curvature of the cubic curve at parameter t.\n * @since 1.0.0\n */\n (c: CubicCurve2d, t: number): number\n /**\n * Calculates the curvature of a cubic curve at a given parameter.\n *\n * @param t - The parameter value.\n * @returns A function that takes a cubic curve and returns the curvature of the cubic curve at parameter t.\n * @since 1.0.0\n */\n (t: number): (c: CubicCurve2d) => number\n} = internal.curvature\n"],"names":["fromPolynomials","fromPoints","CubicPolynomial.make","isCubicCurve2d","solve","Vector2.make","CubicPolynomial.solve","QuadraticCurve2d.fromPolynomials","CubicPolynomial.derivative","length","Interval.size","QuadraticCurve2d.length","QuadraticPolynomial.make","Interval.scaleShift","Interval.biunit","Vector2.magnitude","QuadraticCurve2d.solve","curvature","LinearCurve2d.solve","QuadraticCurve2d.derivative","Vector2.cross","internal.fromPolynomials","internal.fromPoints","internal.isCubicCurve2d","internal.solve","internal.length","internal.curvature"],"mappings":";;;;;;;;;;;;;;AAAA,IAAA,EAAA,EAAA,EAAA;AA6Ca,MAAA,kBAAA,GAAoC,OAAO,qBAAqB,CAAA;AAGhE,MAAA,gBAAA,UAAyB,EAC1B,GAAA,QAAA,EAAA,EAAA,GAAA,kBAAA,EAD0B,EAAiC,EAAA;AAAA,EAMrE,WAAA,CAAY,IAAqC,EAAqC,EAAA;AACpF,IAAM,KAAA,EAAA;AANR,IAAA,IAAA,CAAU,EAA0C,CAAA,GAAA,kBAAA;AAOlD,IAAA,IAAA,CAAK,CAAI,GAAA,EAAA;AACT,IAAA,IAAA,CAAK,CAAI,GAAA,EAAA;AAAA;AACX,EAEA,KAAK,CAAC,CAAI,GAAA;AACR,IAAA,OAAO,IAAK,CAAA,CAAA;AAAA;AACd,EAEA,KAAK,CAAC,CAAI,GAAA;AACR,IAAA,OAAO,IAAK,CAAA,CAAA;AAAA;AAEhB;AAEO,MAAMA,oBAGO,CAAC,EAAA,EAAI,OAAO,IAAI,gBAAA,CAAiB,IAAI,EAAE,CAAA;AAEpD,MAAMC,eAKO,CAAC,EAAA,EAAI,EAAI,EAAA,EAAA,EAAI,OAC/B,IAAI,gBAAA;AAAA,EACFC,KAAqB,EAAG,CAAA,CAAA,EAAG,GAAG,CAAG,EAAA,EAAA,CAAG,CAAG,EAAA,EAAA,CAAG,CAAC,CAAA;AAAA,EAC3CA,KAAqB,EAAG,CAAA,CAAA,EAAG,GAAG,CAAG,EAAA,EAAA,CAAG,CAAG,EAAA,EAAA,CAAG,CAAC;AAC7C,CAAA;AAEW,MAAAC,gBAAA,GAAiB,CAAC,CAC7B,KAAA,OAAO,MAAM,QAAY,IAAA,CAAA,KAAM,QAAQ,kBAAsB,IAAA,CAAA;AAExD,MAAMC,OAAQ,GAAA,IAAA;AAAA,EAGnB,CAAA;AAAA,EAAG,CAAC,CAA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CAAM,GAAG,KAAQ,GAAA,KAAA,GAAQ,mBAAS,CAAC,IACjF,QAAW,GAAAD,UAAkBC,OAAiB,CAAM,GAAG,KAAQ,GAAA,KAAA,GAAQ,QAAQ,CAAC,CAAA,GAChF,WAAWD,SAAQ,CAAUC,OAAuB,CAAA,CAAA,EAAG,QAAQ,KAAQ,GAAA,oBAAS,CAAC,CAAA,GACjF,WAAWD,SAAQ,CAAUC,OAAuB,CAAA,CAAA,EAAG,QAAQ,KAAQ,GAAA,QAAQ,CAAC,CAChF,IAAA;AAAA,GACJ;AACF,CAAC,CAAA;AAEM,MAAMC,WAAY,GAAA,IAAA,CAAK,CAAG,EAAA,CAAC,GAAiB,CAAc,KAAA;AAC/D,EAAM,MAAA,CAAA,GAAI,WAAW,CAAC,CAAA;AAEtB,EAAA,MAAM,CAAI,GAAAD,OAAuB,CAAA,CAAA,EAAG,CAAC,CAAA;AACrC,EAAA,MAAM,IAAIE,OAAc,CAAMC,YAA4B,CAAA,CAAC,GAAG,CAAC,CAAA;AAE/D,EAAM,MAAA,IAAA,GAAOJ,SAAQ,CAAU,CAAC,CAAA;AAEhC,EAAA,IAAI,SAAS,CAAG,EAAA;AACd,IAAO,OAAA,CAAA;AAAA;AAGT,EAAO,OAAA,KAAA,CAAM,IAAK,CAAA,GAAA,CAAIK,KAAQ,CAAM,GAAG,CAAC,CAAC,CAAI,GAAA,IAAA,IAAQ,CAAC,CAAA;AACxD,CAAC,CAAA;;AC5IM,MAAM,kBACXC;AAYK,MAAM,aACXC;AASK,MAAM,iBAAoDC;AAE1D,MAAM,QAkBTC;AAEG,MAAM,SAkBTC;AAEG,MAAM,YAkBTC;;;;"}
@@ -1,7 +1,7 @@
1
1
  import { T as TwoDimensional } from '../shared/curvy.Bf5TIk31.mjs';
2
2
  import { Interval } from '../interval.mjs';
3
3
  import { Pipeable } from '../pipe.mjs';
4
- import { L as LinearPolynomial } from '../shared/curvy.NsmY7zcr.mjs';
4
+ import { L as LinearPolynomial } from '../shared/curvy.FDaj5rlj.mjs';
5
5
  import { Vector2 } from '../vector/vector2.mjs';
6
6
  import '../vector/vector3.mjs';
7
7
  import '../vector/vector4.mjs';
@@ -9,20 +9,86 @@ import '../vector/vector4.mjs';
9
9
  declare const LinearCurve2dTypeId: unique symbol;
10
10
  type LinearCurve2dTypeId = typeof LinearCurve2dTypeId;
11
11
 
12
+ /**
13
+ * A linear curve in 2D space.
14
+ *
15
+ * All fields are readonly and immutable, and all operations create new instances.
16
+ *
17
+ * @since 1.0.0
18
+ */
12
19
  interface LinearCurve2d extends Pipeable, TwoDimensional<LinearPolynomial> {
13
20
  readonly [LinearCurve2dTypeId]: LinearCurve2dTypeId;
14
21
  }
22
+ /**
23
+ * Creates a new `LinearCurve2d` instance from polynomial parameters.
24
+ *
25
+ * @param x - The x polynomial.
26
+ * @param y - The y polynomial.
27
+ * @returns A new `LinearCurve2d` instance.
28
+ * @since 1.0.0
29
+ */
15
30
  declare const fromPolynomials: (x: LinearPolynomial, y: LinearPolynomial) => LinearCurve2d;
31
+ /**
32
+ * Creates a new `LinearCurve2d` instance from pairs of coefficients.
33
+ *
34
+ * @param p0 - The x^0 coefficients for the x and y polynomials.
35
+ * @param p1 - The x^1 coefficients for the x and y polynomials.
36
+ */
16
37
  declare const fromPoints: (p0: Vector2, p1: Vector2) => LinearCurve2d;
38
+ /**
39
+ * Checks if a value is a `LinearCurve2d`.
40
+ *
41
+ * @param c - The value to check.
42
+ * @returns `true` if the value is a `LinearCurve2d`, `false` otherwise.
43
+ * @since 1.0.0
44
+ */
17
45
  declare const isLinearCurve2d: (c: unknown) => c is LinearCurve2d;
46
+ /**
47
+ * Gets the derivative of a linear curve as a vector
48
+ *
49
+ * @param c - The linear curve to get the derivative of.
50
+ * @returns The derivative of the linear curve as a vector.
51
+ * @since 1.0.0
52
+ */
18
53
  declare const derivative: (c: LinearCurve2d) => Vector2;
19
54
  declare const solve: {
55
+ /**
56
+ * Solves the linear curve for a given parameter t.
57
+ *
58
+ * @param t - The parameter value.
59
+ * @returns A function that takes a linear curve and returns the point on the curve at parameter t.
60
+ * @since 1.0.0
61
+ */
20
62
  (t: number): (c: LinearCurve2d) => Vector2;
63
+ /**
64
+ * Solves the linear curve for a given parameter t.
65
+ *
66
+ * @param c - The linear curve to solve.
67
+ * @param t - The parameter value.
68
+ * @returns The point on the curve at parameter t.
69
+ * @since 1.0.0
70
+ */
21
71
  (c: LinearCurve2d, t: number): Vector2;
22
72
  };
23
73
  declare const length: {
74
+ /**
75
+ * Calculates (approximates) the length of a linear curve.
76
+ *
77
+ * @param c - The linear curve to calculate the length of.
78
+ * @param i - The interval to calculate the length over.
79
+ * @returns The length of the linear curve over the given interval.
80
+ * @since 1.0.0
81
+ */
24
82
  (c: LinearCurve2d, i: Interval): number;
83
+ /**
84
+ * Calculates (approximates) the length of a linear curve.
85
+ *
86
+ * @param i - The interval to calculate the length over.
87
+ * @returns A function that takes a linear curve and returns the length of the linear curve over the given interval.
88
+ * @since 1.0.0
89
+ */
25
90
  (i: Interval): (c: LinearCurve2d) => number;
26
91
  };
27
92
 
28
- export { type LinearCurve2d, derivative, fromPoints, fromPolynomials, isLinearCurve2d, length, solve };
93
+ export { derivative, fromPoints, fromPolynomials, isLinearCurve2d, length, solve };
94
+ export type { LinearCurve2d };
@@ -1,7 +1,7 @@
1
1
  import { T as TwoDimensional } from '../shared/curvy.Bf5TIk31.js';
2
2
  import { Interval } from '../interval.js';
3
3
  import { Pipeable } from '../pipe.js';
4
- import { L as LinearPolynomial } from '../shared/curvy.BsHoYJNv.js';
4
+ import { L as LinearPolynomial } from '../shared/curvy.Cg8lZVUz.js';
5
5
  import { Vector2 } from '../vector/vector2.js';
6
6
  import '../vector/vector3.js';
7
7
  import '../vector/vector4.js';
@@ -9,20 +9,86 @@ import '../vector/vector4.js';
9
9
  declare const LinearCurve2dTypeId: unique symbol;
10
10
  type LinearCurve2dTypeId = typeof LinearCurve2dTypeId;
11
11
 
12
+ /**
13
+ * A linear curve in 2D space.
14
+ *
15
+ * All fields are readonly and immutable, and all operations create new instances.
16
+ *
17
+ * @since 1.0.0
18
+ */
12
19
  interface LinearCurve2d extends Pipeable, TwoDimensional<LinearPolynomial> {
13
20
  readonly [LinearCurve2dTypeId]: LinearCurve2dTypeId;
14
21
  }
22
+ /**
23
+ * Creates a new `LinearCurve2d` instance from polynomial parameters.
24
+ *
25
+ * @param x - The x polynomial.
26
+ * @param y - The y polynomial.
27
+ * @returns A new `LinearCurve2d` instance.
28
+ * @since 1.0.0
29
+ */
15
30
  declare const fromPolynomials: (x: LinearPolynomial, y: LinearPolynomial) => LinearCurve2d;
31
+ /**
32
+ * Creates a new `LinearCurve2d` instance from pairs of coefficients.
33
+ *
34
+ * @param p0 - The x^0 coefficients for the x and y polynomials.
35
+ * @param p1 - The x^1 coefficients for the x and y polynomials.
36
+ */
16
37
  declare const fromPoints: (p0: Vector2, p1: Vector2) => LinearCurve2d;
38
+ /**
39
+ * Checks if a value is a `LinearCurve2d`.
40
+ *
41
+ * @param c - The value to check.
42
+ * @returns `true` if the value is a `LinearCurve2d`, `false` otherwise.
43
+ * @since 1.0.0
44
+ */
17
45
  declare const isLinearCurve2d: (c: unknown) => c is LinearCurve2d;
46
+ /**
47
+ * Gets the derivative of a linear curve as a vector
48
+ *
49
+ * @param c - The linear curve to get the derivative of.
50
+ * @returns The derivative of the linear curve as a vector.
51
+ * @since 1.0.0
52
+ */
18
53
  declare const derivative: (c: LinearCurve2d) => Vector2;
19
54
  declare const solve: {
55
+ /**
56
+ * Solves the linear curve for a given parameter t.
57
+ *
58
+ * @param t - The parameter value.
59
+ * @returns A function that takes a linear curve and returns the point on the curve at parameter t.
60
+ * @since 1.0.0
61
+ */
20
62
  (t: number): (c: LinearCurve2d) => Vector2;
63
+ /**
64
+ * Solves the linear curve for a given parameter t.
65
+ *
66
+ * @param c - The linear curve to solve.
67
+ * @param t - The parameter value.
68
+ * @returns The point on the curve at parameter t.
69
+ * @since 1.0.0
70
+ */
21
71
  (c: LinearCurve2d, t: number): Vector2;
22
72
  };
23
73
  declare const length: {
74
+ /**
75
+ * Calculates (approximates) the length of a linear curve.
76
+ *
77
+ * @param c - The linear curve to calculate the length of.
78
+ * @param i - The interval to calculate the length over.
79
+ * @returns The length of the linear curve over the given interval.
80
+ * @since 1.0.0
81
+ */
24
82
  (c: LinearCurve2d, i: Interval): number;
83
+ /**
84
+ * Calculates (approximates) the length of a linear curve.
85
+ *
86
+ * @param i - The interval to calculate the length over.
87
+ * @returns A function that takes a linear curve and returns the length of the linear curve over the given interval.
88
+ * @since 1.0.0
89
+ */
25
90
  (i: Interval): (c: LinearCurve2d) => number;
26
91
  };
27
92
 
28
- export { type LinearCurve2d, derivative, fromPoints, fromPolynomials, isLinearCurve2d, length, solve };
93
+ export { derivative, fromPoints, fromPolynomials, isLinearCurve2d, length, solve };
94
+ export type { LinearCurve2d };
@@ -1,18 +1,17 @@
1
1
  import { dual, Pipeable } from '../pipe.mjs';
2
- import { make, solve as solve$2 } from '../polynomial/linear.mjs';
2
+ import { make as make$1, solve as solve$2 } from '../polynomial/linear.mjs';
3
3
  import { round } from '../utils.mjs';
4
- import { make as make$1 } from '../vector/vector2.mjs';
5
- import '../shared/curvy.BDhiZ7He.mjs';
4
+ import { make } from '../vector/vector2.mjs';
5
+ import '../shared/curvy.r6f1j287.mjs';
6
6
  import '../interval.mjs';
7
- import '../shared/curvy.BZ_mTkJe.mjs';
7
+ import '../shared/curvy.DJ4xO0al.mjs';
8
8
 
9
+ var _a, _b;
9
10
  const LinearCurve2dTypeId = Symbol("curvy/curve/linear2d");
10
- class LinearCurve2dImpl extends Pipeable {
11
- [LinearCurve2dTypeId] = LinearCurve2dTypeId;
12
- x;
13
- y;
11
+ class LinearCurve2dImpl extends (_b = Pipeable, _a = LinearCurve2dTypeId, _b) {
14
12
  constructor(c0, c1) {
15
13
  super();
14
+ this[_a] = LinearCurve2dTypeId;
16
15
  this.x = c0;
17
16
  this.y = c1;
18
17
  }
@@ -24,15 +23,12 @@ class LinearCurve2dImpl extends Pipeable {
24
23
  }
25
24
  }
26
25
  const fromPolynomials$1 = (c0, c1) => new LinearCurve2dImpl(c0, c1);
27
- const fromPoints$1 = (p0, p1) => new LinearCurve2dImpl(
28
- make(p0.x, p1.x),
29
- make(p0.y, p1.y)
30
- );
26
+ const fromPoints$1 = (p0, p1) => new LinearCurve2dImpl(make$1(p0.x, p1.x), make$1(p0.y, p1.y));
31
27
  const isLinearCurve2d$1 = (c) => typeof c === "object" && c !== null && LinearCurve2dTypeId in c;
32
- const derivative$1 = (c) => make$1(c.x.c1, c.y.c1);
28
+ const derivative$1 = (c) => make(c.x.c1, c.y.c1);
33
29
  const solve$1 = dual(
34
30
  2,
35
- (c, t) => make$1(solve$2(c.x, t), solve$2(c.y, t))
31
+ (c, t) => make(solve$2(c.x, t), solve$2(c.y, t))
36
32
  );
37
33
  const length$1 = dual(
38
34
  2,
@@ -47,3 +43,4 @@ const solve = solve$1;
47
43
  const length = length$1;
48
44
 
49
45
  export { derivative, fromPoints, fromPolynomials, isLinearCurve2d, length, solve };
46
+ //# sourceMappingURL=linear2d.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"linear2d.mjs","sources":["../../src/curve/linear2d.internal.ts","../../src/curve/linear2d.ts"],"sourcesContent":["import type { Interval } from '../interval'\nimport { Pipeable } from '../pipe'\nimport { dual } from '../pipe'\nimport * as LinearPolynomial from '../polynomial/linear'\nimport { round } from '../utils'\nimport * as Vector2 from '../vector/vector2'\nimport type { LinearCurve2d } from './linear2d'\n\nexport const LinearCurve2dTypeId: unique symbol = Symbol('curvy/curve/linear2d')\nexport type LinearCurve2dTypeId = typeof LinearCurve2dTypeId\n\nexport class LinearCurve2dImpl extends Pipeable implements LinearCurve2d {\n readonly [LinearCurve2dTypeId]: LinearCurve2dTypeId = LinearCurve2dTypeId\n\n readonly x: LinearPolynomial.LinearPolynomial\n readonly y: LinearPolynomial.LinearPolynomial\n\n constructor(c0: LinearPolynomial.LinearPolynomial, c1: LinearPolynomial.LinearPolynomial) {\n super()\n this.x = c0\n this.y = c1\n }\n\n get [0]() {\n return this.x\n }\n\n get [1]() {\n return this.y\n }\n}\n\nexport const fromPolynomials: (\n c0: LinearPolynomial.LinearPolynomial,\n c1: LinearPolynomial.LinearPolynomial,\n) => LinearCurve2d = (c0, c1) => new LinearCurve2dImpl(c0, c1)\n\nexport const fromPoints: (p0: Vector2.Vector2, p1: Vector2.Vector2) => LinearCurve2d = (p0, p1) =>\n new LinearCurve2dImpl(LinearPolynomial.make(p0.x, p1.x), LinearPolynomial.make(p0.y, p1.y))\n\nexport const isLinearCurve2d = (c: unknown): c is LinearCurve2d =>\n typeof c === 'object' && c !== null && LinearCurve2dTypeId in c\n\nexport const derivative = (c: LinearCurve2d) => Vector2.make(c.x.c1, c.y.c1)\n\nexport const solve = dual<\n (t: number) => (c: LinearCurve2d) => Vector2.Vector2,\n (c: LinearCurve2d, t: number) => Vector2.Vector2\n>(2, (c: LinearCurve2d, t: number) =>\n Vector2.make(LinearPolynomial.solve(c.x, t), LinearPolynomial.solve(c.y, t)),\n)\n\nexport const length = dual(2, (c: LinearCurve2d, i: Interval) =>\n round(Math.sqrt(c.x.c1 ** 2 + c.y.c1 ** 2) * Math.abs(i.end - i.start)),\n)\n","import type { TwoDimensional } from '../dimensions'\nimport type { Interval } from '../interval'\nimport type { Pipeable } from '../pipe'\nimport type { LinearPolynomial } from '../polynomial/linear'\nimport type { Vector2 } from '../vector/vector2'\nimport type { LinearCurve2dTypeId } from './linear2d.internal'\nimport * as internal from './linear2d.internal'\n\n/**\n * A linear curve in 2D space.\n *\n * All fields are readonly and immutable, and all operations create new instances.\n *\n * @since 1.0.0\n */\nexport interface LinearCurve2d extends Pipeable, TwoDimensional<LinearPolynomial> {\n readonly [LinearCurve2dTypeId]: LinearCurve2dTypeId\n}\n\n/**\n * Creates a new `LinearCurve2d` instance from polynomial parameters.\n *\n * @param x - The x polynomial.\n * @param y - The y polynomial.\n * @returns A new `LinearCurve2d` instance.\n * @since 1.0.0\n */\nexport const fromPolynomials: (x: LinearPolynomial, y: LinearPolynomial) => LinearCurve2d =\n internal.fromPolynomials\n\n/**\n * Creates a new `LinearCurve2d` instance from pairs of coefficients.\n *\n * @param p0 - The x^0 coefficients for the x and y polynomials.\n * @param p1 - The x^1 coefficients for the x and y polynomials.\n */\nexport const fromPoints: (p0: Vector2, p1: Vector2) => LinearCurve2d = internal.fromPoints\n\n/**\n * Checks if a value is a `LinearCurve2d`.\n *\n * @param c - The value to check.\n * @returns `true` if the value is a `LinearCurve2d`, `false` otherwise.\n * @since 1.0.0\n */\nexport const isLinearCurve2d: (c: unknown) => c is LinearCurve2d = internal.isLinearCurve2d\n\n/**\n * Gets the derivative of a linear curve as a vector\n *\n * @param c - The linear curve to get the derivative of.\n * @returns The derivative of the linear curve as a vector.\n * @since 1.0.0\n */\nexport const derivative: (c: LinearCurve2d) => Vector2 = internal.derivative\n\nexport const solve: {\n /**\n * Solves the linear curve for a given parameter t.\n *\n * @param t - The parameter value.\n * @returns A function that takes a linear curve and returns the point on the curve at parameter t.\n * @since 1.0.0\n */\n (t: number): (c: LinearCurve2d) => Vector2\n /**\n * Solves the linear curve for a given parameter t.\n *\n * @param c - The linear curve to solve.\n * @param t - The parameter value.\n * @returns The point on the curve at parameter t.\n * @since 1.0.0\n */\n (c: LinearCurve2d, t: number): Vector2\n} = internal.solve\n\nexport const length: {\n /**\n * Calculates (approximates) the length of a linear curve.\n *\n * @param c - The linear curve to calculate the length of.\n * @param i - The interval to calculate the length over.\n * @returns The length of the linear curve over the given interval.\n * @since 1.0.0\n */\n (c: LinearCurve2d, i: Interval): number\n /**\n * Calculates (approximates) the length of a linear curve.\n *\n * @param i - The interval to calculate the length over.\n * @returns A function that takes a linear curve and returns the length of the linear curve over the given interval.\n * @since 1.0.0\n */\n (i: Interval): (c: LinearCurve2d) => number\n} = internal.length\n"],"names":["fromPolynomials","fromPoints","LinearPolynomial.make","isLinearCurve2d","derivative","Vector2.make","solve","LinearPolynomial.sol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