Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/powerbi/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 拉格朗日函数有什么问题?_C++_Opengl_Graphic - Fatal编程技术网

C++ 拉格朗日函数有什么问题?

C++ 拉格朗日函数有什么问题?,c++,opengl,graphic,C++,Opengl,Graphic,以上是我为opengl编写的拉格朗日函数算法 下面的链接是我必须实现的公式的屏幕截图 我已经调整了一段时间,但我似乎找不到它有什么问题 A如果你不说出哪里出了问题,我们该如何帮助你?不是吗?没有给出正确的答案?请添加不正确的输出和所需的输出。由于整数舍入,1/ctrlpnts.size也是0,请使用1.0/ctrlpnts.size。这可能是您的问题,但现在我可能被误解了,这不是结构良好的代码,这很可能是错误挖掘代码本身的原因,也是您难以发现它的原因。参数形式的b_it字面上要求一个函数,甚至更

以上是我为opengl编写的拉格朗日函数算法

下面的链接是我必须实现的公式的屏幕截图


我已经调整了一段时间,但我似乎找不到它有什么问题

A如果你不说出哪里出了问题,我们该如何帮助你?不是吗?没有给出正确的答案?请添加不正确的输出和所需的输出。由于整数舍入,1/ctrlpnts.size也是0,请使用1.0/ctrlpnts.size。这可能是您的问题,但现在我可能被误解了,这不是结构良好的代码,这很可能是错误挖掘代码本身的原因,也是您难以发现它的原因。参数形式的b_it字面上要求一个函数,甚至更好,一个将从样本中收集的参数化作为内部状态的函数。
 GsVec curve_eval::eval_lagrange(float t, float numberofsegmentsn, const GsArray<GsVec>& ctrlpnts) //f(t) = sum of p.i * B.i(t)
 {  
//float interval = 1 / numberofsegmentsn; //so if 4, then 0.25
float interval = 1 / ctrlpnts.size(); 

//remember that for interval that is put in above, it's based on numbers of ctrlpnts

//for lagrange, let t 
GsVec ft(0.0f, 0.0f, 0.0f);
int sizeofctrlpnts = ctrlpnts.size();
float result = 0;   
std::cout << "interval = " << interval << "  \\ number of segments = " << numberofsegmentsn << " \\ ctrlpnts.size() = " << ctrlpnts.size() << "\n";

float tt = 0;
float ti[50] = { 0 }; 
float tj[50] = { 0 }; //only this might be used
for (int x = 0; x < ctrlpnts.size(); x++) //changed from 'numberofsegmentsn'
{
    tj[x] = tt;//
    std::cout << "tt in tj[" << x << "]= " << tt <<  "\n";
    tt = tt + interval;

}

float tb = 1;
tt = 1;
int i = 0;
for (int i = 0; i < ctrlpnts.size(); i ++)
{
    tt = 1;
    tb = 1;
    for (int j = 0; j < ctrlpnts.size(); j++) // 
    {           
        if (i != j)
        {
            std::cout << "Before cal: i = " << i << " :: j = " << j << " :: tt = " << tt << " :: tb = " << tb << " :: t = " << t << " :: tj[i" << j << "] = " << tj[j] << " :: tj[j" << i << "] = " << tj[i] << "\n";

            tt = (t - tj[j]) * tt;
            tb = (tj[i] - tj[j])* tb;

            std::cout << "After cal: tt = " << tt << " :: tb = " << tb << "\n";
        }
        //t gotta change
    }
    result = tt / tb;
    ft = ft+(ctrlpnts[i]*result);
}

return ft;