Download presentation
Presentation is loading. Please wait.
1
CS 376 Introduction to Computer Graphics 04 / 27 / 2007 Instructor: Michael Eckmann
2
Michael Eckmann - Skidmore College - CS 376 - Spring 2007 Today’s Topics Questions? Piecewise Cubic Parametric curves –Bezier blending functions –Splines –comparison of the different types Generalize to surfaces Speedups for polynomial evaluation quick comment on Shape Grammars Fractal geometry
3
Illumination Change this equation: I R = I aR k a O R + Sum all i [f radatten (d L ) I pRi O R (k d L ● N + W(theta)cos ns (phi))]which is INCORRECT to this one: I R = I aR k a O R + Sum all i [f radatten (d L ) I pRi ( O R k d L ● N + W(theta)cos ns (phi))] which is CORRECT NOTE: The object color O R is not to be multiplied by the specular term. Sorry. The above equation is for the red channel, do the same for green and blue channels. Recall... Ambient light as 3 components: I aR I aG I aB Point lights each as 3 components: I pR I pG I pB Objects with color: O R O G O B
4
Michael Eckmann - Skidmore College - CS 376 - Spring 2007 As stated earlier, the pieces of information defining a Bezier curve are 4 points. Therefore, the Geometry Matrix are these 4 points. P 1 and P 4 are the endpoints and P 2 and P 3 are the intermediate points that do not necessarily (usually don't) live on the curve. R 1 (the tangent at the first endpoint) = 3 [P 2 – P 1 ] R 4 (the tangent at the other endpoint) = 3 [P 4 – P 3 ] [ P 1 ] G = [ P 2 ] [ P 3 ] [ P 4 ] Q(t) = [ t 3 t 2 t 1 ] M G Bezier Basis Matrix and Blending Functions
5
Michael Eckmann - Skidmore College - CS 376 - Spring 2007 The Basis Matrix M for Bezier curves is: [ -1 3 -3 1 ] [ 3 6 3 0 ] [ -3 3 0 0 ] [ 1 0 0 0 ] Q(t) = [ t 3 t 2 t 1 ] M G So, what are the blending functions? Bezier Basis Matrix and Blending Functions
6
Michael Eckmann - Skidmore College - CS 376 - Spring 2007 The Blending functions are: -t 3 + 3t 2 -3t + 1 3t 3 + 6t 2 + 3t -3t 3 + 3t 2 t 3 These functions are the Bernstein polynomials which are of the form: C(n, k) t k (1 – t ) n-k where C(n,k) is the choose function. C(n,k) = n! / (k! ((n-k)!)) In the case where n=3 (cubic), we have k among 0,1,2,3, which gives one function per geometric element (point.) Bezier Basis Matrix and Blending Functions
8
Michael Eckmann - Skidmore College - CS 376 - Spring 2007 A nice feature of Bezier curves is: –Because the blending functions are symmetric to the line t=0.5, the sequence of points used to define a Bezier curve can be reversed without changing the shape of the curve. Both Bezier and Hermite curves are easy to make have G 1 or C 1 continuity at all the join points. It is not easy though to get C 2 continuity at the join points for Hermite and Bezier curves. Hermite and Bezier curves interpolate the points (that is, the curves go through the points). Splines are C 2 continuous. Bezier/Hermite Curves vs. Splines
9
Michael Eckmann - Skidmore College - CS 376 - Spring 2007 Splines are C 2 continuous. Natural cubic splines interpolate the control points and the coefficients of a natural cubic spline are dependent on all n control points. –expensive to invert an n+1 by n+1 matrix –moving one control point affects the entire curve B-splines are defined by m+1 control points, where m>=3. The control points are named P 0 through P m. –There are m-2 cubic polynomial, C 2 continuous curve segments joined together. These segments are named Q 3 through Q m. –The join points (as well as the endpoints) of the B-spline are called knots. There are m-1 knots. –moving one control point has only a local effect (changes four curve segments) –clearly the B-splines approximate (not interpolate) the control points –Let's look at the handout Splines
10
Michael Eckmann - Skidmore College - CS 376 - Spring 2007 Uniform = spacing between knots are equal (that is, the difference in t between knots is uniform) – without loss of generality we can set the spacing to 1, first t=0 and the next are 1,2,3,... –blending functions for all segments have same shape but are shifted Nonuniform = spacing between knots are unequal (see handout) –more flexibility to control the curve shape than uniform allows –2 or more consecutive knots that are the same reduce the continuity there (e.g., if we have 0 difference between 2 or more knots then continuity is reduced by 1 (i.e., C 2 -> C 1 continuity)) Rational = each spline curve segment is defined with ratio of polynomials –are invariant under rotation, scaling, translation AND perspective transformations of the control points. So, we can apply the perspective transform to the control points and then generate the perspectively transformed curve from the transformed control points to obtain the correct view of the curve. –in addition to the myriad of curves that can be produced, they can precisely define the conic sections (e.g. circle, ellipse, parabola, hyperbola) NURBS = NonUniform Rational B-Splines B-Splines
12
Michael Eckmann - Skidmore College - CS 376 - Spring 2007 NURBS = NonUniform Rational B-Splines –used frequently in graphics packages due to the properties just described Nonrational = each spline curve segment is defined as a polynomial (not a ratio of polynomials) –has the disadvantage (compared to rational B-splines) that they are not invariant to perspective transformations as well as cannot precisely describe the conics B-Splines
13
Michael Eckmann - Skidmore College - CS 376 - Spring 2007 Recall that we defined parametric cubic curves as Q(t) = T M G. For surfaces we define a parametric cubic surface with two parameters, hence Q(s,t) for some particular value of s, say s 1, Q(s 1,t) is a parametric curve. Also, for some particular value of t, say t 1, Q(s,t 1 ) is a parametric curve. [ G 1 (t) ] Q(s,t) = S M G(t) = S M [ G 2 (t) ] [ G 3 (t) ] [ G 4 (t) ] where each G i (t) is a parametric cubic. So, each G i (t) = T M G i The overall G(t) geometry matrix contains 16 geometry items (whereas for cubic curves, G contained 4 geometry items.) Curve Surfaces
15
Michael Eckmann - Skidmore College - CS 376 - Spring 2007 Horner's rule for evaluating polynomials –consider the x-coordinate parametric cubic: x(t) = a x t 3 + b x t 2 + c x t + d x evaluated as is, then you get –6 multiplies and 3 adds if you use Horner's rule, x(t) can be rewritten as: x(t) = [(a x t + b x )t + c x ]t + d x –3 multiplies and 3 adds –for all 3 coordinates, then you have 9 multiplies and 9 adds –we can do better Forward-difference calculations –generate successive values recursively by incrementing the previous value – x k+1 = x k + Δx k –Δx k is the forward difference Speedups for polynomial evaluation
16
Michael Eckmann - Skidmore College - CS 376 - Spring 2007 Forward-difference calculations –generate successive values recursively by incrementing the previous value x k+1 = x k + Δx k –Δx k is the forward difference –for parametric cubics if we divide our range of t into a set number of fixed intervals of size δ then x k = x(t k ) and x k+1 = x(t k+1 ) where t k+1 = t k + δ k=0,1,... x k = a x t k 3 + b x t k 2 + c x t k + d x x k+1 = a x t k+1 3 + b x t k+1 2 + c x t k+1 + d x = a x (t k +δ) 3 + b x (t k +δ) 2 + c x (t k +δ) + d x Δx k = x k+1 - x k = 3a x δt k 2 + (3a x δ 2 + 2b x δ)t k + (a x δ 3 + b x δ 2 + c x δ) Notice that Δx k is a quadratic polynomial in t Speedups for polynomial evaluation
17
Michael Eckmann - Skidmore College - CS 376 - Spring 2007 we can do the same kind of thing but this is the second forward-difference Δx k = Δx k-1 + Δ 2 x k-1 –Δ 2 x k-1 is the second forward difference... Δ 2 x k-1 = 6a x δt k-1 + 6a x δ 3 + 2b x δ 2 Notice that Δ 2 x k-1 is a linear polynomial in t we can do the same kind of thing but this is the third forward-difference Δ 2 x k-1 = Δ 2 x k-2 + Δ 3 x k-2 –Δ 3 x k-2 is the third forward difference... Δ 3 x k-2 = 6a x δ 3 which is a constant in t Speedups for polynomial evaluation
18
Michael Eckmann - Skidmore College - CS 376 - Spring 2007 x(t) = a x t 3 + b x t 2 + c x t + d x Δx k = 3a x δt k 2 + (3a x δ 2 + 2b x δ)t k + (a x δ 3 + b x δ 2 + c x δ) Δ 2 x k-1 = 6a x δt k-1 + 6a x δ 3 + 2b x δ 2 Δ 3 x k-2 = 6a x δ 3 We need initial values for x and the first and second forward differences when k = 0, t = 0 and we get the following x 0 = d x Δx 0 = a x δ 3 + b x δ 2 + c x δ Δ 2 x 0 = 6a x δ 3 + 2b x δ 2 and compute the first few x's and then to compute successive values of x it only takes 3 adds at each step: x k+1 = x k + Δx k Δx k = Δx k-1 + Δ 2 x k-1 Δ 2 x k-1 = Δ 2 x k-2 + Δ 3 x k-2 Speedups for polynomial evaluation
19
Michael Eckmann - Skidmore College - CS 376 - Spring 2007 To see the forward differences algorithm, see the handout with the two algorithms (the first is brute force --- not even using Horner's rule). The brute force uses 11 multiplies and 10 additions. Horner's rule algorithm requires 9 multiplies and 10 additions. The forward differences algorithm only takes 9 additions (and 0 multiplies) to calculate the next point coordinates (after some initialization that takes some multiplies and adds.) Speedups for polynomial evaluation
20
Michael Eckmann - Skidmore College - CS 376 - Spring 2007 See section 8-24 in our text. It's short. I suggest you read it and attend Tim Gildea's presentation of his thesis "LSystem Viewer: Interactive Visualization Software for Parametric DOL-Systems" which is at 8pm, Monday April 30 th in Harder room 202. Two other students will present their work before Tim. 6:30 p.m. Kellen Affleck 7:15 p.m. Max Levine 8:00 p.m. Tim Gildea Shape Grammars
21
Michael Eckmann - Skidmore College - CS 376 - Spring 2007 Up until now, we have only discussed objects (Euclidean shapes) being described by equations. These methods are good for man-made objects that are smooth and have regular shapes. Natural objects like mountains, clouds, terrain, trees, etc. have surface shapes that aren't well described by equations. Instead these are better described by “procedures”. Fractal methods are a way to make a procedural description of a surface/object. Fractal objects have 2 important characteristics –infinite detail at every point –self-similarity between the parts to the overall features (see next slide) Fractal objects are specified by a procedure that does an operation repeatedly. Fractal Geometry
23
Michael Eckmann - Skidmore College - CS 376 - Spring 2007 Zooming in enough on an equation defined surface (Euclidean shape) will reveal the limit to the level of detail in the shape. Zooming in on a Fractal object will reveal the “limitless” detail in the shape. (I'll try to draw figure 8-67 in text pg 480.) Fractals are defined infinitely, but of course in graphics we will perform a finite number of steps and hence our objects will have finite dimensions. Fractal Geometry
24
Michael Eckmann - Skidmore College - CS 376 - Spring 2007 Self-similarity –entire object contains scaled down versions of itself as its subparts –each subpart is created by multiplying a scale factor by the whole object –each subpart can use the same scale factor or different ones –random variations can be employed -> statistically self-similar used for trees, leaves, etc. Fractal Geometry
25
Michael Eckmann - Skidmore College - CS 376 - Spring 2007 Fractal Dimension D –a description of the amount of variation in the structure of a fractal object. a line is 1 dimensional, a square is 2 dimensional if we subdivide a line into N equal parts, each part is the original scaled down by a factor of N = N 1/1 = N 1/d if we subdivide a square into N equal parts, each part is the original scaled down by a factor of sqrt(N) = N 1/2 = N 1/d if we subdivide the Koch snowflake into 4 equal parts, each part is the original scaled down by a factor of 3, hence 3 = 4 1/d = 4 1/1.26186 The dimension of the Koch snowflake fractal = d = log(4)/log(3) which is approx. 1.2618595 See the slide showing the Koch snowflake Fractal Geometry
26
Michael Eckmann - Skidmore College - CS 376 - Spring 2007 For deterministic, self-similar fractals we have Fractal initiator –start shape Fractal generator –the pattern that subparts of the initiator are replaced by The generation of the fractal is deterministic because we always replace a subpart of the initiator with the generator and we do this at each step exactly the same way every time. Example on the board (figure 8-70). Fractal Geometry
29
Michael Eckmann - Skidmore College - CS 376 - Spring 2007 For statistically, self-similar fractals we could have –a Fractal initiator and –randomly choose a generator from a set of generators to be the pattern to replace a subpart of the initiator at each step This is non-deterministic (won't get the same exact shape every time) due to the random choice of generator. Instead of random generators, –random scalings could be done or –something else that is random to make the fractal non-deterministic. see figure 8-80 for an example. Fractal Geometry
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.