void deCastelijau(const Point* ctrlPoints, const int numCtrlPts,
const int resolutionOfLine, Point* bezierPoints) {
/* ctrlPoints — our control points for this curve
numCtrlPts — number of control points
resolutionOfLine — resolution/”number of lines drawn for the entire curve”
bezierPoints — our output, a collection of points we are to connect to attain our bezier curve*/
//// do some error checking here on input
for(int i = 0; i <= resolutionOfLine; i++) {
double u = (double) i / (double) resolutionOfLine;
Point Q[numCtrlPts];
for(int j = 0; j < numCtrlPts; j++) {
Q[j] = ctrlPoints[j];
}
for(int j = 1; j < numCtrlPts; j++) {
for(int k = 0; k < numCtrlPts - j; k++) {
Point temp((1.0 - u) * Q[k].x + u * Q[k + 1].x, (1.0 - u) * Q[k].y + u * Q[k + 1].y);
Q[k] = temp;
}
}
bezierPoints[i] = Q[0];
}
}
Check out the source code.