@thi.ng/math
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -6,2 +6,13 @@ # Change Log | ||
## [0.2.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/math@0.2.0...@thi.ng/math@0.2.1) (2018-11-20) | ||
### Bug Fixes | ||
* **math:** fix [#60](https://github.com/thi-ng/umbrella/issues/60), add range check for norm() ([143c47c](https://github.com/thi-ng/umbrella/commit/143c47c)) | ||
# [0.2.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/math@0.1.0...@thi.ng/math@0.2.0) (2018-10-21) | ||
@@ -8,0 +19,0 @@ |
@@ -0,1 +1,9 @@ | ||
/** | ||
* Returns normalized value of `x` WRT to interval `a .. b`. If `a` | ||
* equals `b`, returns 0. | ||
* | ||
* @param x | ||
* @param a | ||
* @param b | ||
*/ | ||
export declare const norm: (x: number, a: number, b: number) => number; | ||
@@ -2,0 +10,0 @@ export declare const fit: (x: number, a: number, b: number, c: number, d: number) => number; |
10
fit.js
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const interval_1 = require("./interval"); | ||
exports.norm = (x, a, b) => (x - a) / (b - a); | ||
/** | ||
* Returns normalized value of `x` WRT to interval `a .. b`. If `a` | ||
* equals `b`, returns 0. | ||
* | ||
* @param x | ||
* @param a | ||
* @param b | ||
*/ | ||
exports.norm = (x, a, b) => b !== a ? (x - a) / (b - a) : 0; | ||
exports.fit = (x, a, b, c, d) => c + (d - c) * exports.norm(x, a, b); | ||
@@ -6,0 +14,0 @@ exports.fitClamped = (x, a, b, c, d) => c + (d - c) * interval_1.clamp01(exports.norm(x, a, b)); |
{ | ||
"name": "@thi.ng/math", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "Assorted common math functions & utilities", | ||
@@ -42,3 +42,3 @@ "main": "./index.js", | ||
}, | ||
"gitHead": "5bb513915cb3c533bd4278f6f365389b3664f4d1" | ||
"gitHead": "e044a6a2548a372399444479153861da6a63e1dc" | ||
} |
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
37127
735