Week 4 : Curves Topics: parametric curves, Bezier curves, Hermite curves, b-splines/NURBS curves, NURBS surfaces.

Slides:



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

© University of Wisconsin, CS559 Spring 2004
2002 by Jim X. Chen: Bezier Curve Bezier Curve.
Parametric Equations Local Coordinate Systems Curvature Splines
Lecture 10 Curves and Surfaces I
Cubic Curves CSE167: Computer Graphics Instructor: Steve Rotenberg UCSD, Fall 2006.
Cubic Curves CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005.
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
B-Spline Blending Functions
CS 445 / 645 Introduction to Computer Graphics Lecture 22 Hermite Splines Lecture 22 Hermite Splines.
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.
Slide 127 October 1999CS Computer Graphics (Top Changwatchai) Review of Spline Concepts Sections 10-6 to in Hearn & Baker Splines can be 2D.
Informationsteknologi Monday, December 10, 2007Computer Graphics - Class 161 Today’s class Curve fitting Evaluators Surfaces.
Rational Bezier Curves
Offset of curves. Alina Shaikhet (CS, Technion)
Geometric Modeling Surfaces Mortenson Chapter 6 and Angel Chapter 9.
Cubic Bezier and B-Spline Curves
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
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.
Computer Graphics Lecture 13 Curves and Surfaces I.
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.
Curves and Surfaces CSE3AGR - Paul Taylor Polynomials of Degree n Degree is equal to the highest exponent of a term. Higher exponents result in.
11/19/02 (c) 2002, University of Wisconsin, CS 559 Last Time Many, many modeling techniques –Polygon meshes –Parametric instancing –Hierarchical modeling.
CS 376 Introduction to Computer Graphics 04 / 23 / 2007 Instructor: Michael Eckmann.
V. Space Curves Types of curves Explicit Implicit Parametric.
Introduction to Computer Graphics with WebGL
Numerical Computation
Curves.
Review of Interpolation. A method of constructing a function that crosses through a discrete set of known data points.
Quadratic Surfaces. SPLINE REPRESENTATIONS a spline is a flexible strip used to produce a smooth curve through a designated set of points. We.
CS 376 Introduction to Computer Graphics 04 / 20 / 2007 Instructor: Michael Eckmann.
Curves. First of all… You may ask yourselves “What did those papers have to do with computer graphics?” –Valid question Answer: I thought they were cool,
INTERPOLATION & APPROXIMATION. Curve algorithm General curve shape may be generated using method of –Interpolation (also known as curve fitting) Curve.
Curves and Surfaces Chapter 10. CS 480/680 2Chapter 9 -- Hierarchical Models Introduction: Introduction: Until now we have worked with flat entities such.
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.
Ship Computer Aided Design MR 422. Geometry of Curves 1.Introduction 2.Mathematical Curve Definitions 3.Analytic Properties of Curves 4.Fairness of Curves.
CS 376 Introduction to Computer Graphics 04 / 25 / 2007 Instructor: Michael Eckmann.
Basic Theory (for curve 02). 1.3 Parametric Curves  The main aim of computer graphics is to display an arbitrary surface so that it looks real.  The.
CS 445 / 645 Introduction to Computer Graphics Lecture 23 Bézier Curves Lecture 23 Bézier Curves.
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/6/ :55 Graphics II Introduction to Parametric Curves and Surfaces Session 2.
Greg Humphreys CS445: Intro Graphics University of Virginia, Fall 2003 Parametric Curves & Surfaces Greg Humphreys University of Virginia CS 445, Spring.
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
Slide 129 October 1999CS Computer Graphics (Top Changwatchai) Bézier Curves - Results of Derivation Tangents at endpoints are equal to endpoint slopes.
CS 450: Computer Graphics PARAMETRIC SPLINES AND SURFACES
1 CS 430/536 Computer Graphics I B-Splines and NURBS Week 5, Lecture 9 David Breen, William Regli and Maxim Peysakhov Geometric and Intelligent Computing.
CS 325 Computer Graphics 04 / 30 / 2010 Instructor: Michael Eckmann.
Basic Theory (for curve 01). 1.1 Points and Vectors  Real life methods for constructing curves and surfaces often start with points and vectors, which.
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.
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
© University of Wisconsin, CS559 Fall 2004
© University of Wisconsin, CS559 Spring 2004
Introduction to Parametric Curve and Surface Modeling
Presentation transcript:

