Graphics Reference
In-Depth Information
/* -------------------------------------------------------------
* STRUCTURES
*/
// the structure to hold entries of the table consisting of
// parameter value (u) and estimated length (length)
typedef struct table_entry_structure {
double u,length;
} table_entry_td;
// the structure to hold an interval of the curve, defined by
// starting and ending parameter values and the estimated
// length (to be filled in by the adaptive integration
// procedure)
typedef struct interval_structure {
double ua,ub;
double length;
} interval_td;
// coefficients for a 2D cubic curve
typedef struct cubic_curve_structure {
double ax,bx,cx,dx;
double ay,by,cy,dy;
} cubic_curve_td;
// polynomial function structure; a quadric function is generated
// from a cubic curve during the arclength computation
typedef struct polynomial_structure {
double *coeff;
int degree;
} polynomial_td;
/* --------------------------------------------------------------------
* ADAPTIVE INTEGRATION
* this is the high-level call used whenever a curve's length is to be computed
*/
void adaptive_integration(cubic_curve_td *curve, double ua, double ub,double
tolerance)
{
double subdivide();
polynomial_td func;
interval_td full_interval;
double total_length;
double integrate_func();
double temp;
func.degree = 4;
func.coeff = (double *)malloc(sizeof(double)*5);
FIGURE 3.8
 
Search WWH ::




Custom Search