You are on page 1of 11

ELLIPSES & CURVES

Dr. SHUCHITA UPADHYAYA BHASIN


Professor
Department of Computer Science & Applications
GENERATION OF ELLIPSE
Polynomial Method of Defining an Ellipse
• The equation of the ellipse can be written in
terms of the ellipse center coordinates and
parameters as:
(𝒙 𝒉)𝟐 (𝒚 𝒌)𝟐
+ =1
𝒂𝟐 𝒃𝟐
• Where (h, k) is the center of the ellipse and a
and b are the lengths of major and minor axis
 This method is very
• When the polynomial method is used to inefficient, however, because
define an ellipse, the value of x is the squares of a and (x – h)
incremented from h to (h + a) in unit steps. must be found;
• For each step of x, each value of y is found by  then floating point division of
evaluating the expression; (x – h)2 by a2 and floating –
𝒙 𝒉)𝟐 point multiplication of the
y=b +k square root of [ 1 – (x – h)2 /
𝒂𝟐
By Dr. Shuchita Upadhyaya Bhasin
a2] by b must be performed.
Ellipse Drawing Using Polar Coordinates
• A second method of defining an ellipse
makes use of trigonometric
relationship. The following equations
define an ellipse trigonometrically using
polar coordinates.
x = a cos (θ) + h
y = b sin (θ) + k
• where (x,y) = the current coordinate
lying on the circumference of the  The value of θ is varied from 0 to π/2
ellipse
radians.
a = length of major axis  The remaining points are found by symmetry.
b = length of minor axis  this method is also inefficient and generally
θ = current angle too slow for interactive applications,
(h,k) = ellipse center
By Dr. Shuchita Upadhyaya Bhasin
PARAMETRIC REPRESENTATION OF CUBIC CURVES
• A curve is an infinitely large set of points Parametric Curves
Types of Curves • Curves having parametric form are called parametric
Curves can be broadly classified into three categories curves.
 explicit • Parametric curve descriptions provide a mapping from a
 implicit free parameter to the set of points on the curve. That is,
 parametric this free parameter (a single number) provides an index
to the points on the curve. The parametric form of a
Parametric representations are the most common in computer curve defines a function that assigns positions to values
graphics and will be the focus of our discussion. of the free parameter.
x, y = f (t).
Implicit curves
• A two-dimensional parametric curve has the following
Implicit curve representations define the set of points on a curve by form −
giving a procedure that can test to see if a point in on the curve.
Usually, an implicit curve is defined by an implicit function of the • Q(t) = x(t), y(t)
form:
• The points are obtained when the parameter t is varied
f(x, y) = 0 over a certain interval [a, b], normally [0, 1].
so that the curve is the set of points for which this equation is true. • Two univariate functions define a parametric curve in 2D
A common example is the circle, whose implicit representation is while three univariate functions are necessary in 3D.
x2 + y2 - r2 = 0 • 3D Curve: Q(t) = (X(t), Y(t), Z(t))
Explicit Curves • 2D Curve: Q(t) = (X(t), Y(t)), 0 ≤ t ≤ 1
A mathematical function y = f(x) can be plotted as a curve. Such a • As t varies from 0 to 1, the functions sweep out the
function is the explicit representation of the curve. More generally, curve. [sometimes u is used in place of t to represent the
any curve given by an explicit equation parameter]
y = f(x)
By Dr. Shuchita Upadhyaya Bhasin
Cubic curves BEZIER CURVES
The parametric curve is usually a polynomial or • A Bezier curve is a parametric curve
rational polynomial. A polynomial of order k + 1 which frequently used in computer graphics and
contains terms up to and including those of degree k is related fields.
Q(t) = 𝒑𝟎 + 𝒑𝟏 t + 𝒑𝟐 t2 + … + 𝒑𝒌 tk 0≤ t≤ 1 • In order to draw things in 2D, we usually
rely on lines, which typically get classified
The widely used degree of polynomials in computer into two categories: straight lines, and
graphics is 3 i.e. it is cubic
curves. The first of these are as easy to draw
For a curve Q(t) to exist and be represented with a as they are easy to make a computer draw.
polynomial of degree n, at least (n-1) points are Give a computer the first and last point in
required to solve the polynomial. the line, and you get a straight line.
𝟑
Q(t) = 𝟎 𝒊 𝒊 0≤ t≤ 1 • Curves, however, are a much bigger
Where pi is the control point and Bi(t) is the basis problem. While we can draw curves easily
function. Basis functions are a set of linearly with freehand, computers can't draw curves
independent polynomials and referring to equation , unless there is a mathematical function that
we have describes how it should be drawn. There are
a number of functions to draw curves using
Bi(t) = t i 0≤ t≤ 1 a computer but we'll focus on "Bézier"
-
curves
By Dr. Shuchita Upadhyaya Bhasin
BEZIER CURVES
• They run from some start point to some end point, with their curvature • To create a smooth curve, one intuitive
influenced by one or more "intermediate" control points.
• In general, a Bezier curve section can be fitted to any number of control
mechanism is to first connect the four
points. The number of control points to be approximated and their control points with lines. Then draw
relative position determine the degree of the Bezier polynomial.
• A Bezier curve can be specified with blending function (basis function).
new lines connecting the midpoints of
• A Bezier curve is defined by a set of control points P0 through Pn, where those lines, and more new lines to
n is called its order (n = 1 for linear, 2 for quadratic, etc.) connect the midpoints of the new lines,
• The first and last control points are always the end points of the curve; and so forth until the resulting curve is
however, the intermediate control points (if any) generally do not lie on
the curve. sufficiently smooth.
• Bezier curves are the result of linear interpolations. It's simply "picking a
point between two, points".
• If we know the distance between those two points, and we want a new
point that is, say, 20% the distance away from the first point (and thus
80% the distance away from the second point) then we can compute that
easily:
𝒑𝟏 = 𝒔𝒐𝒎𝒆 𝒑𝒐𝒊𝒏𝒕
𝒑𝟐 = 𝒔𝒐𝒎𝒆 𝒐𝒕𝒉𝒆𝒓 𝒑𝒐𝒊𝒏𝒕
Given 𝒅𝒊𝒔𝒕𝒂𝒏𝒄𝒆 = 𝒑𝟐 − 𝒑𝟏 , our new point = p1+ distance • ratio
𝒑𝒆𝒓𝒄𝒆𝒏𝒕𝒂𝒈𝒆
𝒓𝒂𝒕𝒊𝒐 =
𝟏𝟎𝟎

