我正在尝试使用npm natural-spline-interpolator软件包 https://www.npmjs.com/package/natural-spline-interpolator 在此程序包中,我需要将点传递为[[100,350],[150,70],[200,200],[250,250]]。我应该使用哪种数据结构来实现这一目标?
我已经尝试使用Set(),Map()数据结构。
var point = new Set();
var pt;
this.points.forEach(element =>
{
pt = new Set([element.xAxis, element.yAxis]);
point.add(pt);
}
Set() resulted as
Set(3) {Set(2), Set(2), Set(2)}
size: (...)
__proto__: Set
[[Entries]]: Array(3)
0: Set(2)
value: Set(2)
size: (...)
__proto__: Set
[[Entries]]: Array(2)
0: 332.5565912117177
1: 407.18204184363304
length: 2
1: Set(2)
2: Set(2)
length: 3
结果应为: [[100,350],[150,70],[200,200],[250,250]]