Observed since 20 Oct, 19:09 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
Interpolate data set representing function of two variables z = f(x,y) with bicubic spline
This version includes contribution of Akshat Khare. According to Akshat pull request:
Previously the code failed for matrices with repeated value of z for
different record, which is undesired, so changed the code to accomodate
that issue.
This package is a simple implementation of a cubic-spline by morganherlocker for two-directional interpolation (2-dimensional arrays).
Assumed purpose of this package is to interpolate discrete function of two variables (e.g., for a surface plot).
z = f(x,y)
Following package was developed for another project that utilizes it for surface plot interpolation.
Package runs thanks to two dependencies. Firstly, of course cubic-spline by morganherlocker must be included. Another little package needed to run 2d-bicubic-spline is split-array by Arthur Verschaeve. Development dependencies fot testing include Mocha & Chai.
To install package:
npm install --save 2d-bicubic-interpolate
import interpolateArray from '2d-bicubic-interpolate';
Function takes two parameters: data, including data set to interpolate, and parameter n that describes 'strength' of interpolation. Function returns interpolated data set.
Data set is expected to be representation of a discrete function of two variables. Data set is expected to be an array of objects, where every each object presents coordinates for each point of function. Coordinates values are expected to be real numbers.
const data = [
{
x: 0,
y: 0,
z: 2
},
{
x: 1,
y: 0,
z: 0.3
},
{
x: 0,
y: 1,
z: 1.4
},
{
x: 1,
y: 1,
z: 2.5
}
]
Interpolation factor, the n parameter need to be a positive integer or 0. This number describes how many new points are going to be put between primary points. E.g., for n = 4, between every 2 primary points from input data, four new points are going to be calculated and inserted between. For n = 0, no interpolation is applied and output is the same as input.
Function interpolateArray returns new data set, which has the same structure as an input. Length of new data array is described as:
L1 = L0 + (L0 - 1) * n
Where:
L1 - length of output array
L0 - length of input array
n - interpolation factor
import interpolateArray from '2d-bicubic-interpolate';
const data = [
{
x: 0,
y: 0,
z: 0.3
},
{
x: 1,
y: 0,
z: 1.2
},
{
x: 0,
y: 1,
z: 1.4
},
{
x: 1,
y: 1,
z: 2.2
}
];
console.log(interpolateArray(data, 1));
/*
console:
(9) [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}]
0:{x: 0, y: 0, z: 0.3}
1:{x: 0, y: 0.5, z: 0.85}
2:{x: 0, y: 1, z: 1.4}
3:{x: 0.5, y: 0, z: 0.75}
4:{x: 0.5, y: 0.5, z: 1.275}
5:{x: 0.5, y: 1, z: 1.8}
6:{x: 1, y: 0, z: 1.2}
7:{x: 1, y: 0.5, z: 1.7}
8:{x: 1, y: 1, z: 2.2}
*/
Working principle of algorithm is presented by a 3D surface chart (vis.js), representing some discrete function of two-variables.
Data before interpolation:
InterpolateArray(data, 0);

Data interpolated with different interpolation factors: Data interpolated with different interpolation factors:
InterpolateArray(data, 1);

InterpolateArray(data, 10);

Download counts and popularity will appear here as the collector receives them.
This describes our collected data; it is not a security assessment.
Shared repository data · GitHub
Observed since 20 Oct, 19:09 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:c43d1f7a85f99fb19e9f946d4844be66b9dbb04c502125c8259385bbf4fb11f1