By Dr. Shuchita Upadhyaya Bhasin


BEZIER CURVES
3 control points (quadratic)
• The deciding factor in choosing Bézier
curves is a recursive property that makes
them extremely efficient to compute.
• Suppose we are given a Bézier curve with
control points Pi.
• Let's now divide it up into two halves,
with P012 = B(1/2).
• Let P01 be the point midway
between P0 and P1 , P12 be that midway
between P1 and P2 . 4 control points (cubic)
• In these circumstances:
 (1) the point P012 is the point midway
between P01 and P12 ;
(2) the half curve between P0 and the
midpoint P012 is again a quadratic Bézier
curve with control points P0 , P01 , and P012.
Similar will be the case for the second half

By Dr. Shuchita Upadhyaya Bhasin


Linear Bezier curves (two control points)- Quadratic curves-
• Given points P0 and P1, a linear Bezier curve is simply A quadratic Bézier curve is the path traced by the function B(t),
a straight line between those two points. The curve is given points P0, P1, and P2,
given by
B(t)= (1-t) [ (1-t)P0+ t. P1 ] + t [(1-t)P1+ t. P2 ] 0≤ t≤1
B(t)=P0 + t.(P1-P0) = (1-t)P0+ t. P1 0<=t<=1
• And is equivalent to linear interpolation. which can be interpreted as the linear interpolant of
corresponding points on the linear Bézier curves
• The t in the function for a linear Bézier curve can be
from P0 to P1 and from P1 to P2 respectively. Rearranging the
thought of as describing how far B(t) is from P0 to P1.
For example, when t = 0.25, B(t) is one quarter of the preceding equation yields:
way from point P0 to P1. As t varies from 0 to 1, B(t) B(t)= (1 – t)2P0 + 2.(1 – t) t.P1 + t2.P2 0≤ t≤ 1
describes a straight line from P0 to P1. For quadratic Bézier curves one can construct intermediate
points Q0 and Q1 such that as t varies from 0 to 1:
 Point Q0(t) varies from P0 to P1 and describes a
Simple Bezier Curve (linear) Quadratic Bezier Curve linear Bézier curve.
 Point Q1(t) varies from P1 to P2 and describes a
