curves
DESCRIPTION
TRANSCRIPT
1
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 1
Unit 2Bezier Curves & Surfaces
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 2
Learning ObjectivesIn this unit, we will cover the following topics:
CurvesProblems with complex curveBezier CurveAdvantagesCubic Bezier CurvesB Splines More About B Splines
Knot VectorKinds of Knot VectorExerciseSummary
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 3
Curves?
Straight lines are easy to store in a computer’s memory. The computer only has to remember the first and the last point. But what about curved lines?
2
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 4
Computers can’t draw curves
Curves are just lots of small straight lines joined upThe more points/line segments that are used the smoother the curve.
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 5
Curve representation
The basic problem we face is to represent the curve EASILY and EFFICIENTLY.
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 6
Curve representation (contd.)Storing a curve as many small straight line segments
doesn’t work well when scaledinconvenient to have to specify so many pointsneed lots of points to make the curve look smooth
3
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 7
Curve representation (contd.)working out the equation that represents the curve
difficult for complex curvesmoving an individual point requires re-calculation of the entire
curve
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 8
SOLUTION ???
Complex Curves
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 9
Solution For Complex Curves
INTERPOLATION
APPROXIMATION
4
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 10
Interpolation vs. Approximation Curves
Interpolationcurve must pass through control points
Approximationcurve is influenced by control points
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 11
Review of InterpolationA method of constructing a function that crosses through a discrete set of known data points.
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 12
Interpolation vs. Approximation Curves
5
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 13
Solution - InterpolationDefine a small number of pointsUse a technique called “interpolation” to invent the extra points for us.Join the points with a series of (short) straight lines
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 14
Interpolation CurvesCurve is constrained to pass through all control pointsGiven points P0, P1, ... Pn, find lowest degree polynomial which passes through the points
x(t) = an-1tn-1 + .... + a2t2 + a1t + a0y(t) = bn-1tn-1 + .... + b2t2 + b1t + b0
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 15
Bezier Curves
An alternative to interpolation splinesM. Bezier was a French mathematician who worked for the Renault motor car company.He invented his curves to allow his firm’s computers to describe the shape of car bodies.
6
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 16
Curves & Control PointsBezier curves are used in computer graphics to produce curves which appear reasonably smooth at all scales.Bezier curves use a construction due to Sergei Bernstein, in which the interpolating polynomials depend on certain control points.
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 17
Example : Curves & Control Points
Each set of four points P0, P1, P2, P3 we associate a curve with the following properties: It starts at p0 and ends at p3. When it starts from p0 it heads directly towards p1, and when it
arrives at p3 it is coming from the direction of p2. The entire curve is contained in the quadrilateral whose corners
are the four given points
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 18
Bezier Curves
7
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 19
Bezier Curves- PropertiesNot all of the control points are on the line– Some just attract it towards themselvesPoints have “influence” over the course of the line
“Influence” (attraction) is calculated from a polynomial expression
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 20
Bezier CurvesN+1 control points designated by the vectorspk = (xk,yk,zk) k=0,…n
Thr order n Bezier Curve P(u) is given byP(u) = ∑pk Bk,,n(u) k= 0 to n
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 21
Problems with Bezier Curves
A similar but different problem:Controlling the shape of curves.
Problem: given some (control) points, produce and modify the shape of a curve passing through the first and last point.
http://www.ibiblio.org/e-notes/Splines/Bezier.htm
8
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 22
SolutionIdea: Build functions that are combinations of some basic and
simpler functions.
Basic functions: B-splinesBernstein polynomials
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 23
Bernstein PolynomialsBernstein polynomials of degree n are defined by:
For v = 0, 1, 2, …, n, In general there are N+1 Bernstein Polynomials of degree N.
For example, the Bernstein Polynomials of degrees 1, 2, and 3 are:
1. B0,1(t) = 1-t, B1,1(t) = t;2. B0,2(t) = (1-t)2, B1,2(t) = 2t(1-t), B2,2(t) = t2;3. B0,3(t) = (1-t)3, B1,3(t) = 3t(1-t)2, B2,3(t)=3t2(1-t), B3,3(t) = t3;
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 24
Deriving the Basis Polynomials
Write 1 = t + (1-t) and raise 1 to the third power for cubic splines (2 for quadratic, 4 for quartic, etc…)1^3 = (t + (1-t))^3 = t^3 + 3t^2(1-t) + 3t(1-t)^2 + (1-t)^3
The basis functions are the four terms:B0(t) = (1-t)^3
B1(t) = 3t(1-t)^2B2(t) = 3t^2(1-t)
B3(t) = t^3
9
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 25
Using the Basis Functions
To use the Bernstein basis functions to make a spline we need 4 “control” points for a cubic. (3 for quadratic, 5 for quartic, etc…)
Let (x0,y0), (x1,y1), (x2,y2), (x3,y3) be the “control”pointsThe x and y coordinates of the cubic Bezier spline are given
by:x(t) = x0B0(t) + x1B1(t) +x2B2(t) + x3B3(t)y(t) = y0B0(t) + y1B1(t) + y2B2(t) + y3B3(t)Where 0<= t <= 1.
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 26
Bernstein PolynomialsGiven a set of control points {Pi}N
i=0, where Pi = (xi, yi). A Bezier curve of degree N is:
P(t) = Ni=0 PiBi,N(t),Where Bi,N(t), for I = 0, 1, …, N, are the Bernstein
polynomials of degree N.P(t) is the Bezier curve
Since Pi = (xi, yi)x(t) = Ni=0xiBi,N(t) and y(t) = Ni=0yiBi,N(t)The spline goes through (x0,y0) and (x3,y3)The tangent at those points is the line connecting (x0,y0) to (x1,y1) and (x3,y3) to (x2,y2).The positions of (x1,y1) and (x2,y2) determine the shape of the curve.
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 27
Bernstein Polynomials Example
Find the Bezier curve which has the control points (2,2), (1,1.5), (3.5,0), (4,1). Substituting the x- and y-coordinates of the control points and N=3 into the x(t) and y(t) formulas on the previous slide yields
x(t) = 2B0,3(t) + 1B1,3(t) + 3.5B2,3(t) + 4B3,3(t)y(t) = 2B0,3(t) + 1.5B1,3(t) + 0B2,3(t) + 1B3,3(t)
10
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 28
Bernstein Polynomials Example
Substitute the Bernstein polynomials of degree three into these formulas to get
x(t) = 2(1 – t)3 + 3t(1 – t)2 + 10.5t2(1 – t) + 4t3
y(t) = 2(1-t)3 + 4.5t(1 – t)2 + t3
Simplify these formulas to yield the parametric equation:P(t) = (2 – 3t + 10.5t2 – 5.5t3, 2 – 1.5t – 3t2 + 3.5t3)
where 0 < t < 1P(t) is the Bezier curve
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 29
Cubic Bézier Curve4 control pointsCurve passes through first & last control pointCurve is tangent at P1 to (P1-P2) and at P4 to (P4-P3)
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 30
Cubic Bézier Curve
11
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 31
Cubic Bézier Curve
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 32
Higher-Order Bézier Curves> 4 control pointsBernstein Polynomials as the basis functionsBin(t) is Blending Function
Every control point affects the entire curve– Not simply a local effect- More difficult to control for modeling
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 33
Composite Bezier Curves
In practice, shapes are often constructed of multiple Bezier curves combined together.
Allows for flexibility in constructing shapes. (Consecutive Bezier curves need not join smoothly.)
12
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 34
Parametric equations for x(t),y(t)
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 35
Higher-Order Bézier Curves
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 36
Properties of Bezier CurvesThe degree of the bezier curve is one less than the number of control point defining it.N=control point-1The curve generally follows the shape of the defining polygon (i.e. polygon formed by connecting the control points.)
13
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 37
Advantages of Bezier Curves
The Bezier Curve is always contained within the convex hull of its control points. This is extremely useful for collision detection, because a bounding box to the Bezier curve’s control points can be created very fast.
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 38
More About BezierIf we map every point on the Bezier curve with an affine map, the resulting points also form a Bezier curve. This is extremely useful in computer graphics, because if we have a curve in 3D-space and need to project it on a surface, the only thing we have to do is to project each control point. The same goes for rotation, mirroring, skewing etc.
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 39
More About Bezier (Cont’d)If we change a control point, the curve will mostly change around that control point. The other parts of the curve will change very little. This is one reason Bezier curves are used in CAD.If you change one control point a little, you don’t want the whole
drawing to change.
14
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 40
B SPLINE CURVES
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 41
An Introduction to B-Spline Curves
Most shapes are simply too complicated to define using a single Bezier curve.
A spline curve is a sequence of curve segments that are connected together to form a single continuous curve.
Example, a piecewise collection of Bezier curves, connected end to end, can be called a spline curve
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 42
History behind Splines
The word “spline” comes from the ship building industry, where it originally meant a thin strip of wood which draftsmen would use like a flexible French curve.Metal weights (called “ducks”) were placed on the drawing surface and the spline was threaded between the ducks as in Figure .
15
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 43
Splines
Smooth curve defined by some control points
Moving the control points changes the curve
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 44
Definition
A B-spline is defined by an ordered set of control points which determines what path the curve will follow and consequently how the curve will look. A longer B-spline is actually made up of several curve segments, each one of which is defined by some number of control points inits vicinity
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 45
Spline (general case)
Given n+1 distinct knots xi such that:
with n+1 knot values yi find a spline function
with each Si(x) a polynomial of degree at most n.
16
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 46
Spline InterpolationLinear, Quadratic, Cubic
Preferred over other polynomial interpolationMore efficient
High-degree polynomials are very computationally expensive Smaller errorInterpolant is smoother
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 47
Natural Cubic Spline Interpolation
Si(x) = aix3 + bix2 + cix + di
4 Coefficients with n subintervals = 4n equationsThere are 4n-2 conditions
Interpolation conditionsContinuity conditionsNatural Conditions
S’’(x0) = 0S’’(xn) = 0
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 48
Natural Conditions
17
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 49
Weighting factor in Splines
A point on a particular curve segment is calculated by simply adding up the coordinate values of its defining control points after they have been multiplied by a weighting factor. The weighting factor is calculated using a set of parametric basis or blending functions.
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 50
Spline NotationA B-spline curve P(t), is defined by
Where • the {Pi : i = 0, 1, ..., n} are the control points• k is the order of the polynomial segments of the B-spline curve.
Order k means that the curve is made up of piecewise polynomial segments of degree k − 1
• The Ni, k(t) are the “normalized B-spline blending functions”. They are described by the order k and by a non-decreasing sequence of real numbers {ti : i = 0, ..., n + k}normally called the “knot sequence”.
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 51
Functions used in B SplinesThe Ni,k functions are described as follows
and if k > 1
18
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 52
Properties of B-Spline
For n+1 control points the curve is described with n +1 blendingfunctions.Each blending function Bk,d is defined over d subintervals of the total range of u, starting at knot value uk.The range of parameter u is divided into n + d ,subintervals by the n + d + 1 values specified in the knot vector.
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 53
Properties (Cont’d..)Each section of the spline curve ( between 2 successive knot values) is influenced by d control points.Any one control point can affect the shape of at most d curve sections.
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 54
CUBIC B SPLINEIterative method for constructing BSplines
19
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 55
Knot VectorA knot vector is a list of parameter values, or knots, that specify the parameter intervals for the individual Bezier curves that make up a B-spline.
The knot vector can, by its definition, be any sequence of numbers provided that each one is greater than or equal to the precedingone.
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 56
Example : Knot VectorFor example, the knot vector in Figure would be [t0, 1, 2, 3, 4, 5, 6,
7, 8, t9], where the values of t0 and t9 have absolutely no effect on the curve.
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 57
Uniform Knot VectorA B-spline curve whose knot vector is evenly spaced is known as a uniform B-spline.These are knot vectors for which
For example:
20
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 58
Open Uniform Knot VectorIf any knot value is repeated,it is referred to as a multiple knot. Also known as open Uniform knot vector. For example:
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 59
Non-uniform Knot VectorIf the knot vector is not evenly spaced, the curve is called a non-
uniform B-spline . Here
For example:
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 60
Example: 5 Control PointsThe picture below shows a set of 5 control points (so n+1=5), and two separate B-Spline curves through them. The red curve has k=3, while the blue curve has k=4. The knot vector used was uniform. In the case with k=3, there are n+k+1=8 knots: 0,1,2,3,4,5,6,7, while in the case with k=4, there are 9 knots: 0,1,2,3,4,5,6,7,8.
21
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 61
Why use BsplinesB-spline curves require more information (i.e., the degree of the curve and a knot vector) and a more complex theory than Bezier curves. But, it has more advantages:B-spline curve can be a Bézier curve.B-spline curves satisfy all important properties that Bézier curves have.B-spline curves provide more control flexibility than Bézier curves can do. For example, the degree of a B-spline curve is separated from the number of control points. More precisely, we can use lower degree curves and still maintain a large number of control points.
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 62
Bézier Surfaces
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 63
SummaryA Curve is specified by set of points called the control point.The shape of the curve should not get affected when the control points are measured.The control points control the shape interactively and hence a designer tries to manipulate the shape of the curve by moving the control points in a neighborhood.Most shapes are simply too complicated to define using a single
Bezier curve. A spline curve is a sequence of curve segments that are connected
together to form a single continuous curve. Blending functions are a set of functions which are used to
represent curve.Knot Vector specify the parameter intervals for the individual Bezier curves that make up a B-spline.
22
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 64
Exercise
Q.1 Multiple Choice Questionsa) The following knot vector [0, 0, 0, 0, 1 , 2, 2, 2, 2] represents(A) Bezier spline (B) open uniform B-spline(C) Periodic B-spline (D) Non-uniform B-spline
b) A B-spline curve with (n+1) blending function has(A) n control points. (B) (n+1) control points.(C) (n-1) control points. (D) n2 control points.
c) For which of the curves it is easier to compute basis functions. (A) Bezier curves. (B) open B-spline.(C) Uniform B-spline. (D) periodic B-spline
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 65
Exercise (Cont’d..)d) Which one of the following is one of the blending functions for
Bezier curve (cubic)?(A) 3u2 (B) u2(C) 3u3 (D) u (1-u)2
e) State True/False “For n + 1 control points, the B-spline curve is described with n blending functions”.
f) For second order parametric continuity in Bezier curves withcontrol points and where , we must have
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 66
Exercise (Cont’d..)Q.2 Attempt all questions:a.‘Bezier Curve do not allow for local control of the curve shape’.
Justify.b. Give the blending functions for uniform quadratic B-spline with
knot vectors [0, 1, 2, 3, 4, 5, 6]
c. What are the boundary conditions for periodic cubic splines with four control points?
d. What do you understand by C1 and C2 continuity between two cubic Bezier segments? Derive the conditions for the same in terms of control point of the two cubic Bezier curve segments.
e. Define B-spline. What do you mean by knot vector?
23
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 67
Exercise (Cont’d..)
f. In computer graphics, why do we prefer parametric representation of curves?
g. What do you mean by knot vector? What are various types of knot vectors?
h. Give the general expression for B-spline curve defined by Cox-de-Boor. Give also the characterstics of B-splinecurve.
i. Write the blending functions of cubic Bezier curves. Draw their curves also.
j Draw a Bezier curve by hand with four control points P1, P2, P3, P4