Representing Curves Foley & Van Dam, Chapter 11 Representing Curves • Motivations • Techniques for Object Representation • Curves Representation • Free Form Representation • Approximation and Interpolation • Parametric Polynomials • Parametric and Geometric Continuity • Polynomial Splines • Hermite Interpolation 3D Objects Representation • Solid Modeling attempts to develop methods and algorithms to model and represent real objects by computers Objects Representation • Three types of objects in 3D: • 1D curves • 2D surfaces • 3D objects • We need to represent objects when: • Modeling of existing objects (3D scan) - modeling is not precise • Modeling a new object “from scratch” (CAD) - modeling is precise - interactive sculpting capabilities General Techniques • Primitive Based: A composition of “simple” components • Not precise • Efficient and simple • Free Form: Global representation, curved manifolds • Precise • Complicated • Statistical: Modeling of objects generated by statistical phenomena, such as fog, trees, rocks Curves Representation 20 15 10 5 0 1 1 0 .5 0.5 0 0 -0 .5 -0 .5 -1 -1 Primitive Based Representation • Line segments: A curve is approximated by a collection of connected line segments Free Form Representations • Explicit form: z = f(x, y) • f(x,y) must be a function • Not a rotation invariant representation • Difficult to represent vertical tangents • Implicit form: f(x, y, z) = 0 • Difficult to connect two curves in a smooth manner • Not efficient for drawing • Useful for testing object inside/outside • Parametric: x(t), y(t), z(t) • A mapping from [0,1] → R3 • Very common in modeling Free Form Representations Example: A Circle of radius R • Implicit: x2 + y2 + z2 - R2 = 0 & z = 0 z • Parametric: x(θ) = R cos(θ) y(θ) = R sin(θ) z(θ) = 0 θ x y Approximated vs. Interpolated Curves • Given a set of control points Pi known to be on the curve, find a parametric curve that interpolates/approximates the points Interpolating Curve P1 P0 P3 P2 P4 Approximating Curve P1 P3 P0 P2 P4 Parametric Polynomials • For interpolating n points we need a polynomial of degree n-1 x (u ) = a x + bxu + c xu y (u ) = a y + b yu + c yu z(u ) = a z p1 + b zu + c zu + " 2 2 2 + " + " p3 p0 p2 p4 • Example: Linear polynomial. For interpolating 2 points we need a polynomial of degree 1 x ( u ) = a y ( u ) = a z ( u ) = a x + b + b y z + b u x y z u p1 u p0 Example: Linear Polynomial • The geometrical constraints for x(u) are: x (0 ) = a = x P 0x ; x (1 ) = a + b x = x P1 x • Solving the coefficients for x(u) we get: a ⇒ x = P0x ; b = P1 x − P 0 x x x ( u ) = P 0 x + ( P1 x − P 0 x ) u • Solving for [x(u) y(u) z(u)] we get: V ( u ) = x ( u ) y ( u ) z ( u ) = P 0 + ( P 1 u=1 u=0 p1 p0 − P 0 ) u Example: Linear Polynomial u=0 p0 u=1 p1 V 1 x (u ) y (u ) = z ( u ) (u ) = p1 p0 V1(u) P 0 + ( P1 − P 0 ) p3 p2 V2(u) x (u V ( u ) = y (u z (u ) ) ) w h ere V3(u) = ∑ V4(u) p4 V i (u ) i V i ( u ) Vi (u ) = 0 if u ∈ [ u i , u i +1 ] o th erw ise u Parametric Polynomials • Polynomial interpolation has several disadvantages: • Polynomial coefficients are geometrically meaningless • Polynomials of high degree introduce unwanted wiggles • Polynomials of low degree give little flexibility • Solution: Polynomial Splines p1 p0 p3 p2 p4 Polynomial Splines • Piecewise, low degree, polynomial curves, with continuous joints x (u C ( u ) = y (u z (u ) ) ) w h ere = ∑ C i (u ) i C i (u ) C i (u ) = 0 if u ∈ [ u i , u i +1 ] o th erw ise • Advantages: • Rich representation • Geometrically meaning coefficients • Local effects • Interactivep sculpting capabilities p3 1 p0 c1(u) c2(u) p2 c3(u) c4(u) p4 Tangent Vector • Let V(u)=[x(u), y(u), z(u)], u→[0,1] be a continuous univariate parametric curve in R3 • The tangent vector at u0, T(u0), is: G dy dz dV ( u ) dx T ( u 0 ) = V ′( u 0 ) = = du du du du u=u0 u=u • V(u) may be thought of as the trajectory of a point in time • In this case, T(u0) is the instantaneous velocity vector at time u0 u0 u=0 T(u0) u=1 0 Parametric Continuity • Let V1(u) and V2(u) , u→[0,1], be two parametric curves •Level of parametric continuity of the curves at the joint between V1(1) and V2(0): • C-1: The joint is discontinuous, V1(1)≠V2(0) • C0: Positional continuos, V1(1)=V2(0) • C1: Tangent continuos, C0 & V’1(1)=V’2(0) • Ck, k>0: Continuous up to the k-th derivative, V1(j) (1)=V2(j) (0), 0 ≤ j ≤ k C-1 V1(1) V2(0) C0 C1 Geometric Continuity • In computer aided geometry design, we also consider the notion of geometric continuity: • G-1, G0: Same as C-1 and C0 • G1: Same tangent direction: V’1(1)=αV’2(0) • Gk: All derivatives up to the k-th order are proportional • Given a set of points {pi}: • A piecewise constant interpolant is C-1 • A piecewise linear interpolant is C0 Parametric and Geometric Continuity • S-C0 is C0 • S-C1 is C1 • S-C2 is C2 • In general, Ci implies Gi (not vice versa) • Exception when the tangents are zero • Q1-Q2 both C1 and G1 • Q1-Q3 is G1 but not C1 Parametric Cubic Curves • Cubic polynomials defining a curve in R3 have the form: 3 2 x (u ) = a x u y (u ) = a y u z (u ) = a z u + b 3 3 + b + b 2 u y z + c u x u 2 + c + c u + d x y z x u + d u + d y z Where u is in [0,1]. Defining: U T [ (u ) = u 3 u 2 u 1 ] and The curve can be rewritten as: [ x (u ) y (u ) a x b x Q = cx d x a b c d y y y y z (u ) ] = V T (u ) = U T (u ) Q az bz cz d z Parametric Cubic Curves • The coefficients Q are unknown and should be determined • For this purpose we have to supply 4 geometrical constraints • Different types of constraints define different types of Splines Hermite Curves • Assume we have n control points {pk} with their tangents {Tk} • W.L.O.G. V(u) represents a parametric cubic function for the section between pk and pk+1 • For V(u) we have the following geometric constraints: V(0)=pk; V(1)=pk+1 V'(0)=Tk; V'(1)=Tk+1 pk V(0) Tk V(1) V(u) Pk+1 Tk+1 Hermite Curves Since V T ( u ) = u 3 u 2 1 u Q we have that ( V ′ ) T ( u ) = 3 u 2 2u 1 0 Q We can write the constraints in a matrix form: G And thus Where = MQ ⇒ p k p k +1 Tk T k +1 G V T M (u ) = U −1 = 2 − 3 0 1 0 1 = 0 3 0 1 0 1 0 1 2 1 1 1 Q 0 0 M T (u )Q = U − 2 3 0 0 1 − 2 1 0 T 1 − 1 0 0 (u ) M −1 G Hermite Curves V (u ) = [u 3 u 2 u 2 −3 1] 0 1 −2 1 3 −2 0 0 1 0 1 − 1 0 0 pk p k + 1 Tk T k + 1 Geometry matrix Blending functions T 2u 3 − 3u 2 + 1 3 2 − 2u + 3u V (u ) = u 3 − 2u 2 + u 3 2 − u u T H 0(u ) p k H (u ) p 1 k +1 = H 2(u ) T k H ( u ) 3 T k +1 p k p k +1 T k T k +1 = Hermite Curves 1.2 H1=H(1) 1 H0=H(0) 0.8 0.6 0.4 H2=H’(0) 0.2 0 -0 . 2 H3=H’(1) 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 Hermite Blending Functions 0.9 1 Hermite Curves y(u) Change in Magnitude of T0 T0 P0 T1 P1 x(u) y(u) Change in Direction of T0 x(u) Hermite Curves Properties: • The Hermite curve is composed of a linear combinations of tangents and locations (for each u) • Alternatively, the curve is a linear combination of Hermite basis functions (the matrix M) • It can be used to create geometrically intuitive curves • The piecewise interpolation scheme is C1 continuous • The blending functions have local support; changing a control point or a tangent vector, changes its local neighborhood while leaving the rest unchanged Hermite Curves • Main Drawback: Requires the specification of the tangents This information is not always available