Introduction to Parametric Curve and Surface Modeling

Slides:



Advertisements
Similar presentations
Lecture Notes #11 Curves and Surfaces II
Advertisements

© University of Wisconsin, CS559 Spring 2004
Lecture 10 Curves and Surfaces I
CS 445/645 Fall 2001 Hermite and Bézier Splines. Specifying Curves Control Points –A set of points that influence the curve’s shape Knots –Control points.
© University of Wisconsin, CS559 Spring 2004
Jehee Lee Seoul National University
B-Spline Blending Functions
Dr. S.M. Malaek Assistant: M. Younesi
1 Curves and Surfaces. 2 Representation of Curves & Surfaces Polygon Meshes Parametric Cubic Curves Parametric Bi-Cubic Surfaces Quadric Surfaces Specialized.
Informationsteknologi Monday, December 10, 2007Computer Graphics - Class 161 Today’s class Curve fitting Evaluators Surfaces.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Curves Week 12, Wed Apr.
1 Lecture 13 Modeling Curved Lines and Surfaces. 2 Types of Surfaces Ruled Surfaces B-Splines and Bezier Curves Surfaces of Revolution.
Geometric Modeling Surfaces Mortenson Chapter 6 and Angel Chapter 9.
Curves Mortenson Chapter 2-5 and Angel Chapter 9
Bezier and Spline Curves and Surfaces Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
Modelling: Curves Week 11, Wed Mar 23
University of British Columbia CPSC 414 Computer Graphics © Tamara Munzner 1 Curves Week 13, Mon 24 Nov 2003.
Bezier and Spline Curves and Surfaces CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
1 Representing Curves and Surfaces. 2 Introduction We need smooth curves and surfaces in many applications: –model real world objects –computer-aided.
Curve Surfaces June 4, Examples of Curve Surfaces Spheres The body of a car Almost everything in nature.
Splines III – Bézier Curves
Computer Graphics Lecture 13 Curves and Surfaces I.
Curves and Surfaces (cont’) Amy Zhang. Conversion between Representations  Example: Convert a curve from a cubic B-spline curve to the Bézier form:
Curve Modeling Bézier Curves
Bresenham’s Algorithm. Line Drawing Reference: Edward Angel’s book: –6 th Ed. Sections 6.8 and 6.9 Assuming: –Clipped (to fall within the window) –2D.
11/19/02 (c) 2002, University of Wisconsin, CS 559 Last Time Many, many modeling techniques –Polygon meshes –Parametric instancing –Hierarchical modeling.
A D V A N C E D C O M P U T E R G R A P H I C S CMSC 635 January 15, 2013 Spline curves 1/23 Curves and Surfaces.
CS 376 Introduction to Computer Graphics 04 / 23 / 2007 Instructor: Michael Eckmann.
(Spline, Bezier, B-Spline)
V. Space Curves Types of curves Explicit Implicit Parametric.
Introduction to Computer Graphics with WebGL
Cornell CS465 Fall 2004 Lecture 15© 2004 Steve Marschner 1 2D Spline Curves CS 465 Lecture 15.
Quadratic Surfaces. SPLINE REPRESENTATIONS a spline is a flexible strip used to produce a smooth curve through a designated set of points. We.
University of Texas at Austin CS384G - Computer Graphics Fall 2008 Don Fussell Parametric Curves.
CS 445/645 Fall 2001 Splines/Film/Animation. Final Exam Thursday, December 13 th from 7 – 10 p.m. –Room Olsson 011 You may use one sheet of notes (8.5.
Splines IV – B-spline Curves based on: Michael Gleicher: Curves, chapter 15 in Fundamentals of Computer Graphics, 3 rd ed. (Shirley & Marschner) Slides.
Parametric Surfaces Define points on the surface in terms of two parameters Simplest case: bilinear interpolation s t s x(s,t)x(s,t) P 0,0 P 1,0 P 1,1.
CS 376 Introduction to Computer Graphics 04 / 25 / 2007 Instructor: Michael Eckmann.
Representation of Curves & Surfaces Prof. Lizhuang Ma Shanghai Jiao Tong University.
04/18/02(c) 2002 University of Wisconsin Last Time Hermite Curves Bezier Curves.
Curves: ch 4 of McConnell General problem with constructing curves: how to create curves that are “smooth” CAD problem Curves could be composed of segments.
11/26/02(C) University of Wisconsin Last Time BSplines.
Parametric Curves CS 318 Interactive Computer Graphics John C. Hart.
(c) 2002 University of Wisconsin
CS 450: Computer Graphics PARAMETRIC SPLINES AND SURFACES
Splines Sang Il Park Sejong University. Particle Motion A curve in 3-dimensional space World coordinates.
CS 325 Computer Graphics 04 / 30 / 2010 Instructor: Michael Eckmann.
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:
Curves University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2013 Tamara Munzner.
CS552: Computer Graphics Lecture 19: Bezier Curves.
Object Modeling: Curves and Surfaces CEng 477 Introduction to Computer Graphics.
Introduction to Parametric Curve and Surface Modeling.
© University of Wisconsin, CS559 Spring 2004
CS5500 Computer Graphics May 11, 2006
Curve & Surface.
Representation of Curves & Surfaces
CS 445 / 645 Introduction to Computer Graphics
(Spline, Bezier, B-Spline)
2D Spline Curves CS 465 Lecture 15 © 2004 Steve Marschner • 1.
Parametric Curves.
© University of Wisconsin, CS559 Fall 2004
© University of Wisconsin, CS559 Fall 2004
CURVES CAD/CAM/CAE.
© University of Wisconsin, CS559 Spring 2004
Spline Curves COMP 575/COMP 770.
Implicit Functions Some surfaces can be represented as the vanishing points of functions (defined over 3D space) Places where a function f(x,y,z)=0 Some.
UNIT-5 Curves and Surfaces.
Three-Dimensional Object Representation
Introduction to Parametric Curve and Surface Modeling
Overview June 9- B-Spline Curves June 16- NURBS Curves
Presentation transcript:

Introduction to Parametric Curve and Surface Modeling

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

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

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

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

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

Hermite Spline (3) Solving for the unknowns gives: Rearranging gives:

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

Hermite curves in 2D and 3D We can treat x in the mapping as a vector. Its components can be explicitly written as

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

Some Bezier Curves

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

Bezier Basis Functions for d=3

Bezier Curve Matrix Convert Bezier control points to Hermite control points

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

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

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

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

Sub-Dividing Bezier Curves M12 P1 P2 M012 M0123 M123 M01 M23 P0 P3

Sub-Dividing Bezier Curves P1 P2 P0 P3

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

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

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

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

Piecewise Bezier Curve “knot” P0,0 P1,3 P0,3 P1,0 P1,2 P1,1

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?

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

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.

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

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

Uniform Cubic B-spline on [0,1) Four control points are required to define the curve for 0t<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

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

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:

Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Blending Functions convex hull property Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005

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

Basis Cubic B-Spline Functions In terms of the blending polynomials Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005

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

Uniform Cubic B-spline Blending Functions

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

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 0t<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

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

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

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

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

Bk,1

Bk,2

Bk,3

B0,4

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

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

B-spline to Bezier Matrix

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

Tensor Product Surface Patches Defined over a rectangular domain Valid parameter values come from within a rectangular region in parameter space: 0s<1, 0t<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

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

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)

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?

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

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:

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

B-Spline Patches Defined just like Bezier surfaces: Continuity is automatically obtained everywhere defined over only 1/9 of region

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

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!

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

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)