Javascript library for numerical interpolation and extrapolation.
npm install numfit
section:
html
`
#### Using a Local Copy
Alternatively, you can opt for a local deployment of the library. Locate the /build/ directory within this repository and download either the standard Numfit.js file or the minified version Numfit.min.js. Then, incorporate the downloaded file into your HTML document's section using a
Replace my-directory with the actual path to the downloaded file.
Basic Usage
`javascript
const positions = [ 0, 1 ];
const values = [ 0, 0, 0, 255, 255, 255 ];
const dimension = 3;
const linear = new Linear( positions, values, dimension );
linear.evaluate( 0 );
linear.evaluate( .5 );
linear.evaluate( 1 );
`
`javascript
const positions = [ 0,0, 1,1, 2,2, 3,3 ];
const values = [
0,0,0, 255,0,0, 0,255,0, 0,0,255,
255,0,0, 0,255,0, 0,0,255, 0,0,0,
0,255,0, 0,0,255, 0,0,0, 255,0,0,
0,0,255, 0,0,0, 255,0,0, 0,255,0
];
const dimension = 3;
const bicubic = new Bicubic( positions, values, dimension );
bicubic.step( [0,0], [1,1], [.1,.1] ( position, value ) => {
// Do something with positions and the values.
});
`
Building and Testing
$3
Running the build and testing procedures is easy. First make sure you have `npm` installed. Secondly navigate to the root directory `/` in your CLI and run `npm install --save-dev` which will install two dependencies required in the build and testing phases, `esbuild` and `vitest` respectively.
$3
To run the build procedure, you simply navigate to the root directory `/` in your CLI and run
`npm run build` which will produce two files in the `/build/` directory: `Numfit.js` and `Numfit.min.js`.
$3
To run the tests, you again navigate to the root directory `/` in your CLI and run
`npm run test` which will produce the test results.
Roadmap
Features that we are planning to support down the road are:
- [ ] More types of samplers. Currently supports `step`, `segment` and `map``.