Splines Computer Graphics I Lecture 10

Similar documents
Curves and Surfaces Computer Graphics I Lecture 9

Computer Graphics I Lecture 11

Computer Graphics Spline and Surfaces

Curves and Surfaces Computer Graphics I Lecture 10

Supplement to Lecture 11

Information Coding / Computer Graphics, ISY, LiTH. Splines

An Introduction to 3D Computer Graphics, Stereoscopic Image, and Animation in OpenGL and C/C++ Fore June

OpenGL Programming Guide Chapter 12, Evaluators and NURBS 1

Curves and Surfaces 1

CS130 : Computer Graphics Curves (cont.) Tamar Shinar Computer Science & Engineering UC Riverside

Parametric Curves. University of Texas at Austin CS384G - Computer Graphics

Parametric Curves. University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell

Until now we have worked with flat entities such as lines and flat polygons. Fit well with graphics hardware Mathematically simple

Readings on Bézier Curves and Surfaces. 1 Additional Reading. 2 Organization. 3 Introduction. 4 Representing Curves

Computer Graphics. Curves and Surfaces. Hermite/Bezier Curves, (B-)Splines, and NURBS. By Ulf Assarsson

2D Spline Curves. CS 4620 Lecture 13

Design considerations

CS-184: Computer Graphics

B-spline Curves. Smoother than other curve forms


3D Modeling Parametric Curves & Surfaces

Rational Bezier Curves

3D Modeling Parametric Curves & Surfaces. Shandong University Spring 2013

Computer Graphics Curves and Surfaces. Matthias Teschner

Computergrafik. Matthias Zwicker Universität Bern Herbst 2016

OUTLINE. Quadratic Bezier Curves Cubic Bezier Curves

Representing Curves Part II. Foley & Van Dam, Chapter 11

Splines. Parameterization of a Curve. Curve Representations. Roller coaster. What Do We Need From Curves in Computer Graphics? Modeling Complex Shapes

Bezier Curves, B-Splines, NURBS

Curves: OpenGL Evaluators - Intro

Curve Construction via Local Fitting

Computergrafik. Matthias Zwicker. Herbst 2010

Fall CSCI 420: Computer Graphics. 4.2 Splines. Hao Li.

Evaluators and Spline Surfaces

CSE 167: Introduction to Computer Graphics Lecture #11: Bezier Curves. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2016

2D Spline Curves. CS 4620 Lecture 18

Computer Graphics CS 543 Lecture 13a Curves, Tesselation/Geometry Shaders & Level of Detail

CSE 167: Introduction to Computer Graphics Lecture #13: Curves. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2017

Basic Graphics Programming

Shape Representation Basic problem We make pictures of things How do we describe those things? Many of those things are shapes Other things include

Intro to Curves Week 4, Lecture 7

CS-184: Computer Graphics. Today

(Refer Slide Time: 00:02:24 min)

Intro to Modeling Modeling in 3D

Curves. Computer Graphics CSE 167 Lecture 11

Objects 2: Curves & Splines Christian Miller CS Fall 2011

Lecture IV Bézier Curves

Computer Graphics I. Midterm Examination. October 23, This is a closed-book exam; only one double-sided sheet of notes is permitted.

Curves and Curved Surfaces. Adapted by FFL from CSE167: Computer Graphics Instructor: Ronen Barzel UCSD, Winter 2006

Know it. Control points. B Spline surfaces. Implicit surfaces

08 - Designing Approximating Curves

Curves and Surfaces. Computer Graphics COMP 770 (236) Spring Instructor: Brandon Lloyd

CHAPTER 1 Graphics Systems and Models 3

Bézier Splines. B-Splines. B-Splines. CS 475 / CS 675 Computer Graphics. Lecture 14 : Modelling Curves 3 B-Splines. n i t i 1 t n i. J n,i.

Splines. Connecting the Dots

Types of Curves. Lecture 7. Parametric Curves. Plane Curves. - Not flexible enough, e.g. Circle. - e.g: ax+by+c = 0, x2 +y 2 -c 2 = 0

Central issues in modelling

CS 475 / CS Computer Graphics. Modelling Curves 3 - B-Splines

For each question, indicate whether the statement is true or false by circling T or F, respectively.

To Do. Resources. Algorithm Outline. Simplifications. Advanced Computer Graphics (Spring 2013) Surface Simplification: Goals (Garland)

Intro to Curves Week 1, Lecture 2

Picking and Curves Week 6

COMPUTER AIDED GEOMETRIC DESIGN. Thomas W. Sederberg

CS 536 Computer Graphics Intro to Curves Week 1, Lecture 2

Curves D.A. Forsyth, with slides from John Hart

Introduction to Computer Graphics

Introduction to Computer Graphics. Farhana Bandukwala, PhD Lecture 11: Surfaces

