@thi.ng/math 5.4.11 → 5.5.1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2023-06-14T07:58:51Z
3
+ - **Last updated**: 2023-08-04T10:58:19Z
4
4
  - **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
5
5
 
6
6
  All notable changes to this project will be documented in this file.
@@ -9,6 +9,12 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
9
9
  **Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
10
10
  and/or version bumps of transitive dependencies.
11
11
 
12
+ ## [5.5.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/math@5.5.0) (2023-07-14)
13
+
14
+ #### 🚀 Features
15
+
16
+ - add smoothStep01/smootherStep01() ([152f93c](https://github.com/thi-ng/umbrella/commit/152f93c))
17
+
12
18
  ### [5.4.4](https://github.com/thi-ng/umbrella/tree/@thi.ng/math@5.4.4) (2023-03-02)
13
19
 
14
20
  #### ♻️ Refactoring
package/README.md CHANGED
@@ -66,7 +66,7 @@ For Node.js REPL:
66
66
  const math = await import("@thi.ng/math");
67
67
  ```
68
68
 
69
- Package sizes (brotli'd, pre-treeshake): ESM: 4.03 KB
69
+ Package sizes (brotli'd, pre-treeshake): ESM: 4.04 KB
70
70
 
71
71
  ## Dependencies
72
72
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/math",
3
- "version": "5.4.11",
3
+ "version": "5.5.1",
4
4
  "description": "Assorted common math functions & utilities",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -37,15 +37,15 @@
37
37
  "test": "testament test"
38
38
  },
39
39
  "dependencies": {
40
- "@thi.ng/api": "^8.8.2"
40
+ "@thi.ng/api": "^8.9.0"
41
41
  },
42
42
  "devDependencies": {
43
- "@microsoft/api-extractor": "^7.35.3",
44
- "@thi.ng/testament": "^0.3.17",
43
+ "@microsoft/api-extractor": "^7.36.3",
44
+ "@thi.ng/testament": "^0.3.18",
45
45
  "rimraf": "^5.0.1",
46
46
  "tools": "^0.0.1",
47
47
  "typedoc": "^0.24.8",
48
- "typescript": "^5.1.3"
48
+ "typescript": "^5.1.6"
49
49
  },
50
50
  "keywords": [
51
51
  "animation",
@@ -138,5 +138,5 @@
138
138
  "thi.ng": {
139
139
  "year": 2013
140
140
  },
141
- "gitHead": "54e825a976c72067a244cff8725ca98f5416d26d\n"
141
+ "gitHead": "9fa3f7f8169efa30e3c71b43c82f77393581c3b5\n"
142
142
  }
package/step.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { FnN2, FnN3 } from "@thi.ng/api";
1
+ import type { FnN, FnN2, FnN3 } from "@thi.ng/api";
2
2
  /**
3
3
  * Step/threshold function.
4
4
  *
@@ -10,20 +10,40 @@ export declare const step: FnN2;
10
10
  /**
11
11
  * GLSL-style smoothStep threshold function.
12
12
  *
13
+ * @remarks
14
+ * Also see {@link smoothStep01}, {@link smootherStep}.
15
+ *
13
16
  * @param edge - lower threshold
14
17
  * @param edge2 - upper threshold
15
18
  * @param x - test value
16
19
  * @returns 0, if `x < edge1`, 1 if `x > edge2`, else S-curve polynomial interpolation
17
20
  */
18
21
  export declare const smoothStep: FnN3;
22
+ /**
23
+ * Specialized version of {@link smoothStep}, assuming edges are 0/1
24
+ * respectively and `x` is in [0..1]. No clamping performed.
25
+ *
26
+ * @param x
27
+ */
28
+ export declare const smoothStep01: FnN;
19
29
  /**
20
30
  * Similar to {@link smoothStep} but using different, higher degree polynomial.
21
31
  *
32
+ * @remarks
33
+ * Also see {@link smootherStep01}.
34
+ *
22
35
  * @param edge -
23
36
  * @param edge2 -
24
37
  * @param x -
25
38
  */
26
39
  export declare const smootherStep: FnN3;
40
+ /**
41
+ * Specialized version of {@link smootherStep}, assuming edges are 0/1
42
+ * respectively and `x` is in [0..1]. No clamping performed.
43
+ *
44
+ * @param x
45
+ */
46
+ export declare const smootherStep01: FnN;
27
47
  /**
28
48
  * Exponential ramp with variable shape
29
49
  *
package/step.js CHANGED
@@ -10,26 +10,40 @@ export const step = (edge, x) => (x < edge ? 0 : 1);
10
10
  /**
11
11
  * GLSL-style smoothStep threshold function.
12
12
  *
13
+ * @remarks
14
+ * Also see {@link smoothStep01}, {@link smootherStep}.
15
+ *
13
16
  * @param edge - lower threshold
14
17
  * @param edge2 - upper threshold
15
18
  * @param x - test value
16
19
  * @returns 0, if `x < edge1`, 1 if `x > edge2`, else S-curve polynomial interpolation
17
20
  */
18
- export const smoothStep = (edge, edge2, x) => {
19
- x = clamp01((x - edge) / (edge2 - edge));
20
- return (3 - 2 * x) * x * x;
21
- };
21
+ export const smoothStep = (edge, edge2, x) => smoothStep01(clamp01((x - edge) / (edge2 - edge)));
22
+ /**
23
+ * Specialized version of {@link smoothStep}, assuming edges are 0/1
24
+ * respectively and `x` is in [0..1]. No clamping performed.
25
+ *
26
+ * @param x
27
+ */
28
+ export const smoothStep01 = (x) => x * x * (3 - 2 * x);
22
29
  /**
23
30
  * Similar to {@link smoothStep} but using different, higher degree polynomial.
24
31
  *
32
+ * @remarks
33
+ * Also see {@link smootherStep01}.
34
+ *
25
35
  * @param edge -
26
36
  * @param edge2 -
27
37
  * @param x -
28
38
  */
29
- export const smootherStep = (edge, edge2, x) => {
30
- x = clamp01((x - edge) / (edge2 - edge));
31
- return x * x * x * (x * (x * 6 - 15) + 10);
32
- };
39
+ export const smootherStep = (edge, edge2, x) => smootherStep01(clamp01((x - edge) / (edge2 - edge)));
40
+ /**
41
+ * Specialized version of {@link smootherStep}, assuming edges are 0/1
42
+ * respectively and `x` is in [0..1]. No clamping performed.
43
+ *
44
+ * @param x
45
+ */
46
+ export const smootherStep01 = (x) => x * x * x * (x * (x * 6 - 15) + 10);
33
47
  /**
34
48
  * Exponential ramp with variable shape
35
49
  *