Tag: 线性插值

C#/ Unity3D中的分段线性整数曲线插值

有没有一种简单有效的方法在C#中实现分段线性整数到整数曲线插值(对于Unity3D,如果重要的话)? 详情如下: 分段线性曲线表示必须随着时间的推移而建立。 第一个插值请求在我们拥有所有数据点之前 曲线严格单调 第一点总是(0,0) 数据点的第一坐标也是严格单调的到达时间,即这些点自然地按其第一坐标排序。 数据点不在可能导致4字节整数导致溢出问题的范围内 输出不必100%准确,因此舍入误差不是问题。 在C ++中,我会做这样的事情: #include #include #include using namespace std; typedef pair tDataPoint; typedef vector tPLC; void appendData(tPLC& curve, const tDataPoint& point) { assert(curve.empty() || curve.back().first 0) { // find the first data point above the cursor const auto upper = upper_bound(begin(curve), end(curve), cursor); // above the last […]