Intro to Modeling Modeling in 3D

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

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

Curves and Surfaces Computer Graphics I Lecture 9

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

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

3D Modeling Parametric Curves & Surfaces

Curves and Surfaces Computer Graphics I Lecture 10

OUTLINE. Quadratic Bezier Curves Cubic Bezier Curves

Bezier Curves, B-Splines, NURBS

Curves and Surface I. Angel Ch.10

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

Surface and Solid Geometry. 3D Polygons

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

Curves and Surfaces 1

Information Coding / Computer Graphics, ISY, LiTH. Splines

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

Intro to Curves Week 1, Lecture 2

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

An introduction to interpolation and splines

Design considerations

Intro to Curves Week 4, Lecture 7

Central issues in modelling

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

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

Computer Graphics Curves and Surfaces. Matthias Teschner

Geometric Modeling of Curves

CS-184: Computer Graphics

CS770/870 Spring 2017 Ray Tracing Implementation

08 - Designing Approximating Curves

Need for Parametric Equations

Dgp _ lecture 2. Curves

Introduction to Computer Graphics

CHAPTER 1 Graphics Systems and Models 3

CEng 477 Introduction to Computer Graphics Fall 2007

Sung-Eui Yoon ( 윤성의 )

Computergrafik. Matthias Zwicker Universität Bern Herbst 2016

Review of Tuesday. ECS 175 Chapter 3: Object Representation

Polygon Meshes and Implicit Surfaces

Polygon Meshes and Implicit Surfaces

(Spline, Bezier, B-Spline)

11/1/13. Polygon Meshes and Implicit Surfaces. Shape Representations. Polygon Models in OpenGL. Modeling Complex Shapes

Rendering. Basic Math Review. Rasterizing Lines and Polygons Hidden Surface Remove Multi-pass Rendering with Accumulation Buffers.

CS337 INTRODUCTION TO COMPUTER GRAPHICS. Describing Shapes. Constructing Objects in Computer Graphics. Bin Sheng Representing Shape 9/20/16 1/15

Computergrafik. Matthias Zwicker. Herbst 2010

CS123 INTRODUCTION TO COMPUTER GRAPHICS. Describing Shapes. Constructing Objects in Computer Graphics 1/15

Lecture IV Bézier Curves

LECTURE #6. Geometric Modelling for Engineering Applications. Geometric modeling for engineering applications

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

CS 325 Computer Graphics

CSCI 4620/8626. Coordinate Reference Frames

CS-184: Computer Graphics. Today

The goal is the definition of points with numbers and primitives with equations or functions. The definition of points with numbers requires a

ECE 600, Dr. Farag, Summer 09

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

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

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

Lecture 9: Introduction to Spline Curves

3.2 THREE DIMENSIONAL OBJECT REPRESENTATIONS

Curves. Computer Graphics CSE 167 Lecture 11

The Graphics Pipeline. Interactive Computer Graphics. The Graphics Pipeline. The Graphics Pipeline. The Graphics Pipeline: Clipping

Geometric Queries for Ray Tracing

Curves and Surfaces. Shireen Elhabian and Aly A. Farag University of Louisville

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

2D rendering takes a photo of the 2D scene with a virtual camera that selects an axis aligned rectangle from the scene. The photograph is placed into

Ray Tracing Basics I. Computer Graphics as Virtual Photography. camera (captures light) real scene. photo. Photographic print. Photography: processing

COMPUTER AIDED ENGINEERING DESIGN (BFF2612)

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

9. Three Dimensional Object Representations

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

Curve and Surface Basics

End-Term Examination

GEOMETRIC TOOLS FOR COMPUTER GRAPHICS

Interactive Graphics Using Parametric Equations (Day 2)

Werner Purgathofer

Surface Modeling. Polygon Tables. Types: Generating models: Polygon Surfaces. Polygon surfaces Curved surfaces Volumes. Interactive Procedural

3D Modeling: Surfaces

