Title: Modeling Curves and Surfaces
1Modeling Curves and Surfaces
2Motivation
- Need representations of smooth real world objects
- Art / drawings using CG need smooth curves
- Animation camera paths
- Character Paths
3Naïve approach
- Simply use lines polygons to approximate curves
surfaces(check out Paint!) - curve piecewise linear function
- lots of storage if accuracy desired
- hard to interactively manipulate the shape
- Instead, well use higher-order functions
- Note difference between stored model and
rendered shape
4Approaches
- Explicit Functions y f(x) e.g. y 2x2
- 1. Only one value of y for each x
- 2. Difficult to represent a slope of infinity
- Implicit Equations f(x,y) 0 e.g. x2 y2 -
r2 0 - 1. Need constraints to model just one part of a
curve - 2. Joining curves together smoothly is
difficult - Parametric Equations x f(t), y f(t) e.g.
x t23, y 3t22t1 - 1. Slopes represented as parametric tangent
vectors - 2. Easy to join curve segments smoothly
- See http//www.doc.ic.ac.uk/dfg/AndysSplineTutori
al/
5Parametric Curves
- Linear x axt bx
- y ayt by
- z azt bz
- Quadratic x axt2 bxt cx
- y ayt2 byt cy
- z azt2 bzt cz
- Cubic x axt3 bxt2 cxt dx
- y ayt3 byt2 cyt dy
- z azt3 bzt2 czt dz
0 t 1
6Joining Curve Segments Together
- G0 geometric continuity Two curve segments
join together - G1 geometric continuity The directions of
the two segments tangent vectors are equal at
the join point - C1 continuity Tangent vectors of the two
segments are equal in magnitude and direction - (C1 ? G1 unless tangent vector 0,0,0)
- Cn continuity Direction and magnitude through
the nth derivative are equal at the join point
7Joining Examples
Â
Â
R2
R1
R0
TV3
TV2
8Notation
- x axt3 bxt2 cxt dx
- y ayt3 byt2 cyt dy Q(t) T C
- z azt3 bzt2 czt dz
9Alternate Notation
- Q(t) T M G
-
- T Matrix Basis Matrix
Geometry Matrix - Idea Different curves can be specified by
changing the geometric information in the
geometry matrix. - The basis matrix contains information about the
general family of curve that will be produced.
10Example Parametric Line
- x(t) axt bx x'(t) ax
- y(t) ayt by y'(t) ay
- z(t) azt bz z'(t) az
11Example (cont.)
- Since two points, P1 P2 define a straight line,
then the geometry matrix should be - G1 P1 G2 P2.
- What is the basis matrix?
- We know that at t 0, Q(0) P1
- Q'(0) P2 - P1
- at t 1, Q(1) P2
- Q'(1) P2 - P1
-
t gt 1
t 1
t 0
P2
t lt 0
P1
12Example (cont.)
- Solve these 4 simultaneous equations to find the
basis matrix Mline - Q(0) (0, 1) Mline G P1
- Q'(0) (1, 0) Mline G P2 - P1
- Q(1) (1, 1) Mline G P2
- Q'(1) (1, 0) Mline G P2 - P1
13Example (cont.)
- m21x1 m22x2 x1 (m11 m21)x1 (m12 m22)x2
x2 - m21y1 m22y2 y1 (m11 m21)y1 (m12 m22)y2
y2 - m21z1 m22z2 z1 (m11 m21)z1 (m12 m22)z2
z2 - m11x1 m12x2 x2 - x1 m11 -1 m12 1
- m11y1 m12y2 y2 - y1 m21 1 m22 0
- m11z1 m12z2 z2 - z1
14Blending functions
- Multiplying the T and M matrices gives you a set
of functions in t these are called blending
functions. - There is one blending function for each of the
pieces of geometric information in the G matrix. - The value of a blending function at a certain
value of t determines the effect of the
corresponding piece of geometric information at
that point along the curve. - Line blending functions
f(t)
P1 fn.
1
P2 fn.
1
0
t
15Hermite Curves
Defined by two endpoints and tangents at the
endpoints.
R4
R1
P4
P1
16Hermite Curve Examples
17Hermite Curve Examples (cont.)
Demo
18Hermite Matrices
19 How do we calculate MH?
Assume the following.
20 Hermite Derivation Cont.
Converting to matrices we have Q(t)TC Not we
can also split C into a product of two matrices
C MHGH where G is the set of restrictions on
the curve
21 Tangent vectors ?
22 Recall Q(t)t3 t2 t 1MHGH
The two point restrictions yield the following
23 Tangent equations
The tangent restrictions yield the following
equations.
24 Stacking the four equations
25 Finding the inverse we have
Which result in the following blending functions
26Hermite Blending Functions
27 Piecewise Curve
- We can create a long continuous curve by
connecting multiple Hermite curves.
What goes on Here?
28 Another approach
- Here we will blend four points instead of two
points and two vectors. - The scheme will use an interesting method called
tweening in order to obtain points in between
other points.
29de Casteljau Algorithm (tweening)
Tweening three points to create a parabola
P1
P1
B
A
P
P
P0
P0
P2
P2
P(t) (1-t)A tB
A(t) (1-t)P0 tP1
substituting
B(t) (1-t)P1 tP2
P(t) (1-t)2 P0 2t(1-t)t P1 t2 P2
Blending functions are in green!
30 Tweening four points
P2
B
P1
E
C
P
D
A
t.3
P3
P0
A(t) (1-t)P0 tP1 B(t) (1-t)P1 tP2 C(t)
(1-t)P2 tP3 D(t) (1-t)A tB etc
Applying proper substitutions we
get (do this for homework!)
P(t)P0(1-t)3 P1 3(1-t)2t P2 3(1-t)t2 P3 t3
Blending functions are in green!
31Bernstein polynomials
The blending functions are known as the Bernstein
polynomials They exists for any number of points
but we will stay with four. They are closely
related to the well known Pascals triangle whose
third row is represented by
1 1 1 1 2 1 1 3 3 1 1 4 6 4 1
(a b)3 a3 3a2b 3ab2 b3 if a (1-t)
and b t we have (a b)3 (1-t)3 3(1-t)2t
3(1-t)t2 t3
32The Bernstein polynomials of degree 3
1
33Bézier Curves
34Bézier Matrices
- P1 P4 endpoints
- R1 3(P2-P1), R4 3(P4-P3)
- constant velocity curves if control points are
equally spaced
35Bézier Blending Functions
36General Bézier Curves
- Let P1 through Pn1 be points that define the
curve. Then - where
- Bi,n(t) C(n,i) ti (1-t)n-i Blending
functions - and
- C(n,i) n!/(i!(n-i)!) Binomial
coefficient
37General Bézier Curves (cont.)
- For two points, n 1
- QB(t) (1-t)P1 tP2
- For three points, n 2
- QB(t) (1-t)2P1 2t(1-t)P2 t2P3
- For four points, n 3
- QB(t) (1-t)3P1 3t(1-t)2P2 3t2(1-t)P3
t3P4
38Bézier Curve Characteristics
- 1. The functions interpolate the first and last
vertex points. - 2. The tangent at P0 is given by P1 - P0, and the
tangent at Pn by Pn - Pn-1. - 3. The blending functions are symmetric with
respect to t and (1-t). This means we can
reverse the sequence of vertex points defining
the curve without changing the shape of the
curve. - 4. The curve, Q(t), lies within the convex hull
defined by the control points. - 5. If the first and last vertices coincide, then
we produce a closed curve. - 6. If complicated curves are to be generated,
they can be formed by piecing together several
Bézier sections. - 7. By specifying multiple coincident points at a
vertex, we pull the curve in closer and closer to
that vertex.
39 B-Spline curves
- Bezier drawbacks
- Moving control points will affect the entire
Bezier curves. - A Bezier curve cannot use a cubic curve to
approximate or represent n points without the
inconvenience of using multiple curve segments
(or by increasing the degree of the curve. - Basically, Bezier curves do not provide enough
flexibility in curve design
40 B-Splines
- A B-spline is a complete piecewise cubic
polynomial consisting of any number of curve
segments. - A B-spline curve is a series of m-2 curve
segments that we label Q3,Q4,Qm ,defined by m1
control points P0,P1,,Pm, mgt3.
41 B-spline formulation
- These curve segments are defined as
Where Qi is the i-th B-spline segment and Pi is
the set of four points in a sequence of control
points
42 In other words
Where Bi-3k represents the blending functions.
i is the segment number and k is the local
control point index. The value of u over a
single curve segment is between 0 and 1. Each
segment is defined by four control points and
each control point influences four curve
segments.
43Types of B-Spline curves
- Uniform
- Here the blending functions are all the same.
- Nice for designing closed curves
- Non-Uniform
- The blending functions are different at each end
of the curve - Not closed
44Uniform B-Spline Demonstrator
45Cubic B-spline Blending
B1
B2
B0
B3
Q3
0 1 2 3 4 5 6 7
knots
46 Approximate Gaussian Curve
Bi(u)
ui ui1 ui2 ui3 ui4
47 Closed Uniform B-Splines
- Probably the best application for Uniform
B-Splines is when the curve is closed. - This is automatically created when the last
control point is continued on to the first
control point.
48Non-Uniform B-Splines
- In this case the distances between the knots are
allowed to vary. Recall in the case with uniform
this distance is set at one. - This is of course represented by the knot vector.
In the uniform case it was something like lt0 1 2
3 4 5 6 7gt - In the Non-Uniform case it may be something like
lt0 0 0 0 1 2 3 3 3 gt - Repeating the knot values changes the blending
functions so they are not all the same.
49 Non-Uniform B-Splines segments
Demo
curve
Control pts
Blending functions
50 What happens with 4 points
Note that the non- uniform cubic B-spline reduces
to the usual Bezier curves that we have already
studied
Bezier blending functions