College of Computer and Information Science, Northeastern UniversityApril 12, CS G140 Graduate Computer Graphics Prof. Harriet Fell Spring 2007 Lecture 6 – February 26, 2007
College of Computer and Information Science, Northeastern UniversityApril 12, Today’s Topics Bezier Curves and Splines Parametric Bicubic Surfaces Quadrics
College of Computer and Information Science, Northeastern UniversityApril 12, Curves A curve is the continuous image of an interval in n-space. Implicit f(x, y) = 0 x 2 + y 2 – R 2 = 0 Parametric (x(t), y(t)) = P(t) P(t) = tA + (1-t)B A B Generative proc (x, y)
College of Computer and Information Science, Northeastern UniversityApril 12, Curve Fitting We want a curve that passes through control points. How do we create a good curve? What makes a good curve?
College of Computer and Information Science, Northeastern UniversityApril 12, Axis Independence If we rotate the set of control points, we should get the rotated curve.
Local Control
College of Computer and Information Science, Northeastern UniversityApril 12, Variation Diminishing Never crosses a straight line more than the polygon crosses it.
College of Computer and Information Science, Northeastern UniversityApril 12, Continuity C 0 continuity C 1 continuity C 2 continuity G 2 continuity Not C 2 continuity
College of Computer and Information Science, Northeastern UniversityApril 12, How do we Fit Curves? Lagrange Interpolating Polynomial from mathworld The Lagrange interpolating polynomial is the polynomial of degree n-1 that passes through the n points, (x 1, y 1 ), (x 2, y 2 ), …, (x n, y n ), and is given by
College of Computer and Information Science, Northeastern UniversityApril 12, Example 1
College of Computer and Information Science, Northeastern UniversityApril 12, Polynomial Fit P(x) = -.5x(x-2)(x-3)(x-4)
College of Computer and Information Science, Northeastern UniversityApril 12, Piecewise Fit P a (x) = x (x ) 0 x 1.5 P b (x) = 5.4 x (x ) 1.5 x 2 P c (x) = 0 2 x 4
College of Computer and Information Science, Northeastern UniversityApril 12, Spline Curves
College of Computer and Information Science, Northeastern UniversityApril 12, Splines and Spline Ducks Marine Drafting Weights
College of Computer and Information Science, Northeastern UniversityApril 12, Drawing Spline Today (esc)
College of Computer and Information Science, Northeastern UniversityApril 12, Hermite Cubics p q Dp Dq P(t) = at 3 + bt 2 +ct +d P(0) = p P(1) = q P'(0) = Dp P'(1) = Dq
College of Computer and Information Science, Northeastern UniversityApril 12, Hermite Coefficients P(t) = at 3 + bt 2 +ct +d P(0) = p P(1) = q P'(0) = Dp P'(1) = Dq For each coordinate, we have 4 linear equations in 4 unknowns
College of Computer and Information Science, Northeastern UniversityApril 12, Boundary Constraint Matrix
College of Computer and Information Science, Northeastern UniversityApril 12, Hermite Matrix MHMH GHGH
College of Computer and Information Science, Northeastern UniversityApril 12, Hermite Blending Functions
College of Computer and Information Science, Northeastern UniversityApril 12, Splines of Hermite Cubics a C 1 spline of Hermite curves a G 1 but not C 1 spline of Hermite curves The vectors shown are 1/3 the length of the tangent vectors.
College of Computer and Information Science, Northeastern UniversityApril 12, Computing the Tangent Vectors Catmull-Rom Spline p1 p1 p2 p2 p3 p3 p4 p4 p 5 P(0) = p 3 P(1) = p 4 P'(0) = ½ (p 4 - p 2 ) P'(1) = ½ (p 5 - p 3 )
College of Computer and Information Science, Northeastern UniversityApril 12, Cardinal Spline The Catmull-Rom spline P(0) = p 3 P(1) = p 4 P'(0) = ½ (p 4 - p 2 ) P'(1) = ½ (p 5 - p 3 ) is a special case of the Cardinal spline P(0) = p 3 P(1) = p 4 P'(0) = (1 - t)(p 4 - p 2 ) P'(1) = (1 - t)(p 5 - p 3 ) 0 ≤ t ≤ 1 is the tension.
College of Computer and Information Science, Northeastern UniversityApril 12, Drawing Hermite Cubics How many points should we draw? Will the points be evenly distributed if we use a constant increment on t ? We actually draw Bezier cubics.
College of Computer and Information Science, Northeastern UniversityApril 12, General Bezier Curves
College of Computer and Information Science, Northeastern UniversityApril 12, Low Order Bezier Curves p0p0 n = 0 b 0,0 (t) = 1 B(t) = p 0 b 0,0 (t) = p 0 0 ≤ t ≤ 1 p0p0 n = 1 b 0,1 (t) = 1 - t b 1,1 (t) = t B(t) = (1 - t) p 0 + t p 1 0 ≤ t ≤ 1 p1p1 p0p0 n = 2b 0,2 (t) = (1 - t) 2 b 1,2 (t) = 2t (1 - t) b 2,2 (t) = t 2 B(t) = (1 - t) 2 p 0 + 2t (1 - t)p 1 + t 2 p 2 0 ≤ t ≤ 1 p1p1 p2p2
College of Computer and Information Science, Northeastern UniversityApril 12, Bezier Curves Bezier Arch p q r s n = 3b 0,3 (t) = (1 - t) 3 b 1,3 (t) = 3t (1 - t) 2 b 2,3 (t) = 3t 2 (1 - t) b 2,3 (t) = t 3 B(t) = (1 - t) 3 p + 3t (1 - t) 2 q + 3t 2 (1 - t)r + t 3 s 0 ≤ t ≤ 1
College of Computer and Information Science, Northeastern UniversityApril 12, Bezier Matrix MBMB B(t) = (1 - t) 3 p + 3t (1 - t) 2 q + 3t 2 (1 - t)r + t 3 s 0 ≤ t ≤ 1 B(t) = a t 3 + bt 2 + ct + d 0 ≤ t ≤ 1 GBGB
College of Computer and Information Science, Northeastern UniversityApril 12, Geometry Vector
College of Computer and Information Science, Northeastern UniversityApril 12, Properties of Bezier Curves
College of Computer and Information Science, Northeastern UniversityApril 12, Geometry of Bezier Arches p q r s Pick a t between 0 and 1 and go t of the way along each edge. B(t)B(t) Join the endpoints and do it again.
College of Computer and Information Science, Northeastern UniversityApril 12, Geometry of Bezier Arches p q r s We only use t = 1/2. pqrs = B(1/2) pq qr rs pqr qrs
drawArch(P, Q, R, S){ if (ArchSize(P, Q, R, S) <=.5 ) Dot(P); else{ PQ = (P + Q)/2; QR = (Q + R)/2; RS = (R + S)/2; PQR = (PQ + QR)/2; QRS = (QR + RS)/2; PQRS = (PQR + QRS)/2 drawArch(P, PQ, PQR, PQRS); drawArch(PQRS, QRS, RS, S); }
College of Computer and Information Science, Northeastern UniversityApril 12, Putting it All Together Bezier Archer and Catmull-Rom Splines
College of Computer and Information Science, Northeastern UniversityApril 12, Time for a Break
College of Computer and Information Science, Northeastern UniversityApril 12, Surface Patch P(u,v) 0 u, v 1 A patch is the continuous image of a square in n-space.
College of Computer and Information Science, Northeastern UniversityApril 12, Bezier Patch Geometry
College of Computer and Information Science, Northeastern UniversityApril 12, Bezier Patch P 00 P 10 P 01 P 02 P 03 P 11 P 12 P 13 P 20 P 30 P 21 P 22 P 23 P 31 P 32 P 33
College of Computer and Information Science, Northeastern UniversityApril 12, Bezier Patch Computation
College of Computer and Information Science, Northeastern UniversityApril 12, Bezier Patch P 00 P 10 P 01 P 02 P 03 P 11 P 12 P 13 P 20 P 30 P 21 P 22 P 23 P 31 P 32 P 33 Q(0,v) Q(1,v) Q(u,0) Q(u,1)
College of Computer and Information Science, Northeastern UniversityApril 12, Bezier Patch P 00 P 10 P 01 P 02 P 03 P 11 P 12 P 13 P 20 P 30 P 21 P 22 P 23 P 31 P 32 P 33 Q u (0,0) = 3(P 10 – P 00 ) Q v (0,0) = 3(P 01 – P 00 ) Q uv (0,0) = 9(P 00 – P 01 – P 10 + P 11 )
College of Computer and Information Science, Northeastern UniversityApril 12, Properties of Bezier Surfaces A Bézier patch transforms in the same way as its control points under all affine transformations All u = constant and v = constant lines in the patch are Bézier curves. A Bézier patch lies completely within the convex hull of its control points. The corner points in the patch are the four corner control points. A Bézier surface does not in general pass through its other control points.
College of Computer and Information Science, Northeastern UniversityApril 12, Rendering Bezier Patches with a mesh Chris Bently - Rendering Bezier Patches 3. Use these derived points as the control points for new Bezier curves running in the v direction 1. Consider each row of control points as defining 4 separate Bezier curves: Q 0 (u) … Q 3 (u) 2. For some value of u, say 0.1, for each Bezier curve, calculate Q 0 (u) … Q 3 (u). 4. Generate edges and polygons from grid of surface points.
College of Computer and Information Science, Northeastern UniversityApril 12, Subdividing Bezier Patch P 00 P 10 P 01 P 02 P 03 P 11 P 12 P 13 P 20 P 30 P 21 P 22 P 23 P 31 P 32 P 33 Subdivide until the control points are coplanar.
College of Computer and Information Science, Northeastern UniversityApril 12, Blending Bezier Patches
Teapot Data double teapot_data[][] = { { , 0.00, 30.00, , , 30.00, , , 30.00, 0.00, , 30.00, , 0.00, 12.00, , , 12.00, , , 12.00, 0.00, , 12.00, , 0.00, 3.00, , , 3.00, , , 3.00, 0.00, , 3.00, , 0.00, 0.00, , , 0.00, , , 0.00, 0.00, , 0.00, }, …
College of Computer and Information Science, Northeastern UniversityApril 12, Bezier Patch Continuity If these sets of control points are colinear, the surface will have G 1 continuity.
College of Computer and Information Science, Northeastern UniversityApril 12, Quadric Surfaces ellipsoidelliptic cylinder
College of Computer and Information Science, Northeastern UniversityApril 12, Quadric Surfaces 1-sheet hyperboloid 2-sheet hyperboloid
College of Computer and Information Science, Northeastern UniversityApril 12, Quadric Surfaces cones
College of Computer and Information Science, Northeastern UniversityApril 12, elliptic parabaloid hyperbolic parabaloid
College of Computer and Information Science, Northeastern UniversityApril 12, Quadric Surfaces hyperbolic cylinder parabolic cylinder
College of Computer and Information Science, Northeastern UniversityApril 12, General Quadrics in General Position
College of Computer and Information Science, Northeastern UniversityApril 12, General Quadric Equation Ray Equations
College of Computer and Information Science, Northeastern UniversityApril 12, Ray Quadric Intersection Quadratic Coefficients A = a*xd*xd + b*yd*yd + c*zd*zd + 2[d*xd*yd + e*yd*zd + f*xd*zd B = 2*[a*x0*xd + b*y0*yd + c*z0*zd + d*(x0*yd + xd*y0 ) + e*(y0*zd + yd*z0 ) + f*(x0*zd + xd*z0 ) + g*xd + h*yd + j*zd] C = a*x0*x0 + b*y0*y0 + c*z0*z0 + 2*[d*x0*y0 + e*y0*z0 + f*x0*z0 + g*x0 + h*y0 + j*z0] + k
College of Computer and Information Science, Northeastern UniversityApril 12, Quadric Normals Normalize N and change its sign if necessary.
College of Computer and Information Science, Northeastern UniversityApril 12, MyCylinders
College of Computer and Information Science, Northeastern UniversityApril 12, Student Images
College of Computer and Information Science, Northeastern UniversityApril 12, Student Images