0% found this document useful (0 votes)
169 views

Bezier Curve Notes Two-D Surfaces

The document discusses Bezier curves, which are smooth curves used in computer graphics and design. Bezier curves are defined by a set of control points that determine the shape and properties of the curve. OpenGL supports defining and drawing Bezier curves through evaluator functions that calculate points along the curve based on the control points. The document provides examples of how to set up Bezier curve evaluators and draw curves in OpenGL.

Uploaded by

Gp Love
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
169 views

Bezier Curve Notes Two-D Surfaces

The document discusses Bezier curves, which are smooth curves used in computer graphics and design. Bezier curves are defined by a set of control points that determine the shape and properties of the curve. OpenGL supports defining and drawing Bezier curves through evaluator functions that calculate points along the curve based on the control points. The document provides examples of how to set up Bezier curve evaluators and draw curves in OpenGL.

Uploaded by

Gp Love
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 4

Bezier Curve Notes

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

Properties of the Bezier curve:


1. The Bezier curve fits the first and last control point.
2. The Bezier curve is tangent to the line from P0 to P1 at t=0 and is tanget to the line
from PN-1 to PN at t = 1.
3. The Bezier curve satisfies the convex-hull property – it never wanders outside the
convex hull of the set of control points.
4. The Bezier curve can be a straight line.
5. The Bezier curve is affine invariant. What if we applied affine transformations
(scales, translations, and rotations) to it? This means that if we generate the
Bezier curve on the original points and then transform many points on the Bezier
curve using the transformation we would get a curve, say B1(t).

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.

For 2D curves, we define a one-dimensional evaluator by using the function:


glMap1f(type, tMin, tMax, stride, order, ctrlPtArray);

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.

tMin and tMax define the range of the parameter t.

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).

ctrlPtArray is an array containing the control points.

Multiple evaluators can be defined and be active at the same time to evaluate curves
and normals.

Each evaluator must be enabled through glEnable(type);


Example:
//define the control points of a Bezier curve of degree 3
GLfloat ctrlpoints[4][3] = {{ -4.0, -4.0, 0.0}, { -2.0, 4.0, 0.0},
{2.0, -4.0, 0.0}, {4.0, 4.0, 0.0}};

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);

Thus the following can be used to produce the curve


//plot the Bezier curve

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);

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy