【发布时间】:2014-12-12 16:08:40
【问题描述】:
我从[这个网站]http://paulbourke.net/miscellaneous/interpolation/得到这个功能:
double CosineInterpolate(
double y1,double y2,
double mu)
{
double mu2;
mu2 = (1-cos(mu*PI))/2;
return(y1*(1-mu2)+y2*mu2);
}
如何使用它来插入数组?这是我调用函数的方式。
Interpolate(point_a, point_b, number_of_positions_between_the_points, position)
例如
for (int i = 0; i < ArrayOfPoints.size()-1; ++i) {
double point_a = ArrayOfPoints[i];
double point_b = ArrayOfPoints[i+1];
for (int j = 0; j < 2048; ++j){
array[j] = Interpolate(point_a, point_b, 2048, j)
}
}
【问题讨论】:
-
只是将
number_of_positions_between_the_points和position转换成mu的问题。微不足道的数学。 -
如何“转换为 mu”?对不起,我只是不明白。
标签: c++ arrays interpolation trigonometry