Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 8

Assignment on

Drawing Bezier
Curves

Submitted To Submitted By

[4/19/16, 10:20 PM] Devender Narwal: Dr. (Mrs.) Shuchita


Upadhyaya Devender Kumar

DCSA, KUK
MCA 4thSem

Roll No. 129

Department of Computer Science & Applications


KURUKSHETRA UNIVERSITY KURUKSHETRA
BEZIER CURVES
In general, a Bezier curve section can be fitted to any number of control
points. The number of control points to be approximated and their relative
position determine the degree of the Bezier polynomial. As with the
interpolation splines, a Bezier curve can be specified with boundary
conditions, with a characterizing matrix, or with blending functions. For
general Bezier curves, the blending-function specification is the most
convenient.

Suppose we are given n + 1 control-point positions: P k = (Xk, Yk, Zk),


with k varying from 0 to n. These coordinate points can be blended to
produce the following position vector P(u), which describes the path of an
approximating BCzier polynomial function between P0 and Pn.

The Bezier blending functions


BEZkn(u) are the Bemstein polynomials:

Where the C (n, k) are the binomial coefficients:

Equivalently, we
can define Bezier blending functions with the recursive calculation

With BE& Vector equation represents a set of three parametric equations


for the individual curve coordinates:

As a rule, a Bezier curve is a polynomial of degree one less than the


number of control points used: Three points generate a parabola, four
points a cubic curve, and so forth. Figure 10-34 demonstrates the
appearance of some Bezier curves for various selections of control points
in the xy plane (z = 0). With certain control-point placements, however,
we obtain degenerate Bezier polynomials. For example, a Bezier curve
generated with three collinear control points is a straight-line segment.
And a set of control points that are all at the same coordinate position
produces a B6zier "curve" that is a single point.

Bezier curves are commonly found in painting and drawing


packages, as well as CAD systems, since they are easy to implement and
they are reasonably powerful in curve design. Efficient methods for
determining coordinate positions along a Bezier curve can be set up using
recursive calculations. For example, successive binomial coefficients can
be calculated as

Examples of two-dimensional Bezier curves generated from three, four,


and five control points. Dashed lines connect the control-point positions

For n>- k. The following example program illustrates a method for


generating Bezier curves:

#include <math.h>
#include graphics.h

void computeCoefficients (int n, int * c)

Int k , i;

for (k=O; k<=n: k++) {

/* Compute n! / (k! (n-k) !) */

c[kl = 1;

for (i=n; i >= k+l; i)

c|k| * = i ;

for (i = n-k; i>=2; i--) {

c|k| = i ;

void computepoint

((float u, wcPt3 * pt , int ncontrols , wcPt2 * controls , int * c )

int k , n = n Controls -1 ;

float blend;

pt->x = 0.0; pt->y = 0.0 ; pt->z = 0.0 ;

/* Add in influence of each control point */

for (k=O; k< ncontrols; k++) {

blend = c lkl * powf (u,k) * powf (1-u,n-k);

pt->x + = controls |k| .x * blend;


pt-> y += controls |k| .y * blend;

pt->z + = controls |k|.z * blend;

void Bezier (wcPt3 * controls, int nControls, int m, wcPt3 * curve)

/* Allocate space for the coefficients */

Int * c = (int * ) malloc (ncontrols * sizeof (int));

int i;

computeCoefficients (ncontrols-I, c);

for (i=O; i <= m; i++)

computePoint (i / (float) m, &curve [i] ,n Controls, controls, c );

free (c);

Properties Bezier Curves


1. Degree of polynomial blending function and thus Bezier curve is one
less than number of control points.
2. Bezier Curves always passes through first control point P0 and last
control point Pn irrespective of intermediate points (P1,P2,--------------
Pn-1).
3. Bezier Blending functions are all positive and their sum is always
equal to 1.
4. Bezier curves always lies with convex hull of the control points.
5. First derivatives of the Bezier Curve at the end points can be
calculated from control points coordinates as
P (0) = -np0 +np1
P (1) = - npn-1 + nPn
6. Bezier curves can be translated and rotated by performing these
operations on the control points.
Undesirable Properties of Bezier Curves
1. Numerical Instability for large number of control points.
2. Moving a single control point changes the global shape of the curve.

Points to Remember
The Curve, in general, does not pass through any of the control
points except the first and last. From the formula B(0)= P0 and
B(1)= Pn.
The Curve is always contained within the convex hull of the
control points, it never oscillates wildly away from the control
points.
If there is only one control point P0, i.e. N= 0 then B(u) = P0 for
all u.
If there are only two control points P0 and P1, i.e. N= 1 then the
formula reduces to a line segment between the two control
points.
The blending function is always a polynomial one degree less
than the number of control points. Thus, 3 controls points result
in a parabola, 4 control points a cubic curve etc.
Closed curve can be generated by making the last control point
the same as the first control point. First order continuity can be
achieved by ensuring the tangent between the first two points
and the last two points are the same.
Adding multiple control points at a single position in space will
add more weight to that point pulling the Bezier curve towards
it.

Tangents on Bezier Curve


Equation of cubic Bezier curve is

P (t) = (-t3 + 3t2-3t +1) P0 + (3t3-6t2+3t) P1+ (-3t3+3t2) P2+t3P3

The value of parametric tangent vector is obtained by differentiating P(t)


at any point t and given by:

P (t) = (-3t2 +6t-3) P0 + (9t2-12t+3) P1+ (-9t2+6t) P2+3t2P3

P (t) (t=0) = 3 (P1-P0)

P (t) (t=1) = 3 (P3-P2)

P (0) = 6(P0-2P1+P2)

P (1) = 6(P3-2P2+P1)

In general, Bezier Curve of degree n, the parametric first derivatives at


the end points are given by

P (0) = n (P1-P0)
P (1) = (Pn-Pn-1)

Second derivatives of the nth degree Bezier curve at the end points
can be calculated as

P (0) = n (n-1) (P0-2P1+P2)

=n (n-1) (P2-P1) (P1-P0)

P (1) = n (n-1) (P0-2Pn-1+Pn-2)

=n (n-1) (Pn-2-Pn-1)-(Pn-1-Pn)

Rational Bezier Curve


A rational Bezier curve is defined by

xi=0 Bi.P (t)WiPi

C(t)= ___________________
i=0 Bi.P(t)Wi

Where, P is the order , Bip are the Bernstein polynomials , Pi are


control points, and the weight Wi of Pi is the last ordinate of the
homogeneous point Pi ..These curves are closed under perspective
transformation, and can represent conic sections exactly.

You might also like