DBL Evaluate_Function_UV(FUNCTION funct, UV_VECT fnvec) { POVFPU_SetLocal(U, fnvec[U]); POVFPU_SetLocal(V, fnvec[V]); return POVFPU_Run(funct); }
DBL Evaluate_Function(FUNCTION funct, VECTOR fnvec) { POVFPU_SetLocal(X, fnvec[X]); POVFPU_SetLocal(Y, fnvec[Y]); POVFPU_SetLocal(Z, fnvec[Z]); return POVFPU_Run(funct); }
void Evaluate_Function_Interval_UV(FUNCTION funct, DBL threshold, UV_VECT fnvec_low, UV_VECT fnvec_hi, DBL max_gradient, DBL& low, DBL& hi) { DBL f_0_0, f_0_1, f_1_0, f_1_1; DBL f_0_min, f_0_max; DBL f_1_min, f_1_max; DBL junk; /* Calculate the values at each corner */ POVFPU_SetLocal(U, fnvec_low[U]); POVFPU_SetLocal(V, fnvec_low[V]); f_0_0 = POVFPU_Run(funct) - threshold; POVFPU_SetLocal(U, fnvec_low[U]); POVFPU_SetLocal(V, fnvec_hi[V]); f_0_1 = POVFPU_Run(funct) - threshold; POVFPU_SetLocal(U, fnvec_hi[U]); POVFPU_SetLocal(V, fnvec_low[V]); f_1_0 = POVFPU_Run(funct) - threshold; POVFPU_SetLocal(U, fnvec_hi[U]); POVFPU_SetLocal(V, fnvec_hi[V]); f_1_1 = POVFPU_Run(funct) - threshold; /* Determine a min and a max along the left edge of the patch */ Interval( fnvec_hi[V]-fnvec_low[V], f_0_0, f_0_1, max_gradient, &f_0_min, &f_0_max); /* Determine a min and a max along the right edge of the patch */ Interval( fnvec_hi[V]-fnvec_low[V], f_1_0, f_1_1, max_gradient, &f_1_min, &f_1_max); /* Assume that the upper bounds of both edges are attained at the same u coordinate and determine what an upper bound along that line would be if it existed. That's the worst-case maximum value we can reach. */ Interval( fnvec_hi[U]-fnvec_low[U], f_0_max, f_1_max, max_gradient, &junk, &hi); /* same as above to get a lower bound from the two edge lower bounds */ Interval( fnvec_hi[U]-fnvec_low[U], f_0_min, f_1_min, max_gradient, &low, &junk); /* char str[200]; static int its=0; its++; if (its>20) Error("Boom!"); sprintf( str, "%lf %lf %lf %lf %lf %lf %lf\n%lf %lf %lf %lf %lf %lf %lf %lf %lf %lf\n", max_gradient, fnvec_low[U], fnvec_low[V], fnvec_hi[U], fnvec_hi[V], fnvec_hi[U]-fnvec_low[U], fnvec_hi[V]-fnvec_low[V], f_0_0,f_0_1,f_1_0,f_1_1, f_0_min,f_0_max, f_1_min,f_1_max, low,hi); Warning( 0, str ); */ /* f_min and f_max now contain the maximum interval. */ }