Bezier Curve Notes Two-D Surfaces
Bezier Curve Notes Two-D Surfaces
Two-D Surfaces
In the middle 1960’s, P.E. Bezier of Renault, the major French automobile manufacturer,
developed a curve “fitting” method which works for two or three dimensions equally
well. The Bezier curve allows the user a feel for the relation between input and output.
This enables him/her to use the program as an artist, stylist, or designer, varying curve
shape and order by the use of easily controlled parameters until the output matches the
desired shape.
A Bezier curve is associated with the “vertices” of a polygon which uniquely define the
curve shape. Only the first and last vertices of the polygon actually lie on the curve;
however, the other vertices of the polygon define the derivatives, order, and shape of the
curve. Some screen shots of Bezier curves appear below.
Look at each of the figures carefully. The following observations can be made:
• Notice that in each of the figures, the Bezier curve goes through the first and last
points.
• Note further the shape of the curve at the first and last points. The line segment
from the first point to the second point is actually tangent to the Bezier curve at
the first point.
• Also, the line segment from the next to last point to the last point is tangent to the
Bezier curve at the last point.
• Lastly, the Bezier curve always lies within the convex hull of the control point.
The convex hull of the control points can be envisioned by imagining a rubber
band stretched around the positions of the control points so that each control point
is either on the perimeter of the hull or inside it. The convex hull provides a
measure for the deviation of a curve from the region bounding the control point.
Since the curve shape tends to follow the polygon shape, changing the vertices of this
polygon gives the user a much greater intuitive feel for the input/output relationships. All
that is necessary to increase the order of any curve segment is to specify another vertex.
The Bezier polynomial is related to the Bernstein polynomial. Thus the Bezier curve is
said to have a Bernstein basis. The basis function is given by
J N ,i (t ) = ( )t (1 − t )
N
i
i N −i
where
( ) = i!( NN−
N
i
!
i )!
N is the degree of the polynomial (or the number of points – 1) and i is the particular
vertex in the ordered set (from 0 to N). The vertices are P0, P1, . . ., PN where Pi = (xi, yi,
zi) or Pi = (xi, yi) depending on whether the curve is to be two or three dimensions. The
curve points are given by
N
∑P J
i =0
i N ,i
(t ) 0<t<1
If instead, we first transform the original control point Pi using the transformation
to obtain a new set of control points Pi' then determine the Bezier curve B2(t) to
this new set of points, then affine invariant means B1(t) = B2(t).
6. The Bezier curve has the variation-diminishing property. No straight line can
have more intersections with a Bezier curve than it has with the curve’s control
polygon. (See page 616).
OpenGL supports Bezier curves and surfaces through mechanisms called evaluators
that are used to compute values for the Bernstein Polynomials of any order.
Evaluators can be used to generate two and three dimensional curves and surfaces.
The OpenGL evaluator functions can also provide colors, normals, and texture
coordinates.
where type is the type of objects we wish to evaluate using Bezier polynomials. This
could be three & four dimensional points, normals, or texture coordinates.
stride – is the number of floats between the beginning of one control point and the
beginning of the next one
order is the number of control points (always one more than the degree of the
polynomial).
Multiple evaluators can be defined and be active at the same time to evaluate curves
and normals.
void init(void)
{
glClearColor(0.0, 0.0, 0.0, 0.0);
glShadeModel(GL_FLAT);
//define the evaluator for the Bezier curve and enable the evaluator
glMap1f(GL_MAP1_VERTEX_3, 0.0, 1.0, 3, 4, &ctrlpoints[0][0]);
glEnable(GL_MAP1_VERTEX_3);
}
Once an evaluator has been set up, whenever we need a value from the active evaluators,
we use the function
glEvalCoord1f(t);
glBegin(GL_LINE_STRIP);
for (i = 0; i <= 30; i++)
glEvalCoord1f((GLfloat) i/30.0);
glEnd();
As an alternative, we can use a function that will set up a uniform grid of points:
//set up a grid of 30 points from 0.0 to 1.0 inclusive
glMapGrid1f(30, 0.0, 1.0);
and then ask for OpenGl to draw the Bezier curve using this mesh:
glEvalMesh1(GL_LINE_STRIP, 0, 30);