Introduction We have dealt with polylines and mesh shapes. We want a way to describe curved shapes which will make them easy to draw.

Slides:



Advertisements
Similar presentations
SI23 Introduction to Computer Graphics
Advertisements

Lecture Notes #11 Curves and Surfaces II
Computer Graphics (Spring 2008) COMS 4160, Lecture 6: Curves 1
2002 by Jim X. Chen: Bezier Curve Bezier Curve.
Lecture 10 Curves and Surfaces I
ICS 415 Computer Graphics B-Spline curves (Chapter 8)
Cubic Curves CSE167: Computer Graphics Instructor: Steve Rotenberg UCSD, Fall 2006.
ICS 415 Computer Graphics Bézier Splines (Chapter 8)
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
1 Curves and Surfaces. 2 Representation of Curves & Surfaces Polygon Meshes Parametric Cubic Curves Parametric Bi-Cubic Surfaces Quadric Surfaces Specialized.
Rational Bezier Curves
Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 12: Spline Curves (review) Ravi Ramamoorthi Most material.
1 Lecture 13 Modeling Curved Lines and Surfaces. 2 Types of Surfaces Ruled Surfaces B-Splines and Bezier Curves Surfaces of Revolution.
Curves Locus of a point moving with one degree of freedom
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
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.
Splines III – Bézier Curves
Curve Modeling Bézier Curves
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.
Interactive Graphics Lecture 9: Slide 1 Interactive Graphics Lecture 9: Introduction to Spline Curves.
(Spline, Bezier, B-Spline)
V. Space Curves Types of curves Explicit Implicit Parametric.
Spline Representations
Numerical Computation
1 Dr. Scott Schaefer Smooth Curves. 2/109 Smooth Curves Interpolation  Interpolation through Linear Algebra  Lagrange interpolation Bezier curves B-spline.
Bézier Algorithms & Properties Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Wednesday, March 3, 2004.
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,
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.
Coordinate Systems and Coordinate Frames  vector v = (3, 2, 7)  point P = (5, 3, 1)  coordinate frame consists of a specific point, V, called the origin,
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.
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.
Interpolating Splines, Implicit Descriptions Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Friday, March 5,
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.
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.
Computer Graphics Lecture 07 Ellipse and Other Curves Taqdees A. Siddiqi
Introduction to Parametric Curve and Surface Modeling.
Vector 2.
The Dance of the Foci David Seppala-Holtzman St. Joseph’s College
© University of Wisconsin, CS559 Spring 2004
Introduction to Parametric Curve and Surface Modeling
Curve & Surface.
Basic theory of curve and surface
CSE 167 [Win 17], Lecture 9: Curves 1 Ravi Ramamoorthi
© University of Wisconsin, CS559 Fall 2004
© University of Wisconsin, CS559 Fall 2004
CURVES CAD/CAM/CAE.
© University of Wisconsin, CS559 Spring 2004
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.
Curve design 455.
Introduction to Parametric Curve and Surface Modeling
Presentation transcript:

Introduction We have dealt with polylines and mesh shapes. We want a way to describe curved shapes which will make them easy to draw.

Example: Animation The path of the camera through the scene must be specified at each instant. The camera is located on the path P(t) at time t.

Animation (2) The designer chooses a suitable function P(t) so that the camera moves as desired, perhaps taking snapshot #1 at t = 0.1, snapshot #2 at t = 0.2, etc. The view direction of the camera must also be specified at each instant.

Animation (3) The camera must move smoothly along P(t) without any disturbing jerks. –This imposes conditions on the velocity P’(t). Other objects might move as well: the car, the boat, and any people coming out of the house. The movement of each of these objects must be described by specifying appropriate parametric functions F(t), G(t), etc.

Smoothness of Motion The velocity v(t) is a vector that describes the speed and direction of an object moving along P(t) as it traverses the curve. It is given by

Smoothness of Motion (2) The tangent line to the curve P(t) at t = t 0 (in parametric form) is L(u). It passes through P(t 0 ) at u = 0 and moves in the direction v(t 0 ). L(u) = P(t 0 ) + v(t 0 ) u

Smoothness of Motion (3) The normal direction to a curve may be found at each point. It is defined as the direction perpendicular to the tangent line at the point. If the tangent line has direction v(t 0 ) at time t 0, the normal direction at t 0 is any multiple of the vector –n(t 0 ) = v┴( t 0 ) = (-dy/dt, dx/dt)| t = t0

Example: Motion on an Ellipse The figure shows velocities along an ellipse. What happens if, at t = a, the speed increases by a factor of 3?

Motion along an Ellipse (2) The trajectory is an ellipse; at t = a both x(t) and y(t) start to oscillate 3 times faster. Their derivatives at t = a are discontinuous. The shape of the curve is the same, but the motion changes.

Parametric Continuity We say a curve P(t) has k-th order parametric continuity everywhere in the t- interval [a, b] if all derivatives of the curve, up through the k-th, exist and are continuous at all points inside [a, b]. Briefly, P( ) is k-smooth in [a, b]. We insist on at least 1-smooth curves for animation, to avoid jerky motion.

Visual Smoothness A curve in an interval is 0-smooth if it is continuous. A curve is 1-smooth if its first derivative exists and is continuous throughout the interval. A curve is 2-smooth if its first and second derivatives exist and are continuous throughout the interval. A curve is 3-smooth if its first, second, and third derivatives exist and are continuous throughout the interval. –A 3-smooth curve must also be 2-smooth, but a 2- smooth curve may or may not be 3-smooth.

Geometric Continuity (G k - continuity). G 0 continuity is the same as 0- smoothness: P(t) is continuous with respect to t throughout [a, b]. G 1 continuity in [a, b] means that P’(c-) = k P'(c+) for some constant k and for every c in the interval [a,b]. G 2 continuity in [a, b] means that P’(c-) = k P’(c+) and P’’(c-) = m P’’(c+) for constants k and m and for every c in the interval [a, b].

Describing Curves by Polynomials A k th degree polynomial is a function given by P (t) = a k t k + a k-1 t k-1 + … + a 1 t + a 0. {a k, a k-1, …, a 0 } are the coefficients. Degree of the polynomial: highest power of t in it (i.e., k). Order of the polynomial: number of coefficients (i.e., k+1).

Polynomials of Degree 1 P(t) = a 0 + a 1 t, a linear curve (straight line). –The equation for P(t) is (in 2 dimensions) 2 equations, one for x(t) and one for y(t). –In 3 dimensions, it is 3 equations, one each for x(t), y(t), z(t). –P(t) passes through point a 0 at t = 0, and through point a 1 at t = 1.

Polynomials of Degree 2 X(t) = at 2 + bt + c, y(t) = dt 2 + et + f –For any choice of a, b, c, d, e, and f, this curve is a parabola. –We cannot generate an ellipse or a hyperbola from this form. More generally, we use F(x, y) = Ax 2 + 2Bxy + Cy 2 + Dx + Ey +F = 0 to generate conic sections.

Polynomials of Degree 2 (cont.) Which conic is generated depends on the value of the discriminant, AC – B 2. –If AC – B 2 > 0, we generate an ellipse. –If AC – B 2 = 0, we generate a parabola. –If AC – B 2 < 0, we generate a hyperbola. Example implicit functions: –Ellipse: x 2 + xy + y 2 - 1: (AC-B 2 = 0.75) –Parabola: x 2 + 2xy + y 2 + 3x – 6y – 7: (AC-B 2 = 0) –Hyperbola: x 2 + 4xy + 2y 2 -4x +y -3: (AC-B 2 = -2)

Polynomials of Degree 2 (cont.) A special case of the general quadratic form, the common vertex equation, y 2 = 2px – (1-ε 2 )x 2, shows how the conic sections are related. –This curve passes through (0,0) and has a size proportional to constant p. The conic that it describes depends on the value of the eccentricity ε. –Eccentricity measures how far off the curve is from a perfect circle (eccentricity = 0).

Polynomials of Degree 2 (cont.)

Polynomial Curves of Degree 3 and Higher Polynomial curves of degree 3 and higher do not easily convert to a parametric form. Cubic polynomials prove very useful in curve and surface design, but start with a collection of control points provided by the designer, and use an algorithm to generate points on the curve. The designer may edit the positions of the control points and view the new curve. This approach is visual, allowing the designer to see the progress of the curve design as the process continues.

Rational Parametric Forms X and y are defined as the ratio of two polynomials (quadratic in the example). P 0, P 1, and P 2 are any 3 points on the plane, called control points. W is a weight parameter.

Rational Parametric Forms (2) The equation for P(t) is actually 2 equations: one each for x(t) and y(t). P(t) is a linear combination of control points. It turns out also to be an affine combination of these points, so it makes sense as a point.

Rational Parametric Forms (3) At t=0, the right hand side collapses simply to (x 0, y 0 ); this curve passes through, or interpolates, the point P 0. At t=1, it passes through P 2. For t in between 0 and 1, P(t) depends on all three points in a complicated way. The figure on the next slide shows the curves, which depend on the value of w.

Rational Parametric Forms (4)

Rational Parametric Forms (5) if w < 1 it is an ellipse if w = 1 it is a parabola if w > 1 it is a hyperbola Rational parametric forms provide a way to generate the conic sections parametrically.

Interactive Curve Design We wish to allow a designer to specify a small number of control points and draw a wide variety of curve shapes. The goal is to capture the shape of this curve in a form that permits it to be reproduced at will, adjusted in shape and size as desired, sent to a machine for automatic cutting or molding, etc. There is most likely no simple formula that matches it exactly.

Interactive Curve Design (2) To enter the curve, the designer moves the pointer along the curve (on a tablet) clicking at a set of control points P 0, P 1,... close to the curve.

Interactive Curve Design (3) The role of the algorithm is to produce a point P(t) for any value of t given to it. The data for the algorithm is the set of control points, which together determine the curve along which the points P(t) will fall.

Interactive Curve Design (4) The algorithm is usually implemented as a function Point2 curvePt(double t, RealPointArray pts) that returns a point for any value of t in a certain interval. To draw the curve the user can choose a sequence of t-values, evaluate curvePt() at each of them, and connect the points with line segments to form a polyline.

Interactive Curve Design (5) Steps in Interactive Curve Design: –1. Lay down the initial control points; –2. Use the algorithm to generate the curve; –3. If the curve is satisfactory, stop; –4. Else, move some control points; –5. Go to step 2;

Interpolation and Approximation Interpolation: curve passes through the control points (left). Approximation: curve passes near each control point (right).

Bezier Curves Bezier curves (approximating curves) were developed to assist in car shape design. The de Casteljau algorithm is used to draw them. The de Casteljau algorithm is based on a sequence of familiar tweening steps (Chapter 5) that are easy to implement. Because tweening is such a well-behaved procedure, it is possible to deduce many valuable properties of the curves that it generates.

Bezier Curves (2) Tweening 3 points to obtain a parabola: –Start with three points: P 0, P 1, and P 2. –Choose t between 0 and 1, say t = 0.3. –Locate the point A that is fraction t of the way along the line from P 0 to P 1. Similarly, locate B at fraction t between the endpoints P 1 and P 2 (using the same t). –The new points are A(t) = (1 - t)P 0 + tP 1, B(t) = (1 - t)P 1 + tP 2

Bezier Curves (3) Now repeat the linear interpolation step on these points (using the same t): Find the point, P(t), that lies fraction t of the way between A and B: P(t) = (1-t)A + tB.

Bezier Curves (4) If this process is carried out for every t between 0 and 1, the curve P(t) will be generated. The parametric form for this curve is P(t) = (1-t) 2 P 0 + 2t(1-t)P 1 + t 2 P 2

Bezier Curves (5) The parametric form for P(t) is quadratic in t, so we know the curve is a parabola. It will still be a parabola even if t is allowed to vary from –∞ to ∞. It passes through P 0 at t = 0 and through P 2 at t = 1 (why?) We thus have a well-defined process that can generate a smooth parabolic curve based on three given points.

Bezier Curves (6) The most common Bezier curves use 4 control points. For a given value of t, point A is placed fraction t of the way from P 0 to P 1, and similarly for points B and C. Then D is placed fraction t of the way from A to B, and similarly for point E. Finally, the desired point P is located fraction t of the way from D to E.

Bezier Curves (7) If this is done for every t between 0 and 1, the curve P(t) starts at P 0, is attracted toward P 1 and P 2, and ends at P 3. It is the Bezier curve determined by the four points.

Bezier Curves (8) The Bezier curve based on four points has the parametric form P(t) = P 0 (1-t) 3 + P 1 3(1- t) 2 t + P 2 3(1-t)t 2 + P 3 t 3. Each control point P i is weighted by a cubic polynomial, and the weighted terms are added. The terms involved here are known as Bernstein polynomials.

Bernstein Polynomials The Bernstein polynomials are These polynomials add to 1 for any value of t. [In fact, they are the expansion of (1 – t + t) 3.] Consequently, P(t) is an affine combination of points, and thus a legitimate point.

Bernstein Polynomials (2)

Blending Points with Bernstein Polynomials The points are vectors bound to the origin (e.g., P 0 = p o, etc.) and t = 0.3. Then p(0.3) = p p p p 3. In the figure the four vectors are weighted and the results are added using the parallelogram rule to form the vector p(0.3).

Generalizing Bezier Curves to Any Number of Points For each value of t, a succession of generations are built up, each by tweening adjacent points produced in the previous generation (superscript for P is the generation number): for i = 0,..., L.

Generalizing Bezier Curves to Any Number of Points (2) The resulting curve is For L ≥ k, the binomial coefficient is For L< k, the binomial coefficient is 0.

Properties of Bezier Curves Bezier curves have properties well-suited to CAD. –Endpoint Interpolation: The Bezier curve P(t) based on control points P 0, P 1,..., P L always interpolates P 0 and P L. –Affine Invariance: to apply an affine transformation T to all points P(t) on the Bezier curve, we transform the control points (once), and use the new control points to re-create the transformed Bezier curve Q(t) at any t. –

Properties of Bezier Curves (2) –Example: A Bezier curve based on four control points P 0,..., P 3. The points are rotated, scaled, and translated to the new control points Q k. –The Bezier curve for Q k is drawn. It is identical to the result of transforming the original Bezier curve.

Properties of Bezier Curves (3) –Convex Hull Property: a Bezier curve, P(t), never wanders outside its convex hull. –The convex hull of a set of points P 0, P 1,..., PL is the set of all convex combinations of the points; that is, the set of all points given by where each α k is non-negative, and they sum to 1.

Properties of Bezier Curves (4) Example: Even though the eight control points form a jagged control polygon, the designer knows the Bezier curve will flow smoothly between the two endpoints, never extending outside the convex hull.

Properties of Bezier Curves (5) Derivatives of Bezier Curves: the first derivative is where ΔP k = P k+1 - P k The velocity is another Bezier curve, built on a new set of control vectors ΔP k. Taking the derivative lowers the order of the curve by 1: the derivative of a cubic Bezier curve is a quadratic Bezier curve.

Drawing Bezier Curves Complete code for drawing Bezier curves is in Fig