Week 4 : Curves Topics: parametric curves, Bezier curves, Hermite curves, b-splines/NURBS curves, NURBS surfaces

Families of curves “Parametric Curves” - you have an explicit function for generating the curve “Cubic Curves” (Bezier, Hermite, Catmull-Rom) - curves defined generally by particular geometric constraints, a basis matrix, and the cubic polynomials, Parameterized between 0 and 1. “b-splines” (uniform b-splines, non-uniform b-splines, and NURBS, or non-uniform rational b-splines) - curves defined by a set of control points, a knot vector, and (for NURBS) weights for the control points. Parameterized between 0 and 1.

Parametric curves A “parametric” curve is a curve that is parameterized by a function with a independent variable t, which defines the curve as it changes. That is, for a function P(t), providing a number t results in a unique position vector P ex: Line the equation y = mx + b can be parameterized by t like so: Px = x0 + vxt Py = y0 + vyt where x0 and y0 are the intial values of x and y v is a vector that is parallel to the line Using these equations we can determine the position of a point on the line at any specific t value.

Parametric line example, if you have the line equation: y = 2x + 2 you can parameterize it: A vector parallel to this line would be v = (1, 2) And we can set the initial x value to 0 and the initial y value to the y-intercept = 2; Px = 0 + 1t Py = 2 + 2t so for the values t = {0, .25, .5, .75, 1} we get the points P = {(0, 2), (.25, 2.5), (.5, 3), (.75, 3.5), (1, 4)}

Parametric curves ex: circle (x – a)2 + (y – b)2 = r2 where (a, b) = the center of the circle and r = the radius can be parameterized by t using sine and cosine like so: x(t) = a + r cos(t) y(t) = b + r sin(t) If we step through values of t between 0 and 2pi we will approximate a circle. (the smaller the steps through t, the closer the approximation) If we add another parametric equation for the 3rd dimension, we get a helix z(t) = rt

Cubic curves “Cubic Curves” (Bezier, Hermite, Catmull-Rom) - curves defined generally by particular geometric constraints, a basis matrix, and the cubic polynomials. Cubic curves are defined most generally by the following equation: Q(t) = a + bt + ct^2 + dt^3 , where t moves between 0 and 1 This can also be written in matrix notation as Q(t) = Q’(t) = [ 1 t t^2 t^3 ] [ ax, bx, cx, dx ay, by, cy, dy az, bz, cz, dz ] [ 0 1 2t 3t^2 ] [ ax, bx, cx, dx ay, by, cy, dy az, bz, cz, dz ]

Cubic Curves In practice, we don’t generally know what the cubic polynomial is, and we create it by specifying control values and providing a basis matrix which “blends” these control points in a specific way, depending on what kind of cubic curve it is. Q(t) = GMT(t) , where t moves between 0 and 1 That is, where G contains the geometric information (either vectors of points or points and tangents), M contains the “basis” matrix used to interpolate through G over time and T is the vector [1, t, t^2, t^3]. The different kinds of cubic curves expect different geometric information and use each use a different basis matrix for blending.

Bezier curves Bezier curves are simple parametric curves that are defined by two endpoints and some number of control points. They are usually found in one of two flavors: quadratic (with a single control point) or cubic (with two control points), although there is no reason you couldn’t have more control points. The control point(s) define the position function of the curve as the variable t changes. An algorithm created by DeCasteljau provides a simple mechanism for creating these curves parametrically.

DeCasteljau’s algorithm

Bezier curves Bezier curves with 2 control points are called cubic curves, because the mathematical “blending” function that defines the curve from the control points is a cubic polynomial. (1 – t)3 P0 + 3t(1 – t)2 P1 + 3t2(1 – t) P2 + t3 P3 Where t is between 0 and 1. That is, this equation defines the amount each point contributes to the curve as t moves from 0 to 1. At t = 0, P0 contributes 100% At t = 1, P1 contributes 100% At t = .5, P0 contributes 12.5%, P1 cs 37.5%, P2 cs 37.5%, P3 cs 12.5% etc.