Parametric curves. Brian Curless CSE 457 Spring 2016

Clipping and Scan Conversion

Need for Parametric Equations

Curves & Surfaces. Last Time? Progressive Meshes. Selective Refinement. Adjacency Data Structures. Mesh Simplification. Mesh Simplification

Rendering Curves and Surfaces. Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico

CSE 167: Introduction to Computer Graphics Lecture 12: Bézier Curves. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2013

Rasterization Computer Graphics I Lecture 14. Scan Conversion Antialiasing Compositing [Angel, Ch , ]

Dgp _ lecture 2. Curves

15.10 Curve Interpolation using Uniform Cubic B-Spline Curves. CS Dept, UK

Source code: #include <iostream>

Interactive Computer Graphics A TOP-DOWN APPROACH WITH SHADER-BASED OPENGL

Spline Notes. Marc Olano University of Maryland, Baltimore County. February 20, 2004

Shape modeling Modeling technique Shape representation! 3D Graphics Modeling Techniques

Curves & Surfaces. MIT EECS 6.837, Durand and Cutler

Advanced Texture-Mapping Curves and Curved Surfaces. Pre-Lecture Business. Texture Modes. Texture Modes. Review quiz

Spline Morphing. CG software practical course in the IWR. Carl Friedrich Bolz. Carl Friedrich Bolz

Further Graphics. Bezier Curves and Surfaces. Alex Benton, University of Cambridge Supported in part by Google UK, Ltd

From curves to surfaces. Parametric surfaces and solid modeling. Extrusions. Surfaces of revolution. So far have discussed spline curves in 2D

CS 465 Program 4: Modeller

09 - Designing Surfaces. CSCI-GA Computer Graphics - Fall 16 - Daniele Panozzo

Sung-Eui Yoon ( 윤성의 )

2D Drawing Primitives

Interactive Graphics. Lecture 9: Introduction to Spline Curves. Interactive Graphics Lecture 9: Slide 1

Curve Representation ME761A Instructor in Charge Prof. J. Ramkumar Department of Mechanical Engineering, IIT Kanpur

Review of Tuesday. ECS 175 Chapter 3: Object Representation

INF3320 Computer Graphics and Discrete Geometry

GL9: Engineering Communications. GL9: CAD techniques. Curves Surfaces Solids Techniques

(Spline, Bezier, B-Spline)

Viewing and Projection

The Free-form Surface Modelling System

MA 323 Geometric Modelling Course Notes: Day 21 Three Dimensional Bezier Curves, Projections and Rational Bezier Curves

Direct Rendering of Trimmed NURBS Surfaces

Introduction p. 1 What Is Geometric Modeling? p. 1 Computer-aided geometric design Solid modeling Algebraic geometry Computational geometry

Transcription:

15-462 Computer Graphics I Lecture 10 Splines Cubic B-Splines Nonuniform Rational B-Splines Rendering by Subdivision Curves and Surfaces in OpenGL [Angel, Ch 10.7-10.14] February 21, 2002 Frank Pfenning Carnegie Mellon University http://www.cs.cmu.edu/~fp/courses/graphics/

Review Cubic polynomial form for curve Each c k is a column vector [c kx c ky c kz ] T Solve for c k given control points Interpolation: 4 points Hermite curves: 2 endpoints, 2 tangents Bezier curves: 2 endpoints, 2 tangent points 02/21/2002 15-462 Graphics I 2

Splines Approximating more control points C 0 continuity: points match C 1 continuity: tangents (derivatives) match C 2 continuity: curvature matches With Bezier segments or patches: C 0 02/21/2002 15-462 Graphics I 3

B-Splines Use 4 points, but approximate only middle two Draw curve with overlapping segments 0-1-2-3, 1-2-3-4, 2-3-4-5, 3-4-5-6, etc. Curve may miss all control points Smoother at joint points 02/21/2002 15-462 Graphics I 4

Cubic B-Splines Need m+2 control points for m cubic segments Computationally 3 times more expensive C 2 continuous at each interior point Derive as follows: Consider two overlapping segments Enforce C 0 and C 1 continuity Employ symmetry C 2 continuity follows 02/21/2002 15-462 Graphics I 5

Deriving B-Splines Consider points p i-2, p i-1, p i, p i+1 p(0) approx p i-1, p(1) approx p i p i-3, p i-2, p i-1, p i q(0) approx p i-2, q(1) approx p i-1 Condition 1: p(0) = q(1) Symmetry: p(0) = q(1) = 1/6(p i-2 + 4 p i-1 + p i ) Condition 2: p (0) = q (1) Geometry: p (0) = q (1) = 1/2 ((p i p i-1 ) + (p i-1 p i-2 )) = 1/2 (p i p i-2 ) 02/21/2002 15-462 Graphics I 6

