@thi.ng/math
Advanced tools
Comparing version 5.4.11 to 5.5.0
# Change Log | ||
- **Last updated**: 2023-06-14T07:58:51Z | ||
- **Last updated**: 2023-07-14T11:37:51Z | ||
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub) | ||
@@ -12,2 +12,8 @@ | ||
## [5.5.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/math@5.5.0) (2023-07-14) | ||
#### 🚀 Features | ||
- add smoothStep01/smootherStep01() ([152f93c](https://github.com/thi-ng/umbrella/commit/152f93c)) | ||
### [5.4.4](https://github.com/thi-ng/umbrella/tree/@thi.ng/math@5.4.4) (2023-03-02) | ||
@@ -14,0 +20,0 @@ |
{ | ||
"name": "@thi.ng/math", | ||
"version": "5.4.11", | ||
"version": "5.5.0", | ||
"description": "Assorted common math functions & utilities", | ||
@@ -141,3 +141,3 @@ "type": "module", | ||
}, | ||
"gitHead": "54e825a976c72067a244cff8725ca98f5416d26d\n" | ||
"gitHead": "88cfe77770f3b07c788301dccefcb9547cd4aff6\n" | ||
} |
@@ -1,2 +0,2 @@ | ||
import type { FnN2, FnN3 } from "@thi.ng/api"; | ||
import type { FnN, FnN2, FnN3 } from "@thi.ng/api"; | ||
/** | ||
@@ -13,2 +13,5 @@ * Step/threshold function. | ||
* | ||
* @remarks | ||
* Also see {@link smoothStep01}, {@link smootherStep}. | ||
* | ||
* @param edge - lower threshold | ||
@@ -21,4 +24,14 @@ * @param edge2 - upper threshold | ||
/** | ||
* Specialized version of {@link smoothStep}, assuming edges are 0/1 | ||
* respectively and `x` is in [0..1]. No clamping performed. | ||
* | ||
* @param x | ||
*/ | ||
export declare const smoothStep01: FnN; | ||
/** | ||
* Similar to {@link smoothStep} but using different, higher degree polynomial. | ||
* | ||
* @remarks | ||
* Also see {@link smootherStep01}. | ||
* | ||
* @param edge - | ||
@@ -30,2 +43,9 @@ * @param edge2 - | ||
/** | ||
* Specialized version of {@link smootherStep}, assuming edges are 0/1 | ||
* respectively and `x` is in [0..1]. No clamping performed. | ||
* | ||
* @param x | ||
*/ | ||
export declare const smootherStep01: FnN; | ||
/** | ||
* Exponential ramp with variable shape | ||
@@ -32,0 +52,0 @@ * |
30
step.js
@@ -13,2 +13,5 @@ import { clamp01 } from "./interval.js"; | ||
* | ||
* @remarks | ||
* Also see {@link smoothStep01}, {@link smootherStep}. | ||
* | ||
* @param edge - lower threshold | ||
@@ -19,9 +22,16 @@ * @param edge2 - upper threshold | ||
*/ | ||
export const smoothStep = (edge, edge2, x) => { | ||
x = clamp01((x - edge) / (edge2 - edge)); | ||
return (3 - 2 * x) * x * x; | ||
}; | ||
export const smoothStep = (edge, edge2, x) => smoothStep01(clamp01((x - edge) / (edge2 - edge))); | ||
/** | ||
* Specialized version of {@link smoothStep}, assuming edges are 0/1 | ||
* respectively and `x` is in [0..1]. No clamping performed. | ||
* | ||
* @param x | ||
*/ | ||
export const smoothStep01 = (x) => x * x * (3 - 2 * x); | ||
/** | ||
* Similar to {@link smoothStep} but using different, higher degree polynomial. | ||
* | ||
* @remarks | ||
* Also see {@link smootherStep01}. | ||
* | ||
* @param edge - | ||
@@ -31,7 +41,11 @@ * @param edge2 - | ||
*/ | ||
export const smootherStep = (edge, edge2, x) => { | ||
x = clamp01((x - edge) / (edge2 - edge)); | ||
return x * x * x * (x * (x * 6 - 15) + 10); | ||
}; | ||
export const smootherStep = (edge, edge2, x) => smootherStep01(clamp01((x - edge) / (edge2 - edge))); | ||
/** | ||
* Specialized version of {@link smootherStep}, assuming edges are 0/1 | ||
* respectively and `x` is in [0..1]. No clamping performed. | ||
* | ||
* @param x | ||
*/ | ||
export const smootherStep01 = (x) => x * x * x * (x * (x * 6 - 15) + 10); | ||
/** | ||
* Exponential ramp with variable shape | ||
@@ -38,0 +52,0 @@ * |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
110814
2763