更新记录
1.0.1(2023-11-12)
增加一个多维向量数据重采样接口;
1.0.0(2023-11-12)
发布第一个版本,包含一个一维数据重采样接口;
平台兼容性
App |
快应用 |
微信小程序 |
支付宝小程序 |
百度小程序 |
字节小程序 |
QQ小程序 |
HBuilderX 3.6.8,Android:支持,iOS:支持,HarmonyNext:不确定 |
× |
× |
× |
× |
× |
× |
钉钉小程序 |
快手小程序 |
飞书小程序 |
京东小程序 |
× |
× |
× |
× |
H5-Safari |
Android Browser |
微信浏览器(Android) |
QQ浏览器(Android) |
Chrome |
IE |
Edge |
Firefox |
PC-Safari |
× |
× |
× |
× |
× |
× |
× |
× |
× |
xuhua-dataLib
开发文档
1 使用方法
1.1 引入及调用
import * as xuhua_dataLib from "@/uni_modules/xuhua-dataLib"
//一维数据重采样(非线性插值)
var data = [1, 2, 1];
console.log("5 => ", xuhua_dataLib.ResamplePoints1D(data, 5));
console.log("4 => ", xuhua_dataLib.ResamplePoints1D(data, 4));
console.log("3 => ", xuhua_dataLib.ResamplePoints1D(data, 3));
console.log("2 => ", xuhua_dataLib.ResamplePoints1D(data, 2));
console.log("1 => ", xuhua_dataLib.ResamplePoints1D(data, 1));
console.log("0 => ", xuhua_dataLib.ResamplePoints1D(data, 0));
//多维数据重采样(非线性插值)
const data = [ [1, 1, 1], [2, 2, 2], [3, 1, 1] ];
console.log("5 => ", xuhua_dataLib.ResamplePointsND(data, 5));
console.log("4 => ", xuhua_dataLib.ResamplePointsND(data, 4));
console.log("3 => ", xuhua_dataLib.ResamplePointsND(data, 3));
console.log("2 => ", xuhua_dataLib.ResamplePointsND(data, 2));
console.log("1 => ", xuhua_dataLib.ResamplePointsND(data, 1));
console.log("0 => ", xuhua_dataLib.ResamplePointsND(data, 0));
1.2 运行结果
//一维数据重采样结果(非线性插值)
5 => [1, 1.5625, 2, 1.5625, 1]
4 => [1, 1.7777777777777777, 1.777777777777778, 1]
3 => [1, 2, 1]
2 => [1, 1]
1 => [2]
0 => []
//多维数据重采样结果(非线性插值)
5 => [[1,1,1], [1.4375,1.5625,1.5625], [2,2,2],[2.5625,1.5625,1.5625],[3,1,1]]
4 => [[1,1,1],
[1.6296296296296295,1.7777777777777777,1.7777777777777777],
[2.3703703703703702, 1.777777777777778, 1.777777777777778],
[3,1,1]]
3 => [[1,1,1], [2,2,2], [3,1,1]]
2 => [[1,1,1], [3,1,1]]
1 => [[2,2,2]]
0 => []
1.3 空数据重采样填充{0}
const data01 = [];
console.log("2 => ", xuhua_dataLib.ResamplePoints1D(data01, 2));
console.log("1 => ", xuhua_dataLib.ResamplePoints1D(data01, 1));
console.log("0 => ", xuhua_dataLib.ResamplePoints1D(data01, 0));
运行结果:
2 => [0, 0]
1 => [0]
0 => []
1.3 单数据重采样填充{原值}
const data02 = [99];
console.log("2 => ", xuhua_dataLib.ResamplePoints1D(data02, 2));
console.log("1 => ", xuhua_dataLib.ResamplePoints1D(data02, 1));
console.log("0 => ", xuhua_dataLib.ResamplePoints1D(data02, 0));
运行结果:
2 => [99, 99]
1 => [99]
0 => []
2 接口说明
2.1 数据重采样
function ResamplePoints1D(data: Array<number>, sampleCount: number): Array<number>
说明:
一维数据重采样,使用非线性插值
function ResamplePointsND(data: Array<Array<number>>, sampleCount: number): Array<Array<number>>
说明:
支持多维向量数据重采样,使用非线性插值