computer graphics
play

Computer Graphics Si Lu Fall 2017 - PowerPoint PPT Presentation

Computer Graphics Si Lu Fall 2017 http://web.cecs.pdx.edu/~lusi/CS447/CS447_547_Comp uter_Graphics.htm 11/20/2017 Last time o Modeling Techniques 2 Today o More modeling techniques o Splines o Homework 5 available, due 11/29 in class o Pick


  1. Computer Graphics Si Lu Fall 2017 http://web.cecs.pdx.edu/~lusi/CS447/CS447_547_Comp uter_Graphics.htm 11/20/2017

  2. Last time o Modeling Techniques 2

  3. Today o More modeling techniques o Splines o Homework 5 available, due 11/29 in class o Pick a slot for grading Project 2 n https://docs.google.com/spreadsheets/d/1wiiB91GLX 3dkZMARjPR- PIA2qcI7lgcGGyzCAvMLZPY/edit#gid=0 3

  4. Implicit Functions o Some surfaces can be represented as the vanishing points of functions (defined over 3D space) Places where a function f(x,y,z)=0 n o Some objects are easy to represent this way n Spheres, ellipses, and similar n More generally, quadratic surfaces:        2 2 2 ax bx cy dy ez fz g 0 n Shapes depends on all the parameters a,b,c,d,e,f,g

  5. Blobs and Metaballs o Define the location of some points, p i o For each point, define a function on the distance to a given point, D (x,p i ) o Sum these functions up, and use them as an implicit function o Often, use Gaussian functions of distance, or other forms Various results are called blobs or metaballs n

  6. Example with Blobs Rendered with POVray. Not everything is a blob, but the characters are.

  7. Blob Math n blobs  o Implicit equation:    f ( x , y , z ) w w g ( x , y , z ) 0 0 i i  i 1 o The w i are weights – just numbers o The g i are functions, one common choice is: 2   x c i  g i ( x ) e  i c i and  i are parameters n

  8. Rendering Implicit Surfaces o Some methods can render them directly n Raytracing - find intersections with Newton’s method o For polygonal renderer, must convert to polygons n Marching Cubes algorithm n Also used for finding iso-surfaces , or level sets , in volume data

  9. Implicit Surfaces Summary o Advantages: n Good for organic looking shapes eg human body n Good for extracting surfaces from volume representations, such as water surfaces in fluid simulation n Easy inside/outside testing o Disadvantages: n Difficult to render Difficult to control when animating n

  10. What are Parametric Curves? o Define a parameter space 1D for curves: t n 2D for surfaces: ( s , t ) n o Define a mapping from parameter space to 3D points n A function that takes parameter values and gives back 3D points o The result is a parametric curve or surface ( F x ( t ), F y ( t )) Mapping: F:t → (x,y) 1 0 1 t 0

  11. Why Parametric Curves? o Parametric curves are intended to provide the generality of polygon meshes but with fewer parameters for smooth surfaces n Polygon meshes have as many parameters as there are vertices (at least) o Fewer parameters make it faster to create a curve, and easier to edit an existing curve o Normal vectors and texture coordinates can be easily defined everywhere o Parametric curves are easier to animate than polygon meshes

  12. Parametric Curves o We have seen the parametric form for a line:    x ( 1 t ) x tx 0 1    y ( 1 t ) y ty 0 1    z ( 1 t ) z tz 0 1 o Note that x, y and z are each given by an equation that involves: The parameter t n Some user specified control points, x 0 and x 1 n o This is an example of a parametric curve

  13. Basis Functions (first sighting) o A line is the sum of two functions multiplied by vectors:       x x x 0 1            y 1 t y t y       0 1       z z z       0 1 o A linear combination of basis functions n t and 1- t are the basis functions o The weights are called control points (x 0 ,y 0 ,z 0 ) and (x 1 ,y 1 ,z 1 ) are the control points n n They control the shape and position of the curve

  14. Hermite Spline o A spline is a parametric curve defined by control points n The term spline dates from engineering drawing, where a spline was a piece of flexible wood used to draw smooth curves The control points are adjusted by the user to control the n shape of the curve o A Hermite spline is a curve for which the user provides: n The endpoints of the curve The parametric derivatives of the curve at the endpoints n (tangents with length) o The parametric derivatives are dx/dt, dy/dt, dz/dt n That is enough to define a cubic Hermite spline

  15. Spline 15 Source: http://en.wikipedia.org/wiki/File:Spline_(PSF).png

  16. Control Point Interpretation End Tangent Start Tangent d x d x dt dt 1 0 x 1 End Point x 0 Start Point

  17. Hermite Spline (2) d x d x o Say the user provides x , x , 0 , 1 0 1 dt dt 0 1 o A cubic spline has degree 3, and is of the form:     3 2 x at bt ct d For some constants a, b, c and d derived from the control n points, but how? o We have constraints: The curve must pass through x 0 when t=0 n The derivative must be x’ 0 when t=0 n n The curve must pass through x 1 when t=1 n The derivative must be x’ 1 when t=1

  18. Hermite Spline (3)        a 2 x 2 x x x o Solving for the unknowns gives: 1 0 1 0       b 3 x 3 x x 2 x 1 0 1 0   c x 0  d x 0 o Rearranging gives:     2 3 0 0  3 t    3 2 x x ( 2 t 3 t )     1  2 3 0 1 2 t      3 2 x ( 2 t 3 t 1 )       or  x x x x x 0   1 0 1 0       1 1 0 0 3 2 x ( t t ) t 1         3 2 x ( t 2 t t )  1 2 1 0 1     0

  19. Basis Functions o A point on a Hermite curve is obtained by multiplying each control point by some function and summing

  20. Splines in 2D and 3D o For higher dimensions, define the control points in higher dimensions (that is, as vectors)      2 3 0 0 3 t       x x x x x     1 0 1 0  2 3 0 1 2 t            y y y y y         1 0 1 0  1 1 0 0 t         z z z z z       1 0 1 0  1 2 1 0   1    

  21. Bezier Curves (1) o Different choices of basis functions give different curves Choice of basis determines how the control points influence n the curve n In Hermite case, two control points define endpoints, and two more define parametric derivatives o For Bezier curves, two control points define endpoints, and two control the tangents at the endpoints in a geometric way

  22. Control Point Interpretation Point along start tangent x 1 x 3 End Point x x 2 0 Point along end Tangent Start Point

  23. Bezier Curves (2) o The user supplies d +1 control points, p i o Write the curve as:   d d           d i     d i  B t t 1 t d x t p B t   i i i i    i 0 o The functions B id are the Bernstein polynomials of degree d o This equation can be written as a matrix equation also n There is a matrix to take Hermite control points to Bezier control points

  24. Bezier Basis Functions for d =3

  25. Bezier Curves of Varying Degree

  26. Bezier Curve Properties o The first and last control points are interpolated o The tangent to the curve at the first control point is along the line joining the first and second control points o The tangent at the last control point is along the line joining the second last and last control points o The curve lies entirely within the convex hull of its control points The Bernstein polynomials (the basis functions) sum to 1 and n are everywhere positive o They can be rendered in many ways n E.g.: Convert to line segments with a subdivision algorithm

  27. Rendering Bezier Curves (1) o Evaluate the curve at a fixed set of parameter values and join the points with straight lines o Advantage: Very simple o Disadvantages: n Expensive to evaluate the curve at many points n No easy way of knowing how fine to sample points, and maybe sampling rate must be different along curve n No easy way to adapt. In particular, it is hard to measure the deviation of a line segment from the exact curve

  28. Rendering Bezier Curves (2) o Recall that a Bezier curve lies entirely within the convex hull of its control vertices o If the control vertices are nearly collinear, then the convex hull is a good approximation to the curve o Also, a cubic Bezier curve can be subdivided into two shorter curves that exactly cover the original o This suggests an algorithm: Keep breaking the curve into sub-curves n Stop when the control points of each sub-curve are nearly n collinear n Draw the control polygon - the polygon formed by the control points

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend