www.pudn.com > nurbs++3_0_10.zip > tnlength.C
// The first functions are used to compute the bezierMatrix coefficients // I'm keeping them here in case I need them. // but this file is used to test the validity of the length function // this is bases partly on equation 6.86 from the NURBS book #include#include #include using namespace PLib ; // Generates the bezier matrix coefficients void bezierMatrix(int deg, PlMatrix_float& Mp){ int i,j ; PlMatrix_float bin(deg+1,deg+1) ; binomialCoef(bin) ; Mp.resize(deg+1,deg+1) ; for(i=0;i of degree 2.\n" ; float l; for(i=0;i<500;++i) l = circle.length() ; cout << "it's length is " << l << "\terror = " << absolute(2*M_PI-l) << endl ; cout << "Now we use a degree 3 circle to make sure it's still valid\n" ; circle.degreeElevate(1) ; for(i=0;i<500;++i) l = circle.length() ; cout << "it's length is " << l << "\terror = " << absolute(2*M_PI-l) << endl ; cout << "\nIn case you forgot, the value should be 2*PI\n" ; cout << "\nNow we test if we can find the length of the curve for a\n" "range of the circle: [0.25,0.75].\n" ; for(i=0;i<500;++i) l = circle.lengthIn(0.25,0.75) ; cout << "The length is " << l << "\terror = " << absolute(M_PI-l) << endl ; return 0 ; }