Bezier curves And it turns out that at each point the total sum of the contribution is 100%. Moreover, at time 0 and time 1 a single point account for the full contribution of the curve, which means that the curve begins and end on a control point.

Bezier curves Since we know the blending functions we can shorten our equation to: P(t) = B0(t) P0 + B1(t) P1 + B2(t) P2 + B3(t) P3 or just P(t) = ΣBiPi In practice, you can calculate each dimension of the curve separately. I.e. : Px(t) = (1 – t)3 Px,0 + 3t(1 – t)2 Px,1 + 3t2(1 – t) Px,2 + t3 Px,3 Py(t) = (1 – t)3 Py,0 + 3t(1 – t)2 Py,1 + 3t2(1 – t) Py,2 + t3 Py,3 Pz(t) = (1 – t)3 Pz,0 + 3t(1 – t)2 Pz,1 + 3t2(1 – t) Pz,2 + t3 Pz,3

Bezier curves Or, returning to our generalization Q(t) = GMT(t) we can encode G using our 4 points (the start point, the two control points, and the end points) and M by extracting out the coefficients of the blending function. G = [Pstart, Pcontrol1, Pcontrol2, Pend] M = T = M’ = T’ = [ 1 -3 3 1 0 3 -6 3 0 0 3 -3 0 0 0 1 ] [ 1 t t^2 t^3 ] [ -3 6 -3 3 -12 9 0 6 -9 0 0 3 ] [ 1 t t^2 ]

Hermite curves A similar curve that also lets you create a curve around set endpoints is called a Hermite curve. In the Bezier curve you move the two control points to influence the curve. In a Hermite curve you instead adjust the tangents at the endpoints to control the curve. Hermite curves are also known as “the pen tool” in Illustrator. The curve is parametrically defined by the following equation: Q(t) = (2t3 – 3t2 + 1)P0 + (t3 – 2t2 + t)T0 + (t3 – t2)T1 + (-2t3 + 3t2)P1 where P0 and P1 are the endpoints of the curve, and T0 and T1 are tangent vectors for P0 and P1 respectively.

Hermite curves Here is the graph of the blending function for the two endpoints. (The red and blue indicate the blending for the points and the green and turquoise for the tangents)

