 # A Nurbs Optimization Part 2

I did a second test this morning with a curve with two spans and the new method still appears to be 2x faster than the Maya API method. I'll probably do one more test involving an arbitrary number of spans, and then do some tests regarding the speed of tangent calculation.

//calculate the extra points we need

points.insert((points + points) / 2.0, 2);

points.insert((points + points) / 2.0, 4);

points = (points + points) / 2.0;

//calculate the basis function for each CV//

MPoint res_point;

if (useCache_val)

{

for (unsigned k = 0; k < 100000; k++)

{

if (param_val < 1)

{

res_point = points * pow(1.0 - param_val, 3);

res_point += points * (3 * param_val * pow(1.0 - param_val, 2));

res_point += points * (3 * pow(param_val, 2) * (1.0 - param_val));

res_point += points * pow(param_val, 3);

}

else

{

res_point = points * pow(1.0 - param_val, 3);

res_point += points * (3 * param_val * pow(1.0 - param_val, 2));

res_point += points * (3 * pow(param_val, 2) * (1.0 - param_val));

res_point += points * pow(param_val, 3);

}

}

}

else

{

for (unsigned k = 0; k < 100000; k++)

mFnCurve.getPointAtParam(param_val, res_point);

}