B-Spline Geometry Matrix Conditions at u = 0 p(0) = c 0 = 1/6 (p i-2 + 4p i-1 + p i ) p (0) = c 1 = 1/2 (p i p i-2 ) Conditions at u = 1 p(1) = c 0 + c 1 + c 2 + c 3 = 1/6 (p i-1 + 4p i + p i+1 ) p (1) = c 1 + 2c 2 + 3c 3 = 1/2 (p i+1 p i-1 ) 02/21/2002 15-462 Graphics I 7

Blending Functions Calculate cubic blending polynomials Note symmetries 02/21/2002 15-462 Graphics I 8

Convex Hull For 0 u 1, have 0 b k (u) 1 Recall: p(u) = b i-2 (u)p i-2 + b i-1 (u)p i-1 + b i (u)p i + b i+1 (u)p i+1 So each point p(u) lies in convex hull of p k 02/21/2002 15-462 Graphics I 9

Spline Basis Functions Total contribution B i (u)p i of p i is given by 02/21/2002 15-462 Graphics I 10

Spline Surface As for Bezier patches, use 16 control points Start with blending functions Need 9 times as many splines as for Bezier 02/21/2002 15-462 Graphics I 11

Assessment: Cubic B-Splines More expensive than Bezier curves or patches Smoother at join points Local control How far away does a point change propagate? Contained in convex hull of control points Preserved under affine transformation How to deal with endpoints? Closed curves (uniform periodic B-splines) Non-uniform B-Splines (multiplicities of knots) 02/21/2002 15-462 Graphics I 12

General B-Splines Generalize from cubic to arbitrary order Generalize to different basis functions Read: [Angel, Ch 10.8] Knot sequence u min = u 0... u n = u max Repeated points have higher gravity Multiplicity 4 means point must be interpolated {0, 0, 0, 0, 1, 2,..., n-1, n, n, n, n} solves boundary problem 02/21/2002 15-462 Graphics I 13

Nonuniform Rational B-Splines (NURBS) Exploit homogeneous coordinates Use perspective division to renormalize Each component of p(u) is rational function of u Points not necessarily uniform (NURBS) 02/21/2002 15-462 Graphics I 14

NURBS Assessment Convex-hull and continuity props. of B-splines Preserved under perspective transformations Curve with transformed points = transformed curve Widely used (including OpenGL) 02/21/2002 15-462 Graphics I 15

Outline Cubic B-Splines Nonuniform Rational B-Splines (NURBS) Rendering by Subdivision Curves and Surfaces in OpenGL 02/21/2002 15-462 Graphics I 16

Rendering by Subdivision Divide the curve into smaller subpieces Stop when flat or at fixed depth How do we calculate the sub-curves? Bezier curves and surfaces: easy (next) Other curves: convert to Bezier! 02/21/2002 15-462 Graphics I 17

Subdividing Bezier Curves Given Bezier curve by p 0, p 1, p 2, p 3 Find l 0, l 1, l 2, l 3 and r 0, r 1, r 2, r 3 Subcurves should stay the same! 02/21/2002 15-462 Graphics I 18

Construction of Bezier Subdivision Use algebraic reasoning l(0) = l 0 = p 0 l(1) = l 3 = p(1/2) = 1/8(p 0 + 3p 1 + 3p 2 + p 3 ) l (0) = 3(l 1 l 0 ) = p (0) = 3/2 (p 1 p 0 ) l (1) = 3(l 3 l 2 ) = p (1/2) = 3/8(-p 0 p 1 + p 2 +p 3 ) Note parameter substitution v = 2u so dv = 2du 02/21/2002 15-462 Graphics I 19

Geometric Bezier Subdivision Can also calculate geometrically l 1 = ½(p 0 + p 1 ), r 2 = ½ (p 2 + p 3 ) l 2 = ½ (l 1 + ½ (p 1 + p 2 )), r 1 = ½ (r 2 + ½(p 1 + p 2 )) l 3 = r 0 = ½ (l 2 + r 1 ), l 0 = p 0, r 3 = p 3 02/21/2002 15-462 Graphics I 20

Recall: Bezier Curves Recall Express 02/21/2002 15-462 Graphics I 21

Subdividing Other Curves Calculations more complex Trick: transform control points to obtain identical curve as Bezier curve! Then subdivide the resulting Bezier curve Bezier: p(u) = u T M b p Other curve: p(u) = u T M q, M geometry matrix Solve: q = M -1 M b p with p = M b -1 M q 02/21/2002 15-462 Graphics I 22

Example Conversion From cubic B-splines to Bezier: Calculate Bezier points p from q Subdivide as Bezier curve 02/21/2002 15-462 Graphics I 23