Computer Graphics I Lecture 11

Page 1. Area-Subdivision Algorithms z-buffer Algorithm List Priority Algorithms BSP (Binary Space Partitioning Tree) Scan-line Algorithms

CSE528 Computer Graphics: Theory, Algorithms, and Applications

Appendix E Calculating Normal Vectors

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

Topic #1: Rasterization (Scan Conversion)

Computer Graphics II

The Free-form Surface Modelling System

9. Visible-Surface Detection Methods

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

Introduction to Geometry. Computer Graphics CMU /15-662

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

Write C++/Java program to draw line using DDA and Bresenham s algorithm. Inherit pixel class and Use function overloading.

Rational Bezier Curves

Splines. Connecting the Dots

Lecture 25: Bezier Subdivision. And he took unto him all these, and divided them in the midst, and laid each piece one against another: Genesis 15:10

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

INF3320 Computer Graphics and Discrete Geometry

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

8.1 Geometric Queries for Ray Tracing

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

CSE328 Fundamentals of Computer Graphics: Concepts, Theory, Algorithms, and Applications

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

Visible Surface Detection Methods

Transcription:

Intro to Modeling Modeling in 3D Polygon sets can approximate more complex shapes as discretized surfaces 2 1

2 3 Curve surfaces in 3D Sphere, ellipsoids, etc Curved Surfaces Modeling in 3D ) ( 2 2 2 2 r z y x 4 Solid Models in 3D Sphere, ellipsoids, etc Modeling in 3D ) ( 2 2 2 2 r z y x

Modeling in 3D Solid Models in 3D Boolean solids 5 Polygons Multi-sided planar element composed of edges and vertices. Vertices (singular vertex) are represented by points Edges connect vertices as line segments (x2,y2) E1 (x1,y1) E3 E2 (x3,y3) 6 3

Polygons Simple polygons - no edges cross Non-simple - some edges cross Simple Non-simple 7 Polygons Convex Polygon - a polygon that has no included angles larger than 180 degrees Concave Polygon - has at least one included angle greater than 180 degrees Convex Concave 8 4

Polygons Test for convexity- any line segment drawn between two points inside a polygon must remain inside the polygon if the poly is convex Convex Concave 9 Polygons A concave polygon can be broken up into two or more convex polygons OpenGL assumes all polygons are simple and convex 10 5

Rasterizing Polygons Assume that all polygons lie on the image plane (2D), then rasterization is to fill in pixels lying within a closed polygon and to do so efficiently To do this, algorithm needs to determine if a pixel is inside or outside a polygon How do we do this?? 11 Rasterizing Polygons Scan Line Approaches: - Inside test: Point P is inside a polygon iff a scanline intersects polygon edges an odd numberof times moving from P in either direction (inside) 12 6

Rasterizing Polygons Inside test special cases: - Horizontal edges can be ignored -Use Min-max test when scanline passes thru vertex Min-max: count twice if slope changes sign count once otherwise 13 Rasterizing Polygons Inside test: To fill polygons, one scanline at a time determine which pixels are inside and set "on" 14 7

Rasterizing Polygons Faster is to fill polygons, one scanline at a time determine which pixels intersect and sort by edge Scanline fill algorithm For each scanline: Find intersections Sort intersections Fill in pixels between pairs of intersections But, intersection calculations are expensive 15 Rasterizing Polygons Faster still, use edge coherence - Many edges that intersect scanline s intersect scanline s+1 Compute scanline intersection: y = mx + b and y s = s, then s = mx s + b or x s = (s-b)/m Compute difference in next scanline for intersection y s+1 = s+1, s+1 = mx s+1 + b or x s+1 = (s +1 - b)/m and, x s+1 = x s + 1/m <= USE THIS TO UPDATE Edge tables allow us to define in efficient, easy manner 16 8

Modeling in 3D 17 Defining 3D Polygons 3D Polygons live in 3D 18 9

Defining 3D Polygons 3D Polygons are truncated planes in 3-space E1 (x1,y1,z1) (x2,y2,z2) E2 E3 (x3,y3,z3) Express given the vertex and edge coordinates Start with the generic form of a plane Ax + By + Cz + D = 0 19 Defining 3D Polygons Vertices and edges are ordered, CW or CCW, usually counter clockwise Therefore, edges are directed line segments and may be treated as vectors (x2,y2,z2) E2 E1 E3 (x3,y3,z3) (x1,y1,z1) 20 10

Defining 3D Polygons Every plane has a vector n normal (perpendicular, orthogonal) to it From two vectors that line on the plane, we can use the cross product to find the normal, n = u v v P u 21 Vector Operations Apply the right hand rule Cross product results in a vector 22 11

Vector Operations Dot product can be used to define angles: For example, assume w & v are unit length v and = cos -1 ( w v ) projection w v w Also generalizes for non-normal vectors (see text) 23 Defining 3D Polygons In our plane equation: Ax + By + Cz + D = 0, [A,B,C] T = the normal of the plane From the edges find two vectors Use the cross product to find the normal, giving us A, B, C Then, to find D, plug in any vertex into the equation and solve for D 24 12

Defining 3D Polygons Once we know our plane equation: Ax + By + Cz + D = 0, we still need to manage the truncation which leads to the polygon itself Functionally, we will need to do this to know if a point lies in a polygon or not, for example 25 Defining 3D Polygons To do this, we can project the 3d polygon into 2d and see if the point is in the 2d z using the inside test (xi,yi,zi) y x (xi,yi ) 26 13

Defining 3D Polygons Project 3d to 2d based on largest of A,B,C z (xi,yi,zi) y This example: Z (or C) is principal component of N, normal so project on to xy-plane x (xi,yi ) 27 Z-buffer For 3D with multiple polygons, must deal with visibility image plane Project vertices into image plane and with projected vertex include depth in additional depth- or Z-buffer 28 14

Z-buffer Scan convert each projected polygon: For each polygon in scene project verticies for each pixel inside poly calculate z if z < closest draw into frame buffer update z buffer 29 Curves and Surfaces 15

Curves Curves are one dimensional entities where the function is nonlinear Curves 31 Representations for curves Parametric representation x = x(u), y = y(u) or simply p(u) where p = x y - More robust and general than other forms - Gives better control over curves and surfaces Notation: p(u) = c 0 + c 1 u + c 2 u 2 where each c is a vector, c i = c ix c iy 32 16

Representations for curves Example, quadric parametric curve: p(u) = c 0 + c 1 u + c 2 u 2 Like curve: x = 3u 2 y = 2u + 3 for u = [-1,1] c 0 = 0 c 1 = 0 c 2 = 3 2 3 0 Note, more coefficients than a quadratic 33 Representations for curves Parametric curve, p(u) can as easily represent a curve in 3D (x,y,z) Simply: x = f x (u) y = fy(u) z = f z (u) Quadric coefs become: c ox c oy c oz c 1x c 1y c 1z c 0 = c 1 = c 2 = c 2x c 2y c 2z 34 17

Parametric Cubic (pc) curves Extension of quadrics to cubics Represented as: p(u) = c 0 + c 1 u + c 2 u 2 + c 3 u 3 Also called Hermite curves after the 17th century mathematician 35 Parametric Cubic (pc) curves Algebraic form: p(u) = c 0 + c 1 u + c 2 u 2 + c 3 u 3 (Note,unless otherwise specified u goes from 0,1) Not very intuitive, 12 values of c Instead want a better specify the curve More intuitive: control by start point p(0) and ending point p(1) and their derivatives 36 18

Parametric Cubic (pc) curves From: p(u) = c 0 + c 1 u + c 2 u 2 + c 3 u 3 Build a geometric form in order to specify a curves by their end points and tangents p(1) p (0) p (1) p(0) 37 Parametric Cubic curves This leads to the Geometric Form: p(u) = F 1 (u)p(0) + F 2 (u)p(1) + F 3 (u)p (0) + F 4 (u)p (1) where: F 1 (u) = 2u 3 3u 2 +1 F 2 (u) = -2u 3 + 3u 2 F 3 (u) = u 3 2u 2 + u F 4 (u) = u 3 u 2 38 19

F curves: Hermite curves basis 39 Joining Multiple Segments use p = [p 0 p 1 p 2 p 3 ] T use p = [p 3 p 4 p 5 p 6 ] T Get continuity at join points but not continuity of derivatives C0, C1, C2 continuity 40 20

Bezier Curves Family of curves developed in the 1970's by Bezier, a engineer for Renault, car manufacturer Bezier's curves are only guaranteed to pass through the end points, but other control points controlled the derivative at the end points Specifically, the tangent was controlled by the next control point in, the 2nd derivative by the second control point in, and the nth derivative by the nth and so on... 41 Bezier Curves 42 21

Bezier Curves The general form of the Bezier curve is: n p(u) = p i f i (u) 0 < u < 1 i=0 Vertices p control the curve and blending functions, f i (u), that satisfy the "derivative" condition Bernstein polynomials were a family of functions that were chosen by Bezier to satisfy his needs, these are not the only functions that could be used though 43 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 reach all the input data, we cannot be too far away Bezier curve p 1 p 2 convex hull p 0 p 3 44 22

Bernstein Polynomials The blending functions are a special case of the Bernstein polynomials d! k d k bkd ( u) u (1 u) k!( d k)! These polynomials give the blending polynomials for any degree Bezier form - All zeros at 0 and 1 - For any degree they all sum to 1 - They are all between 0 and 1 inside (0,1) 45 Bezier Curves p(u) = (1-u) 2 p 0 + 2u(1-u)p 1 + u 2 p 2 p1 p2 p0 46 23

n = 3 n = 5 n = 4 n = 6 47 Bezier Curves Bezier curves have intuitive control, are nicely formed, convex hull of all points 48 24

B Splines One problem with the curves we have looked at is that changing a single control point affects the whole curve (this is called global propogation,) Also, depends on # of control pts B-Splines offer an alternative, to only affect the local region if a single control point is modified (i.e. local propogation) 49 B Splines B-splines are also called Basis Splines They have a form similar to Bezier, B- splines are defined as: n p(u) = p i f i,k (u) i=0 0 < u < n + 2 - k where n +1 is the number of control points and k controls the degree of the blending (or basis) functions 50 25

B Splines B-splines' blending functions are defined recursively: and f i,1 (u) = 1 if t i < u < t i +1 = 0 otherwise f i,m (u) = m goes from 2 to k (u - t i ) f i,m-1 (u) (u - t i + m ) f i+1,m-1 (u) _ t i+m-1 -t i t i+m -t i+1 t i 's are knot points relating u to control points, p i 51 B Splines Knot points,t i 's, follow along like this: t i = 0 if i < k t i = i - k + 1 if k < i < n t i = n- k + 2 if i > n 52 26

B Splines For 6 control pts & k = 1, n= 5 and 0 < u < 6 We get the degenerate case: p(u) = p 0 0 < u < 1 p(u) = p 1 1 < u < 2 p(u) = p 2 2 < u < 3 p(u) = p 3 3 < u < 4 p(u) = p 4 4 < u < 5 p(u) = p 5 5 < u < 6 53 B Splines 54 27

B Splines For 6 control pts & k = 2, n= 5 and 0 < u < 5 We get a linear average of neighbors: p(u) = (1 - u)p 0 + u p 1 0 < u < 1 p(u) = (2 - u)p 1 + (u - 1)p 2 1 < u < 2 p(u) = (3 - u)p 2 + (u - 2)p 3 2 < u < 3 p(u) = (4 - u)p 3 + (u - 3)p 4 3 < u < 4 p(u) = (5 - u)p 4 + (u - 4)p 5 4 < u < 5 55 B Splines 56 28

B Splines For 6 control pts & k = 3, n= 5 and 0 < u < 4 We get: for 0 < u < 1 p 1 (u) = (1 - u) 2 p 0 +.5u(4-3u) p 1 +.5 u 2 p 2 for 1 < u < 2 p 2 (u) =.5(2 - u) 2 p 1 +.5(-2u 2 + 6u - 3) p 2 +.5(u - 1) 2 p 3 for 2 < u < 3 p 3 (u) =.5(3 - u) 2 p 2 +.5(-2u 2 + 10u - 11) p 3 +.5(u - 2) 2 p 4 for 3 < u < 4 p 4 (u) =.5(4 - u) 2 p 3 +.5(-3u 2 + 20u - 32) p 4 + (u - 3) 2 p 5 57 B Splines Note, influence grows with degree k = 2 k = 3 k = 4 58 29

B Splines Thus, local influence of control points on curve as: 59 Cubic B-spline p(u) = u T M S p = b(u) T p MS 1 3 3 1 4 0 6 3 1 3 3 3 0 0 0 1 60 30

Rendering Curves How do we draw the curve, given p(u)? void evaluatecurve(u,pixelx,pixely) p(1) tangent p (0) p (1) tangent p(0) 61 Rendering Curves Polyline approximation p(1) p(0) piecewise linear discrete approximation 62 31

Curves vs. Surfaces Curves are one dimensional entities where the function is nonlinear Surfaces are formed from twodimensional functions - Linear functions give planes and polygons y Curves z x Surfaces 63 Curves vs. Surfaces Parametric curve, p(u) can as easily represent a curve in 3D (x,y,z) x = f x (u) y = fy(u) z = f z (u) u = 1 u = -1 64 32

Parametric surface is very similar: p(u,v) Curves vs. Surfaces Simply: x = f(u, v) y = f(u, v) z = f(u, v) (Just, more difficult to comprehend in a 2D representation, we must go behind the image plane) 65 Parametric Surfaces Surfaces require 2 parameters x=x(u,v) y=y(u,v) z=z(u,v) p(u,v) = [x(u,v), y(u,v), z(u,v)] T z Want same properties as curves: - Smoothness - Differentiability - Ease of evaluation y p(0,v) p(u,0) p(u,1) x p(1,v) 66 33

34 67 Bezier Patches p v b u b v u p ij j i j i ) ( ) ( ), ( 3 0 3 0 Patch lies in convex hull 68 B-Spline Patches v u p v b u b v u p T S S T ij j i j i M P M ) ( ) ( ), ( 3 0 3 0 defined region

Splitting a Cubic Bezier p 0, p 1,p 2,p 3 determine a cubic Bezier polynomial and its convex hull Consider left half l(u) and right half r(u) 69 l(u) and r(u) Since l(u) and r(u) are Bezier curves, we should be able to find two sets of control points {l 0, l 1, l 2, l 3 } and {r 0, r 1, r 2, r 3 } that determine them 70 35

Efficient Form l 0 = p 0 r 3 = p 3 l 1 = ½(p 0 + p 1 ) r 1 = ½(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 ) Requires only shifts and adds! 71 Surfaces Can apply the recursive method to surfaces if we recall that for a Bezier patch curves of constant u (or v) are Bezier curves in u (or v) First subdivide in u - Process creates new points - Some of the original points are discarded original and discarded original and kept new 72 36

Second Subdivision 16 final points for 1 of 4 patches created 73 Normals We can differentiate with respect to u and v to obtain the normal at any point p p( u, v) u x( u, v) / u y( u, v) / u z( u, v) / u p( u, v) v x( u, v) / v y( u, v) / v z( u, v) / v n p( u, v) p( u, v) u v 74 37

Utah Teapot Most famous data set in computer graphics Widely available as a list of 306 3D vertices and the indices that define 32 Bezier patches 75 38