Computer Graphics
Si Lu
Fall 2017
http://web.cecs.pdx.edu/~lusi/CS447/CS447_547_Comp uter_Graphics.htm 11/20/2017
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
http://web.cecs.pdx.edu/~lusi/CS447/CS447_547_Comp uter_Graphics.htm 11/20/2017
2
3
n Places where a function f(x,y,z)=0
2 2 2
n Various results are called blobs or metaballs
Rendered with POVray. Not everything is a blob, but the characters are.
n ci and i are parameters
1
blobs
n i i i
i i
2
c x
n Raytracing - find intersections with Newton’s method
n Marching Cubes algorithm n Also used for finding iso-surfaces, or level sets, in volume data
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
n Difficult to render n Difficult to control when animating
n 1D for curves: t n 2D for surfaces: (s,t)
n A function that takes parameter values and gives back 3D points
t 1 Mapping:F:t→(x,y) 1 (Fx(t), Fy(t))
n Polygon meshes have as many parameters as there are vertices (at least)
n The parameter t n Some user specified control points, x0 and x1
1 1 1
n t and 1-t are the basis functions
n (x0,y0,z0) and (x1,y1,z1) are the control points n They control the shape and position of the curve
1 1 1
n The term spline dates from engineering drawing, where a spline was a piece of flexible wood used to draw smooth curves n The control points are adjusted by the user to control the shape of the curve
n The endpoints of the curve n The parametric derivatives of the curve at the endpoints (tangents with length)
n That is enough to define a cubic Hermite spline
15
Source: http://en.wikipedia.org/wiki/File:Spline_(PSF).png
1
1
Start Point End Point Start Tangent End Tangent
n For some constants a, b, c and d derived from the control points, but how?
n The curve must pass through x0 when t=0 n The derivative must be x’0 when t=0 n The curve must pass through x1 when t=1 n The derivative must be x’1 when t=1
2 3
1 1 1
1 1 1 1
) 2 ( ) ( ) 1 3 2 ( ) 3 2 (
2 3 2 3 1 2 3 2 3 1
t t t t t t t t t x x x x x
1 1 2 1 1 1 1 3 2 3 2
2 3 1 1
t t t x x x x x
2 3 1 1 1 1 1 1
n Choice of basis determines how the control points influence the curve n In Hermite case, two control points define endpoints, and two more define parametric derivatives
3
Start Point End Point Point along start tangent Point along end Tangent
2
1
n There is a matrix to take Hermite control points to Bezier control points
d i d i i
i d i d i
n The Bernstein polynomials (the basis functions) sum to 1 and are everywhere positive
n E.g.: Convert to line segments with a subdivision algorithm
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
n Keep breaking the curve into sub-curves n Stop when the control points of each sub-curve are nearly collinear n Draw the control polygon - the polygon formed by the control points
and then evaluating the curve is the same as evaluating and then translating the curve
then evaluating the curve is the same as evaluating and then rotating the curve
graphics
everything else we will study are translation and rotation invariant
invariant
n Can do perspective transform of control points and then evaluate the curve
class of curves
n Allows more control, at the expense of more control points and higher degree polynomials n Control is not local, one control point influences entire curve
together into piecewise cubic curves
n Total curve can be broken into pieces, each of which is cubic n Local control: Each control point only influences a limited part of the curve n Interaction and design is much easier
“knot”
P0,0 P0,1 P0,2 P0,3 P1,0 P1,1 P1,2 P1,3
n C0, “C-zero”, point-wise continuous, curves share the same point where they join n C1, “C-one”, continuous derivatives, curves share the same parametric derivatives where they join n C2, “C-two”, continuous second derivatives, curves share the same parametric second derivatives where they join n Higher orders possible
P0,0 P0,1 P0,2 J P1,1 P1,2 P1,3
Disclaimer: PowerPoint curves are not Bezier curves, they are interpolating piecewise quadratic curves! This diagram is an approximation.
3 3 3 2 2 3 2 1 3 2 3 3 2 2 2 1 3
2 3 2 2 2 1 2
Bezier curve equation: Parametric derivative:
2 3 3 2 1
t
1 1
t
Evaluated at endpoint of curve (note proves tangent property):
P0,0 P0,1 P0,2 J P1,1 P1,2 P1,3
2 , 1 , 1 2 , 1 , 1
C1 requires equal parametric derivatives:
n If an object moves along the curve with constant parametric speed, there should be no sudden jump at the knots
n Requires that the tangents point in the same direction n Referred to as G1 geometric continuity n Curves could be made C1 with a re-parameterization: u=f(t) n The geometric version of C2 is G2, based on curves having the same radius of curvature across the knot
P0,0 P0,1 P0,2 J P1,1 P1,2 P1,3
2 , 1 , 1
for some k
n Same for large surface
38
n We will only look closely at uniform B-splines
n Linear B-splines have C0 continuity, cubic have C2, etc
39
n Not surprising for a cubic curve with 4 degrees of freedom
n Also called blending functions - they describe how to blend the control points to make the curve (see Shirley book ch. 15.6)
3 3 3 2 2 3 2 1 3 2 3 4 ,
6 1 3 3 3 1 6 1 3 6 4 6 1 3 3 1 6 1 ) ( ) ( t P t t t P t t P t t t P t B P t x
i i i
40
its endpoints?
hull? B0,4 B1,4 B2,4 B3,4
3 3 3 2 2 3 2 1 1 3 2
6 1 3 3 3 1 6 1 3 6 4 6 1 3 3 1 6 1 ) ( t P t t t P t t P t t t P t x
41
n The curve lies inside its convex hull
n Requires hacks or non-uniform B-splines
1 1 1 3 3 3 4 6 3 1 3 3 1 6 1 ) (
2 3 3 2 1
t t t P P P P t x
42
n The parameter value is offset by v n A different set of control points is needed
n Find the greatest integer less than or equal to t: v = floor(t) n Evaluate:
3 4 , i i v i
43
3 4 , mod ) ( i i n v i
44
n You repeat a control point three times n But then all derivatives also vanish (=0) at that point
n Then tangent aligns similar to Bezier curve
45
46
47