+ // 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 = x0*t + x1*one_minus_t;
+ Real x12 = x1*t + x2*one_minus_t;
+ Real x23 = x2*t + x3*one_minus_t;
+
+ Real x012 = x01*t + x12*one_minus_t;
+ Real x123 = x12*t + x23*one_minus_t;
+
+ Real x0123 = x012*t + x123*one_minus_t;
+
+ // Y Coordinates
+ Real y01 = y0*t + y1*one_minus_t;
+ Real y12 = y1*t + y2*one_minus_t;
+ Real y23 = y2*t + y3*one_minus_t;
+
+ Real y012 = y01*t + y12*one_minus_t;
+ Real y123 = y12*t + y23*one_minus_t;
+
+ Real y0123 = y012*t + y123*one_minus_t;
+
+ return Bezier(x0, y0, x01, y01, x012, y012, x0123, y0123);
+ }
+ // Performs one round of De Casteljau subdivision and returns the [0,t] part.
+ Bezier DeCasteljauSubdivideLeft(const Real& t)
+ {
+ Real one_minus_t = Real(1) - t;
+
+ // X Coordinates
+ Real x01 = x0*t + x1*one_minus_t;
+ Real x12 = x1*t + x2*one_minus_t;
+ Real x23 = x2*t + x3*one_minus_t;
+
+ Real x012 = x01*t + x12*one_minus_t;
+ Real x123 = x12*t + x23*one_minus_t;
+
+ Real x0123 = x012*t + x123*one_minus_t;
+
+ // Y Coordinates
+ Real y01 = y0*t + y1*one_minus_t;
+ Real y12 = y1*t + y2*one_minus_t;
+ Real y23 = y2*t + y3*one_minus_t;
+
+ Real y012 = y01*t + y12*one_minus_t;
+ Real y123 = y12*t + y23*one_minus_t;
+
+ Real y0123 = y012*t + y123*one_minus_t;
+
+ return Bezier(x0123, y0123, x123, y123, x23, y23, x3, y3);
+ }
+