Download presentation
Presentation is loading. Please wait.
Published byChester Sherman Modified over 6 years ago
1
Introduction to Parametric Curve and Surface Modeling
2
Motivation Parametric curves and surfaces are intended to provide the generality of polygon meshes but with fewer parameters for smooth surfaces Polygon meshes have as many parameters as there are vertices (at least) Fewer parameters makes it faster to create a curve, and easier to edit an existing curve Normal fields can be properly defined everywhere Parametric curves are easier to animate than polygon meshes
3
What is it? Mapping F :t → (x, y, z) Define a parameter space
1D for curves 2D for surfaces Define a mapping from parameter space to 3D points A function that takes parameter values and gives back 3D points The result is a parametric curve or surface Mapping F :t → (x, y, z) 1 t
4
Parametric Curves We have seen the parametric form for a line:
Note that x, y and z are each given by an equation that involves: The parameter t Some user specified control points, x0 and x1 This is an example of a parametric curve
5
Hermite Spline A spline is a parametric curve defined by control points The term spline dates from engineering drawing, where a spline was a piece of flexible wood used to draw smooth curves The control points are adjusted by the user to control the shape of the curve A Hermite spline is a curve for which the user provides: The endpoints of the curve The parametric derivatives of the curve at the endpoints The parametric derivatives are dx/dt, dy/dt, dz/dt That is enough to define a cubic Hermite spline, more derivatives are required for higher order curves
6
Hermite Spline (2) Say the user provides
A cubic spline has degree 3, and is of the form: For some constants a, b, c and d derived from the control points, but how? We have constraints: The curve must pass through x0 when t=0 The derivative must be x’0 when t=0 The curve must pass through x1 when t=1 The derivative must be x’1 when t=1
7
Hermite Spline (3) Solving for the unknowns gives: Rearranging gives:
8
Basis Functions A point on a Hermite curve is obtained by multiplying each control point by some function and summing The functions are called basis functions
9
Hermite curves in 2D and 3D
We can treat x in the mapping as a vector. Its components can be explicitly written as
10
Bezier Curves (1) Different choices of basis functions give different curves Choice of basis determines how the control points influence the curve In Hermite case, two control points define endpoints, and two more define parametric derivatives For Bezier curves, two control points define endpoints, and two control the tangents at the endpoints in a geometric way
11
Some Bezier Curves
12
Bezier Curves (2) The user supplies d control points, pi
Write the curve as: The functions Bid are the Bernstein polynomials of degree d This equation can be written as a matrix equation also There is a matrix to take Hermite control points to Bezier control points
13
Bezier Basis Functions for d=3
14
Bezier Curve Matrix Convert Bezier control points to Hermite control points
15
Bezier Curve Properties
The first and last control points are interpolated The tangent to the curve at the first control point is along the line joining the first and second control points The tangent at the last control point is along the line joining the second last and last control points The curve lies entirely within the convex hull of its control points The Bernstein polynomials (the basis functions) sum to 1 and are everywhere positive They can be rendered in many ways E.g.: Convert to line segments with a subdivision algorithm
16
Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005
Convex Hull Property The properties of the Bernstein polynomials ensure that all Bezier curves lie in the convex hull of their control points Hence, even though we do not interpolate all the data, we cannot be too far away p1 p2 convex hull Bezier curve p3 p0 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005
17
Rendering Bezier Curves (1)
Evaluate the curve at a fixed set of parameter values and join the points with straight lines Advantage: Very simple Disadvantages: Expensive to evaluate the curve at many points No easy way of knowing how fine to sample points, and maybe sampling rate must be different along curve No easy way to adapt. In particular, it is hard to measure the deviation of a line segment from the exact curve
18
Rendering Bezier Curves (2)
Recall that a Bezier curve lies entirely within the convex hull of its control vertices If the control vertices are nearly collinear, then the convex hull is a good approximation to the curve Also, a cubic Bezier curve can be broken into two shorter cubic Bezier curves that exactly cover the original curve This suggests a rendering algorithm: Keep breaking the curve into sub-curves Stop when the control points of each sub-curve are nearly collinear Draw the control polygon - the polygon formed by the control points
19
Sub-Dividing Bezier Curves
M12 P1 P2 M012 M0123 M123 M01 M23 P0 P3
20
Sub-Dividing Bezier Curves
P1 P2 P0 P3
21
Sub-Dividing Bezier Curves
Step 1: Find the midpoints of the lines joining the original control vertices. Call them M01, M12, M23 Step 2: Find the midpoints of the lines joining M01, M12 and M12, M23. Call them M012, M123 Step 3: Find the midpoint of the line joining M012, M123. Call it M0123 The curve with control points P0, M01, M012 and M0123 exactly follows the original curve from the point with t=0 to the point with t=0.5 The curve with control points M0123 , M123 , M23 and P3 exactly follows the original curve from the point with t=0.5 to the point with t=1
22
de Casteljau’s Algorithm
You can find the point on a Bezier curve for any parameter value t with a similar algorithm Say you want t=0.25, instead of taking midpoints take points 0.25 of the way M12 P2 P1 M23 t=0.25 M01 P0 P3
23
Invariance Translational invariance means that translating the control points and then evaluating the curve is the same as evaluating and then translating the curve Rotational invariance means that rotating the control points and then evaluating the curve is the same as evaluating and then rotating the curve These properties are essential for parametric curves used in graphics It is easy to prove that Bezier curves, Hermite curves and everything else we will study are translation and rotation invariant Some forms of curves, rational splines, are also perspective invariant Can do perspective transform of control points and then evaluate the curve
24
Longer Curves A single cubic Bezier or Hermite curve can only capture a small class of curves At most 2 inflection points One solution is to raise the degree Allows more control, at the expense of more control points and higher degree polynomials Control is not local, one control point influences entire curve Alternate, most common solution is to join pieces of cubic curve together into piecewise cubic curves Total curve can be broken into pieces, each of which is cubic Local control: Each control point only influences a limited part of the curve Interaction and design is much easier
25
Piecewise Bezier Curve
“knot” P0,0 P1,3 P0,3 P1,0 P1,2 P1,1
26
Continuity When two curves are joined, we typically want some degree of continuity across the boundary (the knot) C0, “C-zero”, point-wise continuous, curves share the same point where they join C1, “C-one”, continuous derivatives, curves share the same parametric derivatives where they join C2, “C-two”, continuous second derivatives, curves share the same parametric second derivatives where they join Higher orders possible Question: How do we ensure that two Hermite curves are C1 across a knot? Question: How do we ensure that two Bezier curves are C0, or C1, or C2 across a knot?
27
Achieving Continuity For Hermite curves, the user specifies the derivatives, so C1 is achieved simply by sharing points and derivatives across the knot For Bezier curves: They interpolate their endpoints, so C0 is achieved by sharing control points The parametric derivative is a constant multiple of the vector joining the first/last 2 control points So C1 is achieved by setting P0,3=P1,0=J, and making P0,2 and J and P1,1 collinear, with J-P0,2=P1,1-J C2 comes from further constraints on P0,1 and P1,2
28
Bezier Continuity P0,1 P0,2 P0,0 P1,3 J P1,2 P1,1
Disclaimer: PowerPoint curves are not Bezier curves, they are interpolating piecewise quadratic curves! This diagram is an approximation.
29
Problem with Bezier Curves
To make a long continuous curve with Bezier segments requires using many segments Maintaining continuity requires constraints on the control point positions The user cannot arbitrarily move control vertices and automatically maintain continuity The constraints must be explicitly maintained It is not intuitive to have control points that are not free
30
B-splines B-splines automatically take care of continuity, with exactly one control vertex per curve segment Many types of B-splines: degree may be different (linear, quadratic, cubic,…) and they may be uniform or non-uniform We will only look closely at uniform B-splines With uniform B-splines, continuity is always one degree lower than the degree of each curve piece Linear B-splines have C0 continuity, cubic have C2, etc
31
Uniform Cubic B-spline on [0,1)
Four control points are required to define the curve for 0t<1 (t is the parameter) Not surprising for a cubic curve with 4 degrees of freedom The equation looks just like a Bezier curve, but with different basis functions Also called blending functions - they describe how to blend the control points to make the curve
32
Basis Functions on [0,1] Does the curve interpolate its endpoints?
Does it lie inside its convex hull? B1,4 B2,4 B0,4 B3,4
33
Uniform Cubic B-spline on [0,1)
The blending functions sum to one, and are positive everywhere The curve lies inside its convex hull The curve does not interpolate its endpoints Requires hacks or non-uniform B-splines There is also a matrix form for the curve:
34
Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005
Blending Functions convex hull property Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005
35
Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005
Splines and Basis If we examine the cubic B-spline from the perspective of each control (data) point, each interior point contributes (through the blending functions) to four segments We can rewrite p(u) in terms of the data points as defining the basis functions {Bi(u)} Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005
36
Basis Cubic B-Spline Functions
In terms of the blending polynomials Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005
37
Uniform Cubic B-splines on [0,m)
Curve: n+1 is the total number of control points d is the order of the curves, 2 d n+1 Bk,d are the uniform B-spline blending functions of degree d-1 Pk are the control points Each Bk,d is only non-zero for a small range of t values, so the curve has local control
38
Uniform Cubic B-spline Blending Functions
39
Computing the Curve P1B1,4 P4B4,4 P0B0,4 P2B2,4 P6B6,4 P3B3,4 P5B5,4 The curve can’t start until there are 4 basis functions active
40
Using Uniform B-splines
At any point t along a piecewise uniform cubic B-spline, there are four non-zero blending functions Each of these blending functions is a translation of B0,4 Consider the interval 0t<1 We pick up the 4th section of B0,4 We pick up the 3rd section of B1,4 We pick up the 2nd section of B2,4 We pick up the 1st section of B3,4
41
Uniform B-spline at Arbitrary t
The interval from an integer parameter value i to i+1 is essentially the same as the interval from 0 to 1 The parameter value is offset by i A different set of control points is needed To evaluate a uniform cubic B-spline at an arbitrary parameter value t: Find the greatest integer less than or equal to t: i = floor(t) Evaluate: Valid parameter range: 0 t <n-3, where n is the number of control points
42
Closed curve To create a closed B-spline curve, repeat the control points P0, P1, P2 at the end of the sequence P0, P1, …., Pn, P0, P1, P2
43
B-splines and Interpolation, Continuity
Uniform B-splines do not interpolate control points, unless: You repeat a control point three times But then all derivatives also vanish (=0) at that point To do interpolation with non-zero derivatives you must use non-uniform B-splines with repeated knots Uniform B-splines are automatically C2 All the blending functions are C2, so sum of blending functions is C2 Provides an alternate way to define blending functions To reduce continuity, must use non-uniform B-splines with repeated knots
44
B-Spline Blending Functions
The recurrence relation starts with the 1st order B-splines, just boxes, and builds up successively higher orders This algorithm is the Cox - de Boor algorithm
45
Bk,1
46
Bk,2
47
Bk,3
48
B0,4
49
B0,4 Note that the functions given on slides 5 and 6 are translates of this function obtained by using (t-1), (t-2) and (t-3) instead of just t, and then selecting only a sub-range of t values for each function
50
From B-spline to Bezier
Both B-spline and Bezier curves represent cubic curves, so either can be used to go from one to the other Recall, a point on the curve can be represented by a matrix equation: P is the column vector of control points M depends on the representation: MB-spline and MBezier T is the column vector containing: t3, t2, t, 1 By equating points generated by each representation, we can find a matrix MB-spline->Bezier that converts B-spline control points into Bezier control points
51
B-spline to Bezier Matrix
52
Parametric Surfaces x(s,1) s P1,1 P0,1 x(s,t) t P0,0 s x(s,0) P1,0
Define points on the surface in terms of two parameters Simplest case: bilinear interpolation x(s,1) s P1,1 P0,1 x(s,t) t P0,0 s x(s,0) P1,0
53
Tensor Product Surface Patches
Defined over a rectangular domain Valid parameter values come from within a rectangular region in parameter space: 0s<1, 0t<1 Use a rectangular grid of control points to specify the surface 4 points in the bi-linear case on the previous slide, more in other cases Surface takes the form: For some functions Fi,s and Fj,t
54
Bezier Patches As with Bezier curves, Bin(s) and Bjm(t) are the Bernstein polynomials of degree n and m respectively Most frequently, use n=m=3: cubic Bezier patch Need 4x4=16 control points, Pi,j
55
Bezier Patches (2) x(s,t) Edge curves are Bezier curves
Any curve of constant s or t is a Bezier curve One way to think about it: Each row of 4 control points defines a Bezier curve in s Evaluating each of these curves at the same s provides 4 virtual control points The virtual control points define a Bezier curve in t Evaluating this curve at t gives the point x(s,t) x(s,t)
56
Properties of Bezier Patches
Which vertices, if any, does the patch interpolate? Why? What can you say about the tangent plane at each corner? Why? Does the patch lie within the convex hull of its control vertices?
57
Properties of Bezier Patches
The patch interpolates its corner points Comes from the interpolation property of the underlying curves The tangent plane at each corner interpolates the corner vertex and the two neighboring edge vertices The tangent plane is the plane that is perpendicular to the normal vector at a point The tangent plane property derives from the curve tangent properties and the way to compute normal vectors The patch lies within the convex hull of its control vertices The basis functions sum to one and are positive everywhere
58
Bezier Patch Matrix Form
Note that the 3 matrices stay the same if the control points do not change The middle product can be pre-computed, leaving only:
59
Computing Normal Vectors
The partial derivative in the s direction is one tangent vector The partial derivative in the t direction is another Take their cross product, and normalize, to get the surface normal vector
60
B-Spline Patches Defined just like Bezier surfaces:
Continuity is automatically obtained everywhere defined over only 1/9 of region
61
Rational Curves Each point is the ratio of two curves Advantages:
Just like homogeneous coordinates: NURBS: x(t), y(t), z(t) and w(t) are non-uniform B-splines Advantages: Perspective invariant, so can be evaluating in screen space Can perfectly represent conic sections: circles, ellipses, etc Piecewise cubic curves cannot do this
62
OpenGL and Parametric Curves
OpenGL defines evaluators that evaluate a Bezier curve at a point You give it the control points: glMap1f(…) Access a specific point: glEvalCoord(param) Access a sequence: glMapGrid1f(n, t1,t2) glEvalMesh1f(mode, p1, p2) These functions evaluate the curve at equally spaced points - the poor way of drawing!
63
OpenGL and NURBS NURBS: Non-uniform Rational B-splines
The curved surface of choice in CAD packages Support routines are part of the GLu utility library Allows you to specify how they are rendered: Can use points constantly spaced in parametric space Can use various error tolerances - the good way! Allows you to get back the lines that would be drawn Allows you to specify trim curves Only for surfaces Cut out parts of the surface - in parametric space
64
How to Choose a Spline Hermite curves are good for single segments where you know the parametric derivative or want easy control of it Bezier curves are good for single segments or patches where a user controls the points B-splines are good for large continuous curves and surfaces NURBS are the most general, and are good when that generality is useful, or when conic sections must be accurately represented (CAD)
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.