Exemple #1
0
void
draw_bezier_curve(int num_segments, control_point p[], int num_points)
{
	float x = p[0].x;
	float y = p[0].y;

	glBegin(GL_LINE_STRIP);
 	glVertex2f(x, y);

 	for(int i = 1; i < num_segments; i++){
 		evaluate_bezier_curve(&x, &y, p, num_points, i / (float)num_segments);
 		glVertex2f(x, y);
 	}

 	glVertex2f(p[num_points - 1].x, p[num_points - 1].y);
 	glEnd();
}
Exemple #2
0
void draw_bezier_curve(int num_segments, control_point p[], int num_points)
{
    float x, y;

    glBegin(GL_LINE_STRIP);

    // start line
    glVertex2f(p[0].x, p[0].y);

    // calculate and draw points in the middle
    for (int i = 1; i < num_segments; i++) {
        evaluate_bezier_curve(&x, &y, p, num_points, i / (float) num_segments);
        glVertex2f(x, y);
    }

    // end line
    glVertex2f(p[num_points - 1].x, p[num_points - 1].y);
    glEnd();

}
Exemple #3
0
/*
 * get x_value for certain u
 */
float get_x_value(float *x_u, float *y_u, control_point p[], float u)
{
    evaluate_bezier_curve(x_u, y_u, p, 4, u);
    return *x_u;
}