- Real t0_squared = t0*t0;
- Real t0_cubed = t0*t0_squared;
-
- // X coordinates
- Real Dx0 = x0 / tdiff_cubed;
- Real Dx1 = x1 / (tdiff_squared - tdiff_cubed);
- Real Dx2 = x2 / (tdiff - Real(2)*tdiff_squared + tdiff_cubed);
- Real Dx3 = x3 / (Real(1) - Real(3)*tdiff + Real(3)*tdiff_squared - tdiff_cubed);
+ // X Coordinates
+ Real x01 = x1*t + x0*one_minus_t;
+ Real x12 = x2*t + x1*one_minus_t;
+ Real x23 = x3*t + x2*one_minus_t;
+
+ Real x012 = x12*t + x01*one_minus_t;
+ Real x123 = x23*t + x12*one_minus_t;
+
+ Real x0123 = x123*t + x012*one_minus_t;
+
+ // Y Coordinates
+ Real y01 = y1*t + y0*one_minus_t;
+ Real y12 = y2*t + y1*one_minus_t;
+ Real y23 = y3*t + y2*one_minus_t;
+
+ Real y012 = y12*t + y01*one_minus_t;
+ Real y123 = y23*t + y12*one_minus_t;
+
+ Real y0123 = y123*t + y012*one_minus_t;
+
+ return Bezier(x0, y0, x01, y01, x012, y012, x0123, y0123);
+ }
+ // Performs one round of De Casteljau subdivision and returns the [t,1] part.
+ Bezier DeCasteljauSubdivideRight(const Real& t)
+ {
+ Real one_minus_t = Real(1) - t;
+
+ // X Coordinates
+ Real x01 = x1*t + x0*one_minus_t;
+ Real x12 = x2*t + x1*one_minus_t;
+ Real x23 = x3*t + x2*one_minus_t;
+
+ Real x012 = x12*t + x01*one_minus_t;
+ Real x123 = x23*t + x12*one_minus_t;
+
+ Real x0123 = x123*t + x012*one_minus_t;