rendering curves and surfaces ed angel professor emeritus of computer science university of new...
TRANSCRIPT
![Page 1: Rendering Curves and Surfaces Ed Angel Professor Emeritus of Computer Science University of New Mexico 1 E. Angel and D.Shreiner: Interactive Computer](https://reader031.vdocuments.site/reader031/viewer/2022020320/5697c00d1a28abf838cc9592/html5/thumbnails/1.jpg)
Rendering Curves and Surfaces
Ed Angel
Professor Emeritus of Computer Science
University of New Mexico
1E. Angel and D.Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012
![Page 2: Rendering Curves and Surfaces Ed Angel Professor Emeritus of Computer Science University of New Mexico 1 E. Angel and D.Shreiner: Interactive Computer](https://reader031.vdocuments.site/reader031/viewer/2022020320/5697c00d1a28abf838cc9592/html5/thumbnails/2.jpg)
2E. Angel and D.Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012
Objectives
• Introduce methods to draw curves Approximate with lines
Finite Differences
•Derive the recursive method for evaluation of Bezier curves and surfaces
•Learn how to convert all polynomial data to data for Bezier polynomials
![Page 3: Rendering Curves and Surfaces Ed Angel Professor Emeritus of Computer Science University of New Mexico 1 E. Angel and D.Shreiner: Interactive Computer](https://reader031.vdocuments.site/reader031/viewer/2022020320/5697c00d1a28abf838cc9592/html5/thumbnails/3.jpg)
3E. Angel and D.Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012
Evaluating Polynomials
•Simplest method to render a polynomial curve is to evaluate the polynomial at many points and form an approximating polyline
•For surfaces we can form an approximating mesh of triangles or quadrilaterals
•Use Horner’s method to evaluate polynomials
p(u)=c0+u(c1+u(c2+uc3))
3 multiplications/evaluation for cubic
![Page 4: Rendering Curves and Surfaces Ed Angel Professor Emeritus of Computer Science University of New Mexico 1 E. Angel and D.Shreiner: Interactive Computer](https://reader031.vdocuments.site/reader031/viewer/2022020320/5697c00d1a28abf838cc9592/html5/thumbnails/4.jpg)
4E. Angel and D.Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012
Finite Differences
€
Δ(0)p( ku ) = p( ku )
€
Δ(1)p( ku ) = p( k +1u ) − p( ku )
€
Δ(m+1)p( ku ) = Δ(m )p( k +1u ) − Δ(m )p( ku )
For equally spaced {uk} we define finite differences
For a polynomial of degree n, the nth finite difference is constant
![Page 5: Rendering Curves and Surfaces Ed Angel Professor Emeritus of Computer Science University of New Mexico 1 E. Angel and D.Shreiner: Interactive Computer](https://reader031.vdocuments.site/reader031/viewer/2022020320/5697c00d1a28abf838cc9592/html5/thumbnails/5.jpg)
5E. Angel and D.Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012
Building a Finite Difference Table
p(u)=1+3u+2u2+u3
![Page 6: Rendering Curves and Surfaces Ed Angel Professor Emeritus of Computer Science University of New Mexico 1 E. Angel and D.Shreiner: Interactive Computer](https://reader031.vdocuments.site/reader031/viewer/2022020320/5697c00d1a28abf838cc9592/html5/thumbnails/6.jpg)
6E. Angel and D.Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012
Finding the Next Values
Starting at the bottom, we can work up generating new values for the polynomial
![Page 7: Rendering Curves and Surfaces Ed Angel Professor Emeritus of Computer Science University of New Mexico 1 E. Angel and D.Shreiner: Interactive Computer](https://reader031.vdocuments.site/reader031/viewer/2022020320/5697c00d1a28abf838cc9592/html5/thumbnails/7.jpg)
7E. Angel and D.Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012
deCasteljau Recursion
•We can use the convex hull property of Bezier curves to obtain an efficient recursive method that does not require any function evaluations
Uses only the values at the control points
•Based on the idea that “any polynomial and any part of a polynomial is a Bezier polynomial for properly chosen control data”
![Page 8: Rendering Curves and Surfaces Ed Angel Professor Emeritus of Computer Science University of New Mexico 1 E. Angel and D.Shreiner: Interactive Computer](https://reader031.vdocuments.site/reader031/viewer/2022020320/5697c00d1a28abf838cc9592/html5/thumbnails/8.jpg)
8E. Angel and D.Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012
Splitting a Cubic Bezier
p0, p1 , p2 , p3 determine a cubic Bezier polynomialand its convex hull
Consider left half l(u) and right half r(u)
![Page 9: Rendering Curves and Surfaces Ed Angel Professor Emeritus of Computer Science University of New Mexico 1 E. Angel and D.Shreiner: Interactive Computer](https://reader031.vdocuments.site/reader031/viewer/2022020320/5697c00d1a28abf838cc9592/html5/thumbnails/9.jpg)
9E. Angel and D.Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012
l(u) and r(u)
Since l(u) and r(u) are Bezier curves, we should be able tofind two sets of control points {l0, l1, l2, l3} and {r0, r1, r2, r3}that determine them
![Page 10: Rendering Curves and Surfaces Ed Angel Professor Emeritus of Computer Science University of New Mexico 1 E. Angel and D.Shreiner: Interactive Computer](https://reader031.vdocuments.site/reader031/viewer/2022020320/5697c00d1a28abf838cc9592/html5/thumbnails/10.jpg)
10E. Angel and D.Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012
Convex Hulls
{l0, l1, l2, l3} and {r0, r1, r2, r3}each have a convex hull thatthat is closer to p(u) than the convex hull of {p0, p1, p2, p3}This is known as the variation diminishing property.
The polyline from l0 to l3 (= r0) to r3 is an approximation to p(u). Repeating recursively we get better approximations.
![Page 11: Rendering Curves and Surfaces Ed Angel Professor Emeritus of Computer Science University of New Mexico 1 E. Angel and D.Shreiner: Interactive Computer](https://reader031.vdocuments.site/reader031/viewer/2022020320/5697c00d1a28abf838cc9592/html5/thumbnails/11.jpg)
11E. Angel and D.Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012
Equations
Start with Bezier equations p(u)=uTMBp
l(u) must interpolate p(0) and p(1/2)
l(0) = l0 = p0
l(1) = l3 = p(1/2) = 1/8( p0 +3 p1 +3 p2 + p3 )
Matching slopes, taking into account that l(u) and r(u)only go over half the distance as p(u)
l’(0) = 3(l1 - l0) = p’(0) = 3/2(p1 - p0 )l’(1) = 3(l3 – l2) = p’(1/2) = 3/8(- p0 - p1+ p2 + p3)
Symmetric equations hold for r(u)
![Page 12: Rendering Curves and Surfaces Ed Angel Professor Emeritus of Computer Science University of New Mexico 1 E. Angel and D.Shreiner: Interactive Computer](https://reader031.vdocuments.site/reader031/viewer/2022020320/5697c00d1a28abf838cc9592/html5/thumbnails/12.jpg)
12E. Angel and D.Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012
Efficient Form
l0 = p0
r3 = p3
l1 = ½(p0 + p1)r1 = ½(p2 + p3)l2 = ½(l1 + ½( p1 + p2))r1 = ½(r2 + ½( p1 + p2))l3 = r0 = ½(l2 + r1)
Requires only shifts and adds!
![Page 13: Rendering Curves and Surfaces Ed Angel Professor Emeritus of Computer Science University of New Mexico 1 E. Angel and D.Shreiner: Interactive Computer](https://reader031.vdocuments.site/reader031/viewer/2022020320/5697c00d1a28abf838cc9592/html5/thumbnails/13.jpg)
13E. Angel and D.Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012
Every Curve is a Bezier Curve
• We can render a given polynomial using the recursive method if we find control points for its representation as a Bezier curve
• Suppose that p(u) is given as an interpolating curve with control points q
• There exist Bezier control points p such that
• Equating and solving, we find p=MB-1MI
p(u)=uTMIq
p(u)=uTMBp
![Page 14: Rendering Curves and Surfaces Ed Angel Professor Emeritus of Computer Science University of New Mexico 1 E. Angel and D.Shreiner: Interactive Computer](https://reader031.vdocuments.site/reader031/viewer/2022020320/5697c00d1a28abf838cc9592/html5/thumbnails/14.jpg)
14E. Angel and D.Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012
Matrices
Interpolating to Bezier
B-Spline to Bezier
10006
53
2
3
3
13
1
2
33
6
50001
1MM IB
1410
0420
0240
0141
1MM SB
![Page 15: Rendering Curves and Surfaces Ed Angel Professor Emeritus of Computer Science University of New Mexico 1 E. Angel and D.Shreiner: Interactive Computer](https://reader031.vdocuments.site/reader031/viewer/2022020320/5697c00d1a28abf838cc9592/html5/thumbnails/15.jpg)
15E. Angel and D.Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012
Example
These three curves were all generated from the sameoriginal data using Bezier recursion by converting allcontrol point data to Bezier control points
Bezier Interpolating B Spline
![Page 16: Rendering Curves and Surfaces Ed Angel Professor Emeritus of Computer Science University of New Mexico 1 E. Angel and D.Shreiner: Interactive Computer](https://reader031.vdocuments.site/reader031/viewer/2022020320/5697c00d1a28abf838cc9592/html5/thumbnails/16.jpg)
16E. Angel and D.Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012
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 kept new
original and discarded
![Page 17: Rendering Curves and Surfaces Ed Angel Professor Emeritus of Computer Science University of New Mexico 1 E. Angel and D.Shreiner: Interactive Computer](https://reader031.vdocuments.site/reader031/viewer/2022020320/5697c00d1a28abf838cc9592/html5/thumbnails/17.jpg)
17E. Angel and D.Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012
Second Subdivision
16 final points for1 of 4 patches created
![Page 18: Rendering Curves and Surfaces Ed Angel Professor Emeritus of Computer Science University of New Mexico 1 E. Angel and D.Shreiner: Interactive Computer](https://reader031.vdocuments.site/reader031/viewer/2022020320/5697c00d1a28abf838cc9592/html5/thumbnails/18.jpg)
18E. Angel and D.Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012
Normals
•For rendering we need the normals if we want to shade
Can compute from parametric equations
Can use vertices of corner points to determine
OpenGL can compute automatically
v
vu
u
vu
),(),( ppn
![Page 19: Rendering Curves and Surfaces Ed Angel Professor Emeritus of Computer Science University of New Mexico 1 E. Angel and D.Shreiner: Interactive Computer](https://reader031.vdocuments.site/reader031/viewer/2022020320/5697c00d1a28abf838cc9592/html5/thumbnails/19.jpg)
19E. Angel and D.Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012
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
![Page 20: Rendering Curves and Surfaces Ed Angel Professor Emeritus of Computer Science University of New Mexico 1 E. Angel and D.Shreiner: Interactive Computer](https://reader031.vdocuments.site/reader031/viewer/2022020320/5697c00d1a28abf838cc9592/html5/thumbnails/20.jpg)
20E. Angel and D.Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012
Quadrics
• Any quadric can be written as the quadratic form
pTAp+bTp+c=0 where p=[x, y, z]T
with A, b and c giving the coefficients• Render by ray casting
Intersect with parametric ray p()=p0+d that passes through a pixel
Yields a scalar quadratic equation• No solution: ray misses quadric• One solution: ray tangent to quadric• Two solutions: entry and exit points