curvy 0.3.1 → 0.3.2

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/axis.cjs CHANGED
@@ -27,7 +27,7 @@ function createLinearPolynomial(coefficients, domain = UNIT_INTERVAL) {
27
27
  return {
28
28
  domain,
29
29
  range,
30
- monotonocity: a === 0 ? "constant" : a > 0 ? "increasing" : "decreasing",
30
+ monotonicity: a === 0 ? "constant" : a > 0 ? "increasing" : "decreasing",
31
31
  coefficients,
32
32
  root,
33
33
  solve,
@@ -98,7 +98,7 @@ function createQuadraticPolynomial(coefficients, domain = UNIT_INTERVAL) {
98
98
  domain,
99
99
  range,
100
100
  coefficients,
101
- monotonocity: a !== 0 ? "none" : b === 0 ? "constant" : b > 0 ? "increasing" : "decreasing",
101
+ monotonicity: a !== 0 ? "none" : b === 0 ? "constant" : b > 0 ? "increasing" : "decreasing",
102
102
  extreme,
103
103
  roots,
104
104
  derivative,
@@ -188,11 +188,11 @@ function createCubicPolynomial(coefficients, domain = UNIT_INTERVAL) {
188
188
  ];
189
189
  const solveInverse = createCubicRootSolver(coefficients, domain, range);
190
190
  const roots = range[0] > 0 || range[1] < 0 ? [] : solveInverse(0, domain);
191
- const monotonocity = getMonotonicity(extrema, derivative, domain);
191
+ const monotonicity = getMonotonicity(extrema, derivative, domain);
192
192
  return {
193
193
  domain,
194
194
  range,
195
- monotonocity,
195
+ monotonicity,
196
196
  coefficients,
197
197
  extrema,
198
198
  roots,
@@ -237,8 +237,8 @@ function createCurveAxis(coefficients) {
237
237
  );
238
238
  }
239
239
  if (i === 0) {
240
- monotonicity = segment.monotonocity;
241
- } else if (monotonicity !== segment.monotonocity) {
240
+ monotonicity = segment.monotonicity;
241
+ } else if (monotonicity !== segment.monotonicity) {
242
242
  monotonicity = "none";
243
243
  }
244
244
  }
package/dist/axis.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { I as Interval, M as Monotonicity, C as CubicPolynomial, a as CubicCoefficients } from './shared/curvy.0f1371d7.cjs';
1
+ import { I as Interval, M as Monotonicity, C as CubicPolynomial, a as CubicCoefficients } from './shared/curvy.df73166c.cjs';
2
2
 
3
3
  type CurveAxis = {
4
4
  readonly domain: Interval;
package/dist/axis.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { I as Interval, M as Monotonicity, C as CubicPolynomial, a as CubicCoefficients } from './shared/curvy.0f1371d7.mjs';
1
+ import { I as Interval, M as Monotonicity, C as CubicPolynomial, a as CubicCoefficients } from './shared/curvy.df73166c.mjs';
2
2
 
3
3
  type CurveAxis = {
4
4
  readonly domain: Interval;
package/dist/axis.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { I as Interval, M as Monotonicity, C as CubicPolynomial, a as CubicCoefficients } from './shared/curvy.0f1371d7.js';
1
+ import { I as Interval, M as Monotonicity, C as CubicPolynomial, a as CubicCoefficients } from './shared/curvy.df73166c.js';
2
2
 
3
3
  type CurveAxis = {
4
4
  readonly domain: Interval;
package/dist/axis.mjs CHANGED
@@ -21,7 +21,7 @@ function createLinearPolynomial(coefficients, domain = UNIT_INTERVAL) {
21
21
  return {
22
22
  domain,
23
23
  range,
24
- monotonocity: a === 0 ? "constant" : a > 0 ? "increasing" : "decreasing",
24
+ monotonicity: a === 0 ? "constant" : a > 0 ? "increasing" : "decreasing",
25
25
  coefficients,
26
26
  root,
27
27
  solve,
@@ -92,7 +92,7 @@ function createQuadraticPolynomial(coefficients, domain = UNIT_INTERVAL) {
92
92
  domain,
93
93
  range,
94
94
  coefficients,
95
- monotonocity: a !== 0 ? "none" : b === 0 ? "constant" : b > 0 ? "increasing" : "decreasing",
95
+ monotonicity: a !== 0 ? "none" : b === 0 ? "constant" : b > 0 ? "increasing" : "decreasing",
96
96
  extreme,
97
97
  roots,
98
98
  derivative,
@@ -182,11 +182,11 @@ function createCubicPolynomial(coefficients, domain = UNIT_INTERVAL) {
182
182
  ];
183
183
  const solveInverse = createCubicRootSolver(coefficients, domain, range);
184
184
  const roots = range[0] > 0 || range[1] < 0 ? [] : solveInverse(0, domain);
185
- const monotonocity = getMonotonicity(extrema, derivative, domain);
185
+ const monotonicity = getMonotonicity(extrema, derivative, domain);
186
186
  return {
187
187
  domain,
188
188
  range,
189
- monotonocity,
189
+ monotonicity,
190
190
  coefficients,
191
191
  extrema,
192
192
  roots,
@@ -231,8 +231,8 @@ function createCurveAxis(coefficients) {
231
231
  );
232
232
  }
233
233
  if (i === 0) {
234
- monotonicity = segment.monotonocity;
235
- } else if (monotonicity !== segment.monotonocity) {
234
+ monotonicity = segment.monotonicity;
235
+ } else if (monotonicity !== segment.monotonicity) {
236
236
  monotonicity = "none";
237
237
  }
238
238
  }
@@ -1,4 +1,4 @@
1
- import { a as CubicCoefficients } from './shared/curvy.0f1371d7.cjs';
1
+ import { a as CubicCoefficients } from './shared/curvy.df73166c.cjs';
2
2
  import { Matrix4x4 } from './splines.cjs';
3
3
 
4
4
  declare function convertScalars(points: CubicCoefficients, sourceSpline: Matrix4x4, targetSpline: Matrix4x4): CubicCoefficients;
@@ -1,4 +1,4 @@
1
- import { a as CubicCoefficients } from './shared/curvy.0f1371d7.mjs';
1
+ import { a as CubicCoefficients } from './shared/curvy.df73166c.mjs';
2
2
  import { Matrix4x4 } from './splines.mjs';
3
3
 
4
4
  declare function convertScalars(points: CubicCoefficients, sourceSpline: Matrix4x4, targetSpline: Matrix4x4): CubicCoefficients;
package/dist/convert.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as CubicCoefficients } from './shared/curvy.0f1371d7.js';
1
+ import { a as CubicCoefficients } from './shared/curvy.df73166c.js';
2
2
  import { Matrix4x4 } from './splines.js';
3
3
 
4
4
  declare function convertScalars(points: CubicCoefficients, sourceSpline: Matrix4x4, targetSpline: Matrix4x4): CubicCoefficients;
package/dist/curve.cjs CHANGED
@@ -68,8 +68,10 @@ function createIntervalTree(boundaries) {
68
68
  }
69
69
 
70
70
  function distance(a, b) {
71
- const keys = Object.keys(a);
72
- const deltas = keys.map((key) => a[key] - b[key]);
71
+ const deltas = [];
72
+ for (const key of Object.keys(a)) {
73
+ deltas.push(a[key] - b[key]);
74
+ }
73
75
  return Math.hypot(...deltas);
74
76
  }
75
77
  function createLengthLookup(positionAt) {
package/dist/curve.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { CurveAxis } from './axis.cjs';
2
- import './shared/curvy.0f1371d7.cjs';
2
+ import './shared/curvy.df73166c.cjs';
3
3
 
4
4
  type Point<Axis extends string | number> = Readonly<{
5
5
  [A in Axis]: number;
@@ -7,7 +7,7 @@ type Point<Axis extends string | number> = Readonly<{
7
7
  type Curve<Axis extends string | number> = {
8
8
  readonly axes: Readonly<Record<Axis, CurveAxis>>;
9
9
  readonly positionAt: (input: number, normalize?: number, precision?: number) => Point<Axis>;
10
- readonly solveWhere: <SolveAxis extends Axis>(axis: SolveAxis, position: number, precsiion?: number) => Point<Axis>;
10
+ readonly solveWhere: <SolveAxis extends Axis>(axis: SolveAxis, position: number, precision?: number) => Point<Axis>;
11
11
  };
12
12
  declare function createBasisCurve<Axis extends string | number>(points: ReadonlyArray<Point<Axis>>, triplicateEndpoints?: boolean): Curve<Axis>;
13
13
  declare function createBezierCurve<Axis extends string | number>(points: ReadonlyArray<Point<Axis>>): Curve<Axis>;
package/dist/curve.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { CurveAxis } from './axis.mjs';
2
- import './shared/curvy.0f1371d7.mjs';
2
+ import './shared/curvy.df73166c.mjs';
3
3
 
4
4
  type Point<Axis extends string | number> = Readonly<{
5
5
  [A in Axis]: number;
@@ -7,7 +7,7 @@ type Point<Axis extends string | number> = Readonly<{
7
7
  type Curve<Axis extends string | number> = {
8
8
  readonly axes: Readonly<Record<Axis, CurveAxis>>;
9
9
  readonly positionAt: (input: number, normalize?: number, precision?: number) => Point<Axis>;
10
- readonly solveWhere: <SolveAxis extends Axis>(axis: SolveAxis, position: number, precsiion?: number) => Point<Axis>;
10
+ readonly solveWhere: <SolveAxis extends Axis>(axis: SolveAxis, position: number, precision?: number) => Point<Axis>;
11
11
  };
12
12
  declare function createBasisCurve<Axis extends string | number>(points: ReadonlyArray<Point<Axis>>, triplicateEndpoints?: boolean): Curve<Axis>;
13
13
  declare function createBezierCurve<Axis extends string | number>(points: ReadonlyArray<Point<Axis>>): Curve<Axis>;
package/dist/curve.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { CurveAxis } from './axis.js';
2
- import './shared/curvy.0f1371d7.js';
2
+ import './shared/curvy.df73166c.js';
3
3
 
4
4
  type Point<Axis extends string | number> = Readonly<{
5
5
  [A in Axis]: number;
@@ -7,7 +7,7 @@ type Point<Axis extends string | number> = Readonly<{
7
7
  type Curve<Axis extends string | number> = {
8
8
  readonly axes: Readonly<Record<Axis, CurveAxis>>;
9
9
  readonly positionAt: (input: number, normalize?: number, precision?: number) => Point<Axis>;
10
- readonly solveWhere: <SolveAxis extends Axis>(axis: SolveAxis, position: number, precsiion?: number) => Point<Axis>;
10
+ readonly solveWhere: <SolveAxis extends Axis>(axis: SolveAxis, position: number, precision?: number) => Point<Axis>;
11
11
  };
12
12
  declare function createBasisCurve<Axis extends string | number>(points: ReadonlyArray<Point<Axis>>, triplicateEndpoints?: boolean): Curve<Axis>;
13
13
  declare function createBezierCurve<Axis extends string | number>(points: ReadonlyArray<Point<Axis>>): Curve<Axis>;
package/dist/curve.mjs CHANGED
@@ -62,8 +62,10 @@ function createIntervalTree(boundaries) {
62
62
  }
63
63
 
64
64
  function distance(a, b) {
65
- const keys = Object.keys(a);
66
- const deltas = keys.map((key) => a[key] - b[key]);
65
+ const deltas = [];
66
+ for (const key of Object.keys(a)) {
67
+ deltas.push(a[key] - b[key]);
68
+ }
67
69
  return Math.hypot(...deltas);
68
70
  }
69
71
  function createLengthLookup(positionAt) {
@@ -4,7 +4,7 @@ type LinearCoefficients = readonly [number, number];
4
4
  type LinearPolynomial = {
5
5
  readonly domain: Interval;
6
6
  readonly range: Interval;
7
- readonly monotonocity: Monotonicity;
7
+ readonly monotonicity: Monotonicity;
8
8
  readonly coefficients: LinearCoefficients;
9
9
  readonly root: number | null;
10
10
  readonly solve: (x: number) => number;
@@ -14,7 +14,7 @@ type QuadraticCoefficients = readonly [number, number, number];
14
14
  type QuadraticPolynomial = {
15
15
  readonly domain: Interval;
16
16
  readonly range: Interval;
17
- readonly monotonocity: Monotonicity;
17
+ readonly monotonicity: Monotonicity;
18
18
  readonly coefficients: QuadraticCoefficients;
19
19
  readonly extreme: number | null;
20
20
  readonly roots: ReadonlyArray<number>;
@@ -26,7 +26,7 @@ type CubicCoefficients = readonly [number, number, number, number];
26
26
  type CubicPolynomial = {
27
27
  readonly domain: Interval;
28
28
  readonly range: Interval;
29
- readonly monotonocity: Monotonicity;
29
+ readonly monotonicity: Monotonicity;
30
30
  readonly coefficients: CubicCoefficients;
31
31
  readonly extrema: ReadonlyArray<number>;
32
32
  readonly roots: ReadonlyArray<number>;
@@ -4,7 +4,7 @@ type LinearCoefficients = readonly [number, number];
4
4
  type LinearPolynomial = {
5
5
  readonly domain: Interval;
6
6
  readonly range: Interval;
7
- readonly monotonocity: Monotonicity;
7
+ readonly monotonicity: Monotonicity;
8
8
  readonly coefficients: LinearCoefficients;
9
9
  readonly root: number | null;
10
10
  readonly solve: (x: number) => number;
@@ -14,7 +14,7 @@ type QuadraticCoefficients = readonly [number, number, number];
14
14
  type QuadraticPolynomial = {
15
15
  readonly domain: Interval;
16
16
  readonly range: Interval;
17
- readonly monotonocity: Monotonicity;
17
+ readonly monotonicity: Monotonicity;
18
18
  readonly coefficients: QuadraticCoefficients;
19
19
  readonly extreme: number | null;
20
20
  readonly roots: ReadonlyArray<number>;
@@ -26,7 +26,7 @@ type CubicCoefficients = readonly [number, number, number, number];
26
26
  type CubicPolynomial = {
27
27
  readonly domain: Interval;
28
28
  readonly range: Interval;
29
- readonly monotonocity: Monotonicity;
29
+ readonly monotonicity: Monotonicity;
30
30
  readonly coefficients: CubicCoefficients;
31
31
  readonly extrema: ReadonlyArray<number>;
32
32
  readonly roots: ReadonlyArray<number>;
@@ -4,7 +4,7 @@ type LinearCoefficients = readonly [number, number];
4
4
  type LinearPolynomial = {
5
5
  readonly domain: Interval;
6
6
  readonly range: Interval;
7
- readonly monotonocity: Monotonicity;
7
+ readonly monotonicity: Monotonicity;
8
8
  readonly coefficients: LinearCoefficients;
9
9
  readonly root: number | null;
10
10
  readonly solve: (x: number) => number;
@@ -14,7 +14,7 @@ type QuadraticCoefficients = readonly [number, number, number];
14
14
  type QuadraticPolynomial = {
15
15
  readonly domain: Interval;
16
16
  readonly range: Interval;
17
- readonly monotonocity: Monotonicity;
17
+ readonly monotonicity: Monotonicity;
18
18
  readonly coefficients: QuadraticCoefficients;
19
19
  readonly extreme: number | null;
20
20
  readonly roots: ReadonlyArray<number>;
@@ -26,7 +26,7 @@ type CubicCoefficients = readonly [number, number, number, number];
26
26
  type CubicPolynomial = {
27
27
  readonly domain: Interval;
28
28
  readonly range: Interval;
29
- readonly monotonocity: Monotonicity;
29
+ readonly monotonicity: Monotonicity;
30
30
  readonly coefficients: CubicCoefficients;
31
31
  readonly extrema: ReadonlyArray<number>;
32
32
  readonly roots: ReadonlyArray<number>;
@@ -1,4 +1,4 @@
1
- import { a as CubicCoefficients } from './shared/curvy.0f1371d7.cjs';
1
+ import { a as CubicCoefficients } from './shared/curvy.df73166c.cjs';
2
2
 
3
3
  type Matrix4x4 = readonly [
4
4
  CubicCoefficients,
@@ -1,4 +1,4 @@
1
- import { a as CubicCoefficients } from './shared/curvy.0f1371d7.mjs';
1
+ import { a as CubicCoefficients } from './shared/curvy.df73166c.mjs';
2
2
 
3
3
  type Matrix4x4 = readonly [
4
4
  CubicCoefficients,
package/dist/splines.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as CubicCoefficients } from './shared/curvy.0f1371d7.js';
1
+ import { a as CubicCoefficients } from './shared/curvy.df73166c.js';
2
2
 
3
3
  type Matrix4x4 = readonly [
4
4
  CubicCoefficients,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "curvy",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "Spline and Curve utilities",
5
5
  "author": "Tim Morris <timthewebguy@gmail.com>",
6
6
  "homepage": "https://github.com/tkofh/curvy#readme",