Hermite curves G = [Pstart, Pend, Tstart, Tend] M = [ 1 0 -3 2 [ 1 0 -3 2 0 0 3 -2 0 1 -2 1 0 0 -1 1 ]

Continuity Obviously both these simple cubic parametric curves suffer from the fact that you are limited to the kinds of curves you can generate. That is, they have at most one inflection point. You can keep track of the tangents of the curves at the end points and stitch them together. To increase the range / loopiness of your curve you can either increase the order/complexity of your curve by adding more control points. Or you can stitch together a series of simpler curves. One common solution to do this is to use a Catmull-Rom spline.

Catmull-Rom splines Nice because the curve actually goes through the points that define the curve and is easy/cheap to calculate (often used for camera animations). G = [Pi-1, Pi, Pi+1, Pi+2] M = (1/2) Except for the first and last point, the curve goes through every point. The tangent of the curve at each point is defined by 1/2 (Pi+1 - Pi-1) (can’t find an image of this-- draw on board) [ 0 -1 2 -1 2 0 -5 -3 0 1 4 -3 0 0 -1 1 ]

Continuity When stitching together curves there is generally a trade-off between ease of use and flexibility. A simple naming scheme is used to describe the power of the different techniques to join together curve pieces; C0 = the curves share an end point, but the end point may look discontinuous, sharp G1 = the curves share an end point and those end points have the same tangent. C1 = same as G1 except that the tangent vector is also required to have the same magnitude C2 = the curves share an end point, the tangent is the same, and also the second derivative (representing curvature or acceleration) is the same. C∞ = all derivates of the curve are the same. Generally, strive for C2 as it looks good and if we are using the curve for animation it guarantees that both the velocity and the acceleration are the same.

B-splines B-splines are a more general way to think about curves. The “B” stands for the basis which defines the blending functions. The phrase “b-spline” is often used to describe a certain category of continuously connected curve pieces. B-splines guarantee C2 continuity, but at the price of a increased complexity and the loss of some control (none of the points go through the control points!) B-splines come in three flavors: Uniform, Nonuniform, and Nonuniform Rational. The latter is also called NURBS (NonUniform Rational B-Splines)

Uniform b-splines The basic b-spline is defined like so: Given a set of n+1 control points, the b-spline curve is composed of n-2 cubic curves pieces. Each piece is defined again by a blending of 4 points, where for each piece Qi, Qi(t = 1) = Qi+1 (t = 0) Q’i(t = 1) = Q’i+1 (t = 0) Q’’i(t = 1) = Q’’i+1 (t = 0) That is, the joins are C2 continuous. These joins are called internal knots.

Uniform b-splines For each curve piece Qi, Qi(t) = B0(t) + B1(t) + B2(t) + B3(t) where the blending functions are the following: B0(t) = [ (1 – t)3 / 6 ] * P0 B1(t) = [ (4 – 6t2 + 3t3) / 6 ] * P1 B2(t) = [ (1 + 3t + 3t2 + 3t3) / 6 ] * P2 B3(t) = [ t3 / 6 ] * P3

Uniform b-splines B0(t) = [ (1 – t)3 / 6 ] * P0 B1(t) = [ (4 – 6t2 + 3t3) / 6 ] * P1 B2(t) = [ (1 + 3t + 3t2 + 3t3) / 6 ] * P2 B3(t) = [ t3 / 6 ] * P3 which looks like this:

Uniform b-splines G = [Pi-1, Pi, Pi+1, Pi+2] M = (1/6) [ 1 -3 3 1 [ 1 -3 3 1 4 0 -6 3 1 3 3 -3 0 0 0 1 ]

Nonuniform b-splines In uniform b-splines, the knots are automatically positioned at equal distances along the curve. In a nonuniform b-spline, we can space the knots at nonuniform locations along the curve, which can change the curve in various ways. For instance, we can create looped curves, and perfect circle arcs. To create a nonuniform cubic b-spline we need to define a knot-vector to describe the knot spacing. If our curve uses 7 control points, then we will need (# of control points + degree of curve + 1) knots = 7 + 3 + 1 = 11 knots If the knot vector is (0,1,2,3,4,5,6,7,8,9,10) then the curve will reduce to the uniform b-spline.

Cox-deBoor algorithm Each piece is defined like so: Qi(u) = ΣBi+k-1,d(u)Pi+k-1 (sum as k goes from 0 to 3, ie the previous point Pi-1  Pi+2) Where the range of u is defined by the knot vector (the val at t0 -> val at t#knots) d = the degree parameter (which is the degree + 1, or 3 + 1 for cubic b-spline) The blending functions are recursively defined like so: Bi,0(u) = 1 if ti-2 <= u <= ti-1, otherwise 0 Bi,k(u) = (u – ti-2) [Bi,k-1(u) / ti+k-2 – ti-2] + (ti-+k-1 – u) [Bi+1,k-1(u) / ti+k-1 – ti-1] (ie, input Bi+k-1,d(u) from curve algo above and calc from reduced dimensionality)

NURBS Similar to nonunifrom b-splines, except that you can specify a weight to every control point. Pi = <wixi, wiyi, wizi, wi> Qi(u) = ΣBi+k-1,d(u)Pi+k-1 The weight is thought of as 4th component to the point, making it a point in homogeneous coordinates. The weights have the effect of shifting the curve in the direction of the weighted control point (whereas moving knots close together has the effect of causing the curve to converge upon a control point.)

NURBS With a nonuniform b-spline you can insert new control points as desired and update the knot-vector appropriately. This will let you have more control over a specfic range, while leaving the curve controlled by points further away the same. Also, you can repeat the beginning and end values of your knot vector (order) times which will force your curve to line up with the control point endpoints

Curves in OpenGL / GLU 1. create a NURBS object gluNewNurbsRenderer() 2. indicate that you are using the NURBS renderer gluBeginCurve(nurbsObj) 3. draw the curve gluNurbsCurve( lengthOfKnotVector, //how many knots knotVectorArray, //the knots stride, //the stride through the controlArray, either 3 or 4 generally contolPointsArray, //the control points curveOrder, //cubic = 3, can be higher but requires more knots GL_MAP1_VERTEX_3 //use _3 for unweighted points, _4 if you weight );

NURBS surfaces defined by a mesh of control points, which define two sets of curves – a column of curves and a row of curves... (demo)