@thi.ng/math
Advanced tools
Comparing version 5.3.8 to 5.3.9
# Change Log | ||
- **Last updated**: 2022-09-21T21:37:59Z | ||
- **Last updated**: 2022-09-27T16:23:13Z | ||
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub) | ||
@@ -5,0 +5,0 @@ |
43
fit.d.ts
@@ -11,7 +11,50 @@ import type { FnN3, FnN5 } from "@thi.ng/api"; | ||
export declare const norm: FnN3; | ||
/** | ||
* Returns a number in the `[c,d]` interval which is relative to `x` in the | ||
* `[a,b]` interval. **No** clamping will be performed if `x` lies outside the | ||
* original range (for that use {@link fitClamped} instead). | ||
* | ||
* @param x | ||
* @param a | ||
* @param b | ||
* @param c | ||
* @param d | ||
*/ | ||
export declare const fit: FnN5; | ||
/** | ||
* Clamped version of {@link fit}, i.e. before mapping `x` into the target | ||
* interval `[c,d]`, it will be clamped to the source interval `[a,b]`. | ||
* | ||
* @param x | ||
* @param a | ||
* @param b | ||
* @param c | ||
* @param d | ||
*/ | ||
export declare const fitClamped: FnN5; | ||
/** | ||
* Similar to {@link fitClamped}, assuming [0,1] as source interval. | ||
* | ||
* @param x | ||
* @param a | ||
* @param b | ||
*/ | ||
export declare const fit01: FnN3; | ||
/** | ||
* Similar to {@link fitClamped}, assuming the reverse ordered [1,0] as source | ||
* interval. | ||
* | ||
* @param x | ||
* @param a | ||
* @param b | ||
*/ | ||
export declare const fit10: FnN3; | ||
/** | ||
* Similar to {@link fitClamped}, assuming [-1,1] as source interval. | ||
* | ||
* @param x | ||
* @param a | ||
* @param b | ||
*/ | ||
export declare const fit11: FnN3; | ||
//# sourceMappingURL=fit.d.ts.map |
43
fit.js
@@ -11,6 +11,49 @@ import { clamp01, clamp11 } from "./interval.js"; | ||
export const norm = (x, a, b) => (b !== a ? (x - a) / (b - a) : 0); | ||
/** | ||
* Returns a number in the `[c,d]` interval which is relative to `x` in the | ||
* `[a,b]` interval. **No** clamping will be performed if `x` lies outside the | ||
* original range (for that use {@link fitClamped} instead). | ||
* | ||
* @param x | ||
* @param a | ||
* @param b | ||
* @param c | ||
* @param d | ||
*/ | ||
export const fit = (x, a, b, c, d) => c + (d - c) * norm(x, a, b); | ||
/** | ||
* Clamped version of {@link fit}, i.e. before mapping `x` into the target | ||
* interval `[c,d]`, it will be clamped to the source interval `[a,b]`. | ||
* | ||
* @param x | ||
* @param a | ||
* @param b | ||
* @param c | ||
* @param d | ||
*/ | ||
export const fitClamped = (x, a, b, c, d) => c + (d - c) * clamp01(norm(x, a, b)); | ||
/** | ||
* Similar to {@link fitClamped}, assuming [0,1] as source interval. | ||
* | ||
* @param x | ||
* @param a | ||
* @param b | ||
*/ | ||
export const fit01 = (x, a, b) => a + (b - a) * clamp01(x); | ||
/** | ||
* Similar to {@link fitClamped}, assuming the reverse ordered [1,0] as source | ||
* interval. | ||
* | ||
* @param x | ||
* @param a | ||
* @param b | ||
*/ | ||
export const fit10 = (x, a, b) => b + (a - b) * clamp01(x); | ||
/** | ||
* Similar to {@link fitClamped}, assuming [-1,1] as source interval. | ||
* | ||
* @param x | ||
* @param a | ||
* @param b | ||
*/ | ||
export const fit11 = (x, a, b) => a + (b - a) * (0.5 + 0.5 * clamp11(x)); |
17
mix.d.ts
@@ -30,3 +30,20 @@ import type { FnN, FnN2, FnN3, FnN4, FnN5, FnN6 } from "@thi.ng/api"; | ||
export declare const mixBilinear: FnN6; | ||
/** | ||
* Computes quadratic bezier interpolation for normalized value `t`. | ||
* | ||
* @param a | ||
* @param b | ||
* @param c | ||
* @param t | ||
*/ | ||
export declare const mixQuadratic: FnN4; | ||
/** | ||
* Computes cubic bezier interpolation for normalized value `t`. | ||
* | ||
* @param a | ||
* @param b | ||
* @param c | ||
* @param d | ||
* @param t | ||
*/ | ||
export declare const mixCubic: FnN5; | ||
@@ -33,0 +50,0 @@ /** |
17
mix.js
@@ -34,2 +34,10 @@ import { EPS, HALF_PI, PI } from "./api.js"; | ||
}; | ||
/** | ||
* Computes quadratic bezier interpolation for normalized value `t`. | ||
* | ||
* @param a | ||
* @param b | ||
* @param c | ||
* @param t | ||
*/ | ||
export const mixQuadratic = (a, b, c, t) => { | ||
@@ -39,2 +47,11 @@ const s = 1 - t; | ||
}; | ||
/** | ||
* Computes cubic bezier interpolation for normalized value `t`. | ||
* | ||
* @param a | ||
* @param b | ||
* @param c | ||
* @param d | ||
* @param t | ||
*/ | ||
export const mixCubic = (a, b, c, d, t) => { | ||
@@ -41,0 +58,0 @@ const t2 = t * t; |
{ | ||
"name": "@thi.ng/math", | ||
"version": "5.3.8", | ||
"version": "5.3.9", | ||
"description": "Assorted common math functions & utilities", | ||
@@ -135,3 +135,3 @@ "type": "module", | ||
}, | ||
"gitHead": "973139c5aa3b50081020f4cc726a7cc330f77fc7\n" | ||
"gitHead": "f4c59114f2d2dfafa9014626038a9ec5242b0606\n" | ||
} |
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
106673
2618