@thi.ng/math 5.3.7 → 5.3.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.
- package/CHANGELOG.md +1 -1
- package/README.md +4 -3
- package/fit.d.ts +43 -0
- package/fit.js +43 -0
- package/mix.d.ts +17 -0
- package/mix.js +17 -0
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<!-- This file is generated - DO NOT EDIT! -->
|
|
2
2
|
|
|
3
|
-
# 
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@thi.ng/math)
|
|
6
6
|

|
|
@@ -12,7 +12,7 @@ This project is part of the
|
|
|
12
12
|
For the Clojure version, please visit: [thi.ng/math-clj](https://thi.ng/math-clj)
|
|
13
13
|
|
|
14
14
|
- [About](#about)
|
|
15
|
-
|
|
15
|
+
- [Status](#status)
|
|
16
16
|
- [Breaking changes in v4.0.0](#breaking-changes-in-v400)
|
|
17
17
|
- [Installation](#installation)
|
|
18
18
|
- [Dependencies](#dependencies)
|
|
@@ -32,7 +32,7 @@ Partially ported from Clojure version
|
|
|
32
32
|
[c.thi.ng](https://github.com/thi-ng/c-thing) and
|
|
33
33
|
[thi.ng/vexed-generation](https://github.com/thi-ng/vexed-generation).
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
## Status
|
|
36
36
|
|
|
37
37
|
**STABLE** - used in production
|
|
38
38
|
|
|
@@ -95,6 +95,7 @@ A selection:
|
|
|
95
95
|
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/scenegraph.png" width="240"/> | 2D scenegraph & shape picking | [Demo](https://demo.thi.ng/umbrella/scenegraph/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/scenegraph) |
|
|
96
96
|
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/scenegraph-image.png" width="240"/> | 2D scenegraph & image map based geometry manipulation | [Demo](https://demo.thi.ng/umbrella/scenegraph-image/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/scenegraph-image) |
|
|
97
97
|
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/svg-barchart.png" width="240"/> | Simplistic SVG bar chart component | [Demo](https://demo.thi.ng/umbrella/svg-barchart/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/svg-barchart) |
|
|
98
|
+
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/svg-resample.png" width="240"/> | SVG path parsing & dynamic resampling | [Demo](https://demo.thi.ng/umbrella/svg-resample/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/svg-resample) |
|
|
98
99
|
|
|
99
100
|
## API
|
|
100
101
|
|
package/fit.d.ts
CHANGED
|
@@ -8,9 +8,52 @@ import type { FnN3, FnN5 } from "@thi.ng/api";
|
|
|
8
8
|
* @param b -
|
|
9
9
|
*/
|
|
10
10
|
export declare const norm: FnN3;
|
|
11
|
+
/**
|
|
12
|
+
* Returns a number in the `[c,d]` interval which is relative to `x` in the
|
|
13
|
+
* `[a,b]` interval. **No** clamping will be performed if `x` lies outside the
|
|
14
|
+
* original range (for that use {@link fitClamped} instead).
|
|
15
|
+
*
|
|
16
|
+
* @param x
|
|
17
|
+
* @param a
|
|
18
|
+
* @param b
|
|
19
|
+
* @param c
|
|
20
|
+
* @param d
|
|
21
|
+
*/
|
|
11
22
|
export declare const fit: FnN5;
|
|
23
|
+
/**
|
|
24
|
+
* Clamped version of {@link fit}, i.e. before mapping `x` into the target
|
|
25
|
+
* interval `[c,d]`, it will be clamped to the source interval `[a,b]`.
|
|
26
|
+
*
|
|
27
|
+
* @param x
|
|
28
|
+
* @param a
|
|
29
|
+
* @param b
|
|
30
|
+
* @param c
|
|
31
|
+
* @param d
|
|
32
|
+
*/
|
|
12
33
|
export declare const fitClamped: FnN5;
|
|
34
|
+
/**
|
|
35
|
+
* Similar to {@link fitClamped}, assuming [0,1] as source interval.
|
|
36
|
+
*
|
|
37
|
+
* @param x
|
|
38
|
+
* @param a
|
|
39
|
+
* @param b
|
|
40
|
+
*/
|
|
13
41
|
export declare const fit01: FnN3;
|
|
42
|
+
/**
|
|
43
|
+
* Similar to {@link fitClamped}, assuming the reverse ordered [1,0] as source
|
|
44
|
+
* interval.
|
|
45
|
+
*
|
|
46
|
+
* @param x
|
|
47
|
+
* @param a
|
|
48
|
+
* @param b
|
|
49
|
+
*/
|
|
14
50
|
export declare const fit10: FnN3;
|
|
51
|
+
/**
|
|
52
|
+
* Similar to {@link fitClamped}, assuming [-1,1] as source interval.
|
|
53
|
+
*
|
|
54
|
+
* @param x
|
|
55
|
+
* @param a
|
|
56
|
+
* @param b
|
|
57
|
+
*/
|
|
15
58
|
export declare const fit11: FnN3;
|
|
16
59
|
//# sourceMappingURL=fit.d.ts.map
|
package/fit.js
CHANGED
|
@@ -8,8 +8,51 @@ import { clamp01, clamp11 } from "./interval.js";
|
|
|
8
8
|
* @param b -
|
|
9
9
|
*/
|
|
10
10
|
export const norm = (x, a, b) => (b !== a ? (x - a) / (b - a) : 0);
|
|
11
|
+
/**
|
|
12
|
+
* Returns a number in the `[c,d]` interval which is relative to `x` in the
|
|
13
|
+
* `[a,b]` interval. **No** clamping will be performed if `x` lies outside the
|
|
14
|
+
* original range (for that use {@link fitClamped} instead).
|
|
15
|
+
*
|
|
16
|
+
* @param x
|
|
17
|
+
* @param a
|
|
18
|
+
* @param b
|
|
19
|
+
* @param c
|
|
20
|
+
* @param d
|
|
21
|
+
*/
|
|
11
22
|
export const fit = (x, a, b, c, d) => c + (d - c) * norm(x, a, b);
|
|
23
|
+
/**
|
|
24
|
+
* Clamped version of {@link fit}, i.e. before mapping `x` into the target
|
|
25
|
+
* interval `[c,d]`, it will be clamped to the source interval `[a,b]`.
|
|
26
|
+
*
|
|
27
|
+
* @param x
|
|
28
|
+
* @param a
|
|
29
|
+
* @param b
|
|
30
|
+
* @param c
|
|
31
|
+
* @param d
|
|
32
|
+
*/
|
|
12
33
|
export const fitClamped = (x, a, b, c, d) => c + (d - c) * clamp01(norm(x, a, b));
|
|
34
|
+
/**
|
|
35
|
+
* Similar to {@link fitClamped}, assuming [0,1] as source interval.
|
|
36
|
+
*
|
|
37
|
+
* @param x
|
|
38
|
+
* @param a
|
|
39
|
+
* @param b
|
|
40
|
+
*/
|
|
13
41
|
export const fit01 = (x, a, b) => a + (b - a) * clamp01(x);
|
|
42
|
+
/**
|
|
43
|
+
* Similar to {@link fitClamped}, assuming the reverse ordered [1,0] as source
|
|
44
|
+
* interval.
|
|
45
|
+
*
|
|
46
|
+
* @param x
|
|
47
|
+
* @param a
|
|
48
|
+
* @param b
|
|
49
|
+
*/
|
|
14
50
|
export const fit10 = (x, a, b) => b + (a - b) * clamp01(x);
|
|
51
|
+
/**
|
|
52
|
+
* Similar to {@link fitClamped}, assuming [-1,1] as source interval.
|
|
53
|
+
*
|
|
54
|
+
* @param x
|
|
55
|
+
* @param a
|
|
56
|
+
* @param b
|
|
57
|
+
*/
|
|
15
58
|
export const fit11 = (x, a, b) => a + (b - a) * (0.5 + 0.5 * clamp11(x));
|
package/mix.d.ts
CHANGED
|
@@ -27,7 +27,24 @@ export declare const mix: FnN3;
|
|
|
27
27
|
* @param v - 2nd interpolation factor
|
|
28
28
|
*/
|
|
29
29
|
export declare const mixBilinear: FnN6;
|
|
30
|
+
/**
|
|
31
|
+
* Computes quadratic bezier interpolation for normalized value `t`.
|
|
32
|
+
*
|
|
33
|
+
* @param a
|
|
34
|
+
* @param b
|
|
35
|
+
* @param c
|
|
36
|
+
* @param t
|
|
37
|
+
*/
|
|
30
38
|
export declare const mixQuadratic: FnN4;
|
|
39
|
+
/**
|
|
40
|
+
* Computes cubic bezier interpolation for normalized value `t`.
|
|
41
|
+
*
|
|
42
|
+
* @param a
|
|
43
|
+
* @param b
|
|
44
|
+
* @param c
|
|
45
|
+
* @param d
|
|
46
|
+
* @param t
|
|
47
|
+
*/
|
|
31
48
|
export declare const mixCubic: FnN5;
|
|
32
49
|
/**
|
|
33
50
|
* Returns hermite interpolation of `a, b, c, d` at normalized position
|
package/mix.js
CHANGED
|
@@ -31,10 +31,27 @@ export const mixBilinear = (a, b, c, d, u, v) => {
|
|
|
31
31
|
const iv = 1 - v;
|
|
32
32
|
return a * iu * iv + b * u * iv + c * iu * v + d * u * v;
|
|
33
33
|
};
|
|
34
|
+
/**
|
|
35
|
+
* Computes quadratic bezier interpolation for normalized value `t`.
|
|
36
|
+
*
|
|
37
|
+
* @param a
|
|
38
|
+
* @param b
|
|
39
|
+
* @param c
|
|
40
|
+
* @param t
|
|
41
|
+
*/
|
|
34
42
|
export const mixQuadratic = (a, b, c, t) => {
|
|
35
43
|
const s = 1 - t;
|
|
36
44
|
return a * s * s + b * 2 * s * t + c * t * t;
|
|
37
45
|
};
|
|
46
|
+
/**
|
|
47
|
+
* Computes cubic bezier interpolation for normalized value `t`.
|
|
48
|
+
*
|
|
49
|
+
* @param a
|
|
50
|
+
* @param b
|
|
51
|
+
* @param c
|
|
52
|
+
* @param d
|
|
53
|
+
* @param t
|
|
54
|
+
*/
|
|
38
55
|
export const mixCubic = (a, b, c, d, t) => {
|
|
39
56
|
const t2 = t * t;
|
|
40
57
|
const s = 1 - t;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/math",
|
|
3
|
-
"version": "5.3.
|
|
3
|
+
"version": "5.3.9",
|
|
4
4
|
"description": "Assorted common math functions & utilities",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -34,15 +34,15 @@
|
|
|
34
34
|
"test": "testament test"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@thi.ng/api": "^8.4.
|
|
37
|
+
"@thi.ng/api": "^8.4.2"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@microsoft/api-extractor": "^7.
|
|
41
|
-
"@thi.ng/testament": "^0.
|
|
40
|
+
"@microsoft/api-extractor": "^7.31.1",
|
|
41
|
+
"@thi.ng/testament": "^0.3.0",
|
|
42
42
|
"rimraf": "^3.0.2",
|
|
43
43
|
"tools": "^0.0.1",
|
|
44
44
|
"typedoc": "^0.22.17",
|
|
45
|
-
"typescript": "^4.
|
|
45
|
+
"typescript": "^4.8.3"
|
|
46
46
|
},
|
|
47
47
|
"keywords": [
|
|
48
48
|
"animation",
|
|
@@ -132,5 +132,5 @@
|
|
|
132
132
|
"thi.ng": {
|
|
133
133
|
"year": 2013
|
|
134
134
|
},
|
|
135
|
-
"gitHead": "
|
|
135
|
+
"gitHead": "f4c59114f2d2dfafa9014626038a9ec5242b0606\n"
|
|
136
136
|
}
|