1 #ifndef SimTK_SIMMATH_GEO_BICUBIC_BEZIER_PATCH_H_
2 #define SimTK_SIMMATH_GEO_BICUBIC_BEZIER_PATCH_H_
114 : B(controlPoints) {}
208 const RealP tol = getDefaultTol<RealP>();
209 SimTK_ERRCHK1(tol <= u && u <= 1-tol,
"Geo::BicubicBezierPatch::splitU()",
210 "Can't split patch at parameter u=%g; it is either out of range or"
211 " too close to an edge.", (
double)u);
214 for (
int i=0; i<4; ++i) {
220 for (
int i=0; i<4; ++i) {
243 const RealP tol = getDefaultTol<RealP>();
244 SimTK_ERRCHK1(tol <= w && w <= 1-tol,
"Geo::BicubicBezierPatch::splitW()",
245 "Can't split patch at parameter w=%g; it is either out of range or"
246 " too close to an edge.", (
double)w);
249 for (
int i=0; i<4; ++i) {
255 for (
int i=0; i<4; ++i) {
282 const RealP tol = getDefaultTol<RealP>();
283 SimTK_ERRCHK2((tol <= u && u <= 1-tol) && (tol <= w && w <= 1-tol),
284 "Geo::BicubicBezierPatch::split()",
285 "Can't split patch at parametric point u,w=%g,%g; it is either out of"
286 " range or too close to an edge.", (
double)u, (
double)w);
292 if (u ==
Real(0.5)) {
294 patch0.
splitU(u, patch00, patch10);
295 patch1.
splitU(u, patch01, patch11);
298 patch0.
splitW(w, patch00, patch01);
299 patch1.
splitW(w, patch10, patch11);
347 return Fbu * B * ~Fbw;
360 Pu = dFbu * B * ~Fbw;
361 Pw = Fbu * B * ~dFbw;
376 Puu = d2Fbu * B * ~Fbw;
377 Puw = dFbu * B * ~dFbw;
378 Pww = Fbu * B * ~d2Fbw;
395 Puuu = d3Fbu * B * ~Fbw;
396 Puuw = d2Fbu * B * ~dFbw;
397 Puww = dFbu * B * ~d2Fbw;
398 Pwww = Fbu * B * ~d3Fbw;
420 typedef const Vec3P& Coef;
421 Coef b11=B(0,0), b12=B(0,1), b13=B(0,2), b14=B(0,3),
422 b21=B(1,0), b22=B(1,1), b23=B(1,2), b24=B(1,3),
423 b31=B(2,0), b32=B(2,1), b33=B(2,2), b34=B(2,3),
424 b41=B(3,0), b42=B(3,1), b43=B(3,2), b44=B(3,3);
430 Vec3P a= b41-b11+3*(b21-b31), b= b42-b12+3*(b22-b32),
431 c= b43-b13+3*(b23-b33), d= b44-b14+3*(b24-b34);
432 Vec3P e= 3*(b11+b31)-6*b21, f= 3*(b12+b32)-6*b22,
433 g= 3*(b13+b33)-6*b23, h= 3*(b14+b34)-6*b24;
434 Vec3P p= 3*(b21-b11), q= 3*(b22-b12),
435 r= 3*(b23-b13), s= 3*(b24-b14);
439 ( d-a+3*(b-c), 3*(a+c)-6*b, 3*(b-a), a,
440 h-e+3*(f-g), 3*(e+g)-6*f, 3*(f-e), e,
441 s-p+3*(q-r), 3*(p+r)-6*q, 3*(q-p), p,
442 b14-b11+3*(b12-b13), 3*(b11+b13)-6*b12, 3*(b12-b11), b11 );
448 typedef const Vec3P& Coef;
449 Coef a33=A(0,0), a32=A(0,1), a31=A(0,2), a30=A(0,3),
450 a23=A(1,0), a22=A(1,1), a21=A(1,2), a20=A(1,3),
451 a13=A(2,0), a12=A(2,1), a11=A(2,2), a10=A(2,3),
452 a03=A(3,0), a02=A(3,1), a01=A(3,2), a00=A(3,3);
458 Vec3P a=a13/3+a03, b=a12/3+a02, c=a11/3+a01, d=a10/3+a00;
459 Vec3P e=(a23+2*a13)/3+a03, f=(a22+2*a12)/3+a02,
460 g=(a21+2*a11)/3+a01, h=(a20+2*a10)/3+a00;
461 Vec3P p=a33+a23+a13+a03, q=a32+a22+a12+a02,
462 r=a31+a21+a11+a01, s=a30+a20+a10+a00;
467 ( a00, a01/3+a00, (a02+2*a01)/3+a00, a03+a02+a01+a00,
468 d, c/3+d, (b+2*c)/3+d, a+b+c+d,
469 h, g/3+h, (f+2*g)/3+h, e+f+g+h,
470 s, r/3+s, (q+2*r) /3+s, p+q+r+s );
476 typedef const Vec3P& Coef;
477 Coef b11=B(0,0), b12=B(0,1), b13=B(0,2), b14=B(0,3),
478 b21=B(1,0), b22=B(1,1), b23=B(1,2), b24=B(1,3),
479 b31=B(2,0), b32=B(2,1), b33=B(2,2), b34=B(2,3),
480 b41=B(3,0), b42=B(3,1), b43=B(3,2), b44=B(3,3);
483 Vec3P b12mb11=b12-b11, b24mb14=b24-b14, b42mb41=b42-b41, b44mb34=b44-b34;
487 ( b11, b14, 3*b12mb11, 3*(b14-b13),
488 b41, b44, 3*b42mb41, 3*(b44-b43),
489 3*(b21-b11), 3*b24mb14, 9*(b22-b21-b12mb11), 9*(b24mb14+b13-b23),
490 3*(b41-b31), 3*b44mb34, 9*(b42mb41+b31-b32), 9*(b44mb34+b33-b43) );
496 typedef const Vec3P& Coef;
497 Coef h00=H(0,0), h01=H(0,1), w00=H(0,2), w01=H(0,3),
498 h10=H(1,0), h11=H(1,1), w10=H(1,2), w11=H(1,3),
499 u00=H(2,0), u01=H(2,1), t00=H(2,2), t01=H(2,3),
500 u10=H(3,0), u11=H(3,1), t10=H(3,2), t11=H(3,3);
503 Vec3P tmp00=h00+u00/3, tmp01=h01+u01/3,
504 tmp10=h10-u10/3, tmp11=h11-u11/3;
508 ( h00, h00+w00/3, h01-w01/3, h01,
509 tmp00, tmp00+w00/3+t00/9, tmp01-w01/3-t01/9, tmp01,
510 tmp10, tmp10+w10/3-t10/9, tmp11-w11/3+t11/9, tmp11,
511 h10, h10+w10/3, h11-w11/3, h11 );
523 #endif // SimTK_SIMMATH_GEO_BICUBIC_BEZIER_PATCH_H_