linear Bézier curve.
 Point B(t) is interpolated linearly between Q0(t)
to Q1(t) and describes a quadratic Bézier curve.

By Dr. Shuchita Upadhyaya Bhasin


Cubic Bezier Curves: The explicit form of the curve is:
• Four points P0, P1, P2 and P3 in the plane or
in higher-dimensional space define a cubic B(t)= (1 – t) .P0 + 3. t (1 – t) .P1 + 3 t (1-t)P2 + t .P3
3 2 2 3

Bézier curve. 0<=t<=1


• The curve starts at P0 going toward P1 and
arrives at P3 coming from the direction
of P2.
• Usually, it will not pass through P1 or P2;
these points are only there to provide
directional information.
• The distance between P0 and P1 determines
"how far" and "how fast" the curve moves
towards P1 before turning towards P2.
• For cubic curves one can construct
intermediate points Q0, Q1, and Q2 that
describe linear Bezier curves, and points R0
& R1 that describe quadratic Bezier curves:
By Dr. Shuchita Upadhyaya Bhasin
Generic Function for Bezier Curves
• Suppose we are given n + 1 control-point positions: Pi = (xi,
yi, zi), with i varying from 0 to n. These coordinate points
can be blended to produce the following position vector The blending functions take the forms:
P(t), which describes the path of an approximating Bezier
polynomial function between P0 and Pn. B0,3(t) = (1 - t)3
B1,3(t) = 3t(1 - t)2
• P(t) = ∑𝒏𝒊 𝟎 𝒑𝒊 𝑩𝒊,𝒏 (𝒕) 0≤ t≤ 1
B2,3(t ) = 3t2 (1 - t)
• For Bezier curves, pi is the control point while the Bezier
B3,3(t) = t3
basis Bi,n(t) is the blending function given by :
• Bi,n(t) = nCi t i (1 – t) n-i Equations for Bezier Curves
• The most efficient formulation for two-dimensional Bezier
Curves in the parametric form for the specific case of four
• Where the nCi are the binomial coefficients: control points (cubic) is:
x = x(t) = 𝒙𝟏 (1-t)3 + 3𝒙𝟐 .t(1-t)2 + 3 𝒙𝟑 .t2(1-t) + 𝒙𝟒 .t3 -
nC 𝒏!
• i = and
𝒊! 𝒏 𝒊 !
• For Bezier curves of degree 3 (cubic curve) the blending y = y(t) = 𝒚𝟏 (1-t)3 + 3𝒚𝟐 .t(1-t)2 + 3 𝒚𝟑 .t2(1-t) + 𝒚𝟒 .t3
function (basis function) given as above is :
where the parameter t varies from 0 to 1 to generate the entire
𝟑 curve
• P(t) = 𝒊 𝟎 𝒊 𝒊,𝟑

By Dr. Shuchita Upadhyaya Bhasin


Example of Bezier Curve Generation
Generate a Bezier curve to the four points (60,20), (80, 100),
(150, 90) and (180, 50). Pt. t x y

1 0.0 60.00 20.00

x = x(t) = 𝒙𝟏 (1-t)3 + 3𝒙𝟐 .t(1-t)2 + 3 𝒙𝟑 .t2(1-t) + 𝒙𝟒 .t3 - 2 0.1 67.41 41.36

y = y(t) = 𝒚𝟏 (1-t)3 + 3𝒚𝟐 .t(1-t)2 + 3 𝒚𝟑 .t2(1-t) + 𝒚𝟒 .t3 3 0.2 77.28 57.68

4 0.3 89.07 69.32

x = 60(1-t)3 + 3(80) . t(1-t)2 + 3(150) . t2(1-t) + 180 . t3 5 0.4 102.24 76.64

= 60 + 60t + 150 t2 – 90t3 6 0.5 116.25 80.00

7 0.6 130.56 79.76

And 8 0.7 144.63 76.28

y= 20(1 – t)3 + 3(100) . t(1 -t)2 + 3(90) . t2(1 - t) + 50 . t3 9 0.8 157.92 69.92

= 20 + 240t – 270 t2 + 60 t3 10 0.9 169.89 61.04

11 1.0 180.00 50.00

Now we will be able to generate as many points as are


necessary to define the curve for plotting or other purposes, by
assigning various values of parameter t ranging from 0 to 1.

By Dr. Shuchita Upadhyaya Bhasin

You might also like