@bedard/math
Advanced tools
Comparing version 0.1.1 to 0.2.0
/** | ||
* Two dimensional vector | ||
*/ | ||
type Vector2 = [ | ||
number, | ||
number | ||
]; | ||
/** | ||
* Bi-linear interpolation | ||
*/ | ||
declare function bilerp([x1, y1]: Vector2, [x2, y2]: Vector2, alpha: number): Vector2; | ||
/** | ||
* Linear interpolation between two numbers. | ||
*/ | ||
declare function lerp(a: number, b: number, alpha: number): number; | ||
declare const version = "0.1.1"; | ||
export { lerp, version }; | ||
declare const version = "0.2.0"; | ||
export { bilerp, lerp, version }; |
@@ -1,2 +0,2 @@ | ||
var BedardMath=function(e){"use strict";return e.lerp=function(e,r,t){return e*(1-t)+r*t},e.version="0.1.1",Object.defineProperty(e,"__esModule",{value:!0}),e}({}); | ||
var BedardMath=function(e){"use strict";function r(e,r,n){return e*(1-n)+r*n}return e.bilerp=function([e,n],[t,u],i){return[r(e,t,i),r(n,u,i)]},e.lerp=r,e.version="0.2.0",Object.defineProperty(e,"__esModule",{value:!0}),e}({}); | ||
//# sourceMappingURL=index.bundle.js.map |
/** | ||
* Two dimensional vector | ||
*/ | ||
type Vector2 = [ | ||
number, | ||
number | ||
]; | ||
/** | ||
* Bi-linear interpolation | ||
*/ | ||
declare function bilerp([x1, y1]: Vector2, [x2, y2]: Vector2, alpha: number): Vector2; | ||
/** | ||
* Linear interpolation between two numbers. | ||
*/ | ||
declare function lerp(a: number, b: number, alpha: number): number; | ||
declare const version = "0.1.1"; | ||
export { lerp, version }; | ||
declare const version = "0.2.0"; | ||
export { bilerp, lerp, version }; |
/** | ||
* Two dimensional vector | ||
*/ | ||
type Vector2 = [ | ||
number, | ||
number | ||
]; | ||
/** | ||
* Bi-linear interpolation | ||
*/ | ||
declare function bilerp([x1, y1]: Vector2, [x2, y2]: Vector2, alpha: number): Vector2; | ||
/** | ||
* Linear interpolation between two numbers. | ||
*/ | ||
declare function lerp(a: number, b: number, alpha: number): number; | ||
declare const version = "0.1.1"; | ||
export { lerp, version }; | ||
declare const version = "0.2.0"; | ||
export { bilerp, lerp, version }; |
@@ -8,4 +8,11 @@ /** | ||
const version = '0.1.1'; | ||
/** | ||
* Bi-linear interpolation | ||
*/ | ||
function bilerp([x1, y1], [x2, y2], alpha) { | ||
return [lerp(x1, x2, alpha), lerp(y1, y2, alpha)]; | ||
} | ||
export { lerp, version }; | ||
const version = '0.2.0'; | ||
export { bilerp, lerp, version }; |
@@ -12,5 +12,13 @@ 'use strict'; | ||
const version = '0.1.1'; | ||
/** | ||
* Bi-linear interpolation | ||
*/ | ||
function bilerp([x1, y1], [x2, y2], alpha) { | ||
return [lerp(x1, x2, alpha), lerp(y1, y2, alpha)]; | ||
} | ||
const version = '0.2.0'; | ||
exports.bilerp = bilerp; | ||
exports.lerp = lerp; | ||
exports.version = version; |
@@ -39,3 +39,3 @@ { | ||
"unpkg": "dist/index.bundle.js", | ||
"version": "0.1.1" | ||
"version": "0.2.0" | ||
} |
@@ -1,7 +0,56 @@ | ||
# math | ||
# `@bedard/math` | ||
[](https://github.com/scottbedard/math/actions) | ||
[](https://codecov.io/gh/scottbedard/math) | ||
[](https://david-dm.org/scottbedard/math) | ||
[](https://david-dm.org/scottbedard/math?type=dev) | ||
[](https://www.npmjs.com/package/@bedard/math) | ||
[](https://bundlephobia.com/result?p=@bedard/math) | ||
[](https://github.com/scottbedard/math/blob/main/LICENSE) | ||
A place for to store functions so I don't keep duplicating them between projects. | ||
This library exists to help me avoid duplicate code between projects. My goal here is to expose small, well tested, and tree-shakeable utilities. Given the simplicity of these functions, I do not anticipate breaking changes. But be warned, this project is not following semantic versioning. | ||
## Installation | ||
The recommended installation method is via NPM. | ||
```bash | ||
npm install @bedard/math | ||
``` | ||
Alternatively, these functions maybe be accessed via a CDN. When using a CDN, the library will be exposed globally as `BedardMath`. | ||
```html | ||
<script src="https://unpkg.com/@bedard/math"></script> | ||
``` | ||
## Functions | ||
- [`bilerp`](#bilerp) | ||
- [`lerp`](#lerp) | ||
### `bilerp` | ||
Bi-linear interpolation between vectors. | ||
```js | ||
import { bilerp } from '@bedard/math' | ||
bilerp([0, 0], [10, 10], 0.5) // [5, 5] | ||
``` | ||
### `lerp` | ||
Linear interpolation between numbers. | ||
```js | ||
import { lerp } from '@bedard/math' | ||
lerp(0, 10, 0.5) // 5 | ||
``` | ||
## License | ||
[MIT](https://github.com/scottbedard/math/blob/master/LICENSE) | ||
Copyright (c) 2021-present, Scott Bedard |
@@ -1,3 +0,4 @@ | ||
export { lerp } from './utils/lerp' | ||
export { bilerp } from './functions/bilerp' | ||
export { lerp } from './functions/lerp' | ||
export const version = '0.1.1' | ||
export const version = '0.2.0' |
Sorry, the diff of this file is not supported yet
11746
24
247
57