Subdivision of Bezier Surfaces Slightly more complicated Need to calculate interior point Cracks may show with uneven subdivision See [Angel, Ch 10.9.4] 02/21/2002 15-462 Graphics I 24

Outline Cubic B-Splines Nonuniform Rational B-Splines (NURBS) Rendering by Subdivision Curves and Surfaces in OpenGL 02/21/2002 15-462 Graphics I 25

Curves and Surface in OpenGL Central mechanism is evaluator Defined by array of control points Evaluate coordinates at u (or u and v) to generate vertex Define Bezier curve: type = GL_MAP_VERTEX_3 glmap1f(type, u 0, u 1, stride, order, point_array) Enable evaluator glenable(type) Evaluate Bezier curve glevalcoord1f(u) 02/21/2002 15-462 Graphics I 26

Example: Drawing a Bezier Curve 4 control points Initialize GLfloat ctrlpoints[4][3] = { {-4.0, -4.0, 0.0}, { -2.0, 4.0, 0.0}, {2.0, -4.0, 0.0}, {4.0, 4.0, 0.0}}; void init() {... glmap1f(gl_map1_vertex_3, 0.0, 1.0, 3, 4, &ctrlpoints[0][0]); glenable(gl_map1_vertex_3); } 02/21/2002 15-462 Graphics I 27

Evaluating Coordinates Use a fixed number of points, num_points void display() {... glbegin(gl_line_strip); for (i = 0; i <= num_points; i++) glevalcoord1f((glfloat)i/(glfloat)num_points); glend();... } 02/21/2002 15-462 Graphics I 28

Drawing the Control Points To illustrate Bezier curve void display() {... glpointsize(5.0); glcolor3f(1.0, 1.0, 0.0); glbegin(gl_points); for (i = 0; i < 4; i++) glvertex3fv(&ctrlpoints[i][0]); glend(); glflush(); } 02/21/2002 15-462 Graphics I 29

Resulting Images n = 5 n = 20 02/21/2002 15-462 Graphics I 30

Bezier Surfaces Create evaluator in two parameters u and v glmap2f(gl_map2_vertex_3, u 0, u 1, ustride, uorder, v 0, v 1, vstride, vorder, point_array); Enable, also automatic calculation of normal glenable(gl_map2_vertex_3); glenable(gl_auto_normal); Evaluate at parameters u and v glevalcoord2f(u, v); 02/21/2002 15-462 Graphics I 31

Grids Convenience for uniform evaluators Define grid (nu = number of u division) glmapgrid2f(nu, u 0, u 1, nv, v 0, v 1 ); Evaluate grid glevalmesh2(mode, i 0, i 1, k 0, k 1 ); mode = GL_POINT, GL_LINE, or GL_FILL i and k define subrange 02/21/2002 15-462 Graphics I 32

Example: Bezier Surface Patch Use 16 control points GLfloat ctrlpoints[4][4][3] = {...}; Initialize 2-dimensional evaluator void init(void) {... glmap2f(gl_map2_vertex_3, 0, 1, 3, 4, 0, 1, 12, 4, &ctrlpoints[0][0][0]); glenable(gl_map2_vertex_3); glenable(gl_auto_normal); glmapgrid2f(20, 0.0, 1.0, 20, 0.0, 1.0); } 02/21/2002 15-462 Graphics I 33

Evaluating the Grid Use full range void display(void) {... glpushmatrix(); glrotatef(85.0, 1.0, 1.0, 1.0); glevalmesh2(gl_fill, 0, 20, 0, 20); glpopmatrix(); glflush(); } 02/21/2002 15-462 Graphics I 34

Resulting Image 02/21/2002 15-462 Graphics I 35

NURBS Functions Higher-level interface Implemented in GLU using evaluators Create a NURBS renderer thenurb = glunewnurbsrenderer(); Set NURBS properties glunurbsproperty(thenurb, GLU_DISPLAY_MODE, GLU_FILL); glunurbscallback(thenurb, GLU_ERROR, nurbserror); 02/21/2002 15-462 Graphics I 36

Displaying NURBS Surfaces Specify knot arrays for splines GLfloat knots[8] = {0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0}; glubeginsurface(thenurb); glunurbssurface(thenurb, 8, knots, 8, knots, 4 * 3, 3, &ctlpoints[0][0][0], 4, 4, GL_MAP2_VERTEX_3); gluendsurface(thenurb); For more see [Red Book, Ch. 12] 02/21/2002 15-462 Graphics I 37

Summary Cubic B-Splines Nonuniform Rational B-Splines (NURBS) Rendering by Subdivision Curves and Surfaces in OpenGL 02/21/2002 15-462 Graphics I 38

Reminders Assignment 3 due tonight Assignment 4 out some time today Midterm will cover curves and surfaces Next Tuesday: Textures? Next Thursday: John Ketchpaw 02/21/2002 15-462 Graphics I 39