CS 424 Compter Graphics Crves and Srfaces Yong Cao Virginia Tech Reference: Ed Angle, Interactive Compter Graphics, University of New Mexico, class notes
Crve and Srface Modeling
Objectives Introdce types of crves and srfaces Explicit Implicit Parametric Strengths and weaknesses Discss Modeling and Approximations Conditions Stability
Modeling with Crves data points approximating crve interpolating data point
What Makes a Good Representation? There are many ways to represent crves and srfaces Want a representation that is Stable Smooth Easy to evalate
Explicit Representation Most familiar form of crve in 2D yf(x) Cannot represent all crves y Vertical lines Circles Extension to D x y yf(x), zg(x) The form z f(x,y) defines a srface z x
Implicit Representation Two dimensional crve(s) g(x,y) Mch more robst All lines ax+by+c Circles x 2 +y 2 -r 2 Three dimensions g(x,y,z) defines a srface Intersect two srface to get a crve
Parametric Crves Separate eqation for each spatial variable xx() yy() zz() p()[x(), y(), z()] T For max min we trace ot a crve in two or three dimensions p() p( max ) p( min )
Selecting Fnctions Usally we can select good fnctions not niqe for a given spatial crve Approximate or interpolate known data Want fnctions which are easy to evalate Want fnctions which are easy to differentiate Comptation of normals Connecting pieces (segments) Want fnctions which are smooth
Parametric Lines We can normalize to be over the interval (,) Line connecting two points p and p p() p p()(-)p +p Ray from p in the direction d p()p +d p() p p() p d p() p +d
Parametric Srfaces Srfaces reqire 2 parameters xx(,v) yy(,v) zz(,v) p(,v) [x(,v), y(,v), z(,v)] T Want same properties as crves: Smoothness Differentiability Ease of evalation y p(,v) z p(,) p(,) x p(,v)
Normals We can differentiate with respect to and v to obtain the normal at any point p v v v v ) /, z( ) /, y( ) /, x( ), p( v v v v v v v v ) /, z( ) /, y( ) /, x( ), p( v v v ), ( ), p( p n
Parametric Planes n point-vector form p(,v)p +q+vr r n q x r q three-point form p p 2 n q p p r p 2 p p p
Parametric Sphere x(,v) r cos q sin f y(,v) r sin q sin f z(,v) r cos f 6 q 8 f θ constant: circles of constant longitde f constant: circles of constant latitde Normal: n p
Crve Segments After normalizing, each crve is written p()[x(), y(), z()] T, In classical nmerical methods, we design a single global crve In compter graphics and CAD, it is better to design small connected crve segments p() join point p() q() p() q() q()
Parametric Polynomial Crves N i j x( ) cxi y( ) c yj z( ) czk i M j If NMK, we need to determine (N+) coefficients Eqivalently we need (N+) independent conditions L k k Noting that the crves for x, y and z are independent, we can define each independently in an identical manner We will se the form where p can be any of x, y, z p( ) L k c k k
Why Polynomials Easy to evalate Continos and differentiable everywhere Mst worry abot continity at join points inclding continity of derivatives p() q() join point p() q() bt p () q ()
Cbic Parametric Polynomials NML, gives balance between ease of evalation and flexibility in design p( ) k c k For coefficients to determine for each of x, y and z Seek for independent conditions for varios vales of reslting in 4 eqations in 4 nknowns for each of x, y and z Conditions are a mixtre of continity reqirements at the join points and conditions for fitting the data k
Cbic Polynomial Srfaces p(,v)[x(,v), y(,v), z(,v)] T where p(, v) i j c ij i v j p is any of x, y or z Need 48 coefficients ( independent sets of 6) to determine a srface patch
Objectives Introdce the types of crves Interpolating Hermite Bezier B-spline Analyze their performance
Matrix-Vector Form c k k k ) p( c c c c 2 c 2 define c c T T ) p( then
Interpolating Crve p p p p 2 Given for data (control) points p, p,p 2, p determine cbic p() which passes throgh them Mst find c,c,c 2, c
Interpolation Eqations apply the interpolating conditions at, /, 2/, p p()c p p(/)c +(/)c +(/) 2 c 2 +(/) c p 2 p(2/)c +(2/)c +(2/) 2 c 2 +(2/) c p p()c +c +c 2 +c or in matrix form with p [p p p 2 p ] T pac 2 2 2 2 2 A
Interpolation Matrix Solving for c we find the interpolation matrix MI A 5.5 9 4.5 9 22.5.5 4.5 8.5 4.5 4.5 cm I p Note that M I does not depend on inpt data and can be sed for each segment in x, y, and z
Interpolating Mltiple Segments se p [p p p 2 p ] T se p [p p 4 p 5 p 6 ] T Get continity at join points bt not continity of derivatives
Blending Fnctions Rewriting the eqation for p() p() T c T M I p b() T p where b() [b () b () b 2 () b ()] T is an array of blending polynomials sch that p() b ()p + b ()p + b 2 ()p 2 + b ()p b () -4.5(-/)(-2/)(-) b ().5 (-2/)(-) b 2 () -.5 (-/)(-) b () 4.5 (-/)(-2/)
Blending Fnctions These fnctions are not smooth Hence the interpolation polynomial is not smooth
Interpolating Patch p(, v) i o j c ij i v j Need 6 conditions to determine the 6 coefficients c ij Choose at,v, /, 2/,
Matrix Form Define v [ v v 2 v ] T C [c ij ] P [p ij ] p(,v) T Cv If we observe that for constant (v), we obtain interpolating crve in v (), we can show CM I PM I p(,v) T M I PM IT v
Blending Patches p v b b v p ij j j i o i ) ( ) ( ), ( Each b i ()b j (v) is a blending patch Shows that we can bild and analyze srfaces from or knowledge of crves
Other Types of Crves and Srfaces How can we get arond the limitations of the interpolating form Lack of smoothness Discontinos derivatives at join points We have for conditions (for cbics) that we can apply to each segment Use them other than for interpolation Need only come close to the data
Hermite Form p () p () p() p() Use two interpolating conditions and two derivative conditions per segment Ensres continity and first derivative continity between segments
Eqations Interpolating conditions are the same at ends p() p c p() p c +c +c 2 +c Differentiating we find p () c +2c 2 + 2 c Evalating at end points p () p c p () p c +2c 2 +c
Matrix Form c q 2 p' p' p p Solving, we find cm H q where M H is the Hermite matrix 2 2 2 MH
Blending Polynomials p() b() T q + + + 2 2 2 2 2 2 2 ) b( Althogh these fnctions are smooth, the Hermite form is not sed directly in Compter Graphics and CAD becase we sally have control points bt not derivatives However, the Hermite form is the basis of the Bezier form
Parametric and Geometric Continity We can reqire the derivatives of x, y,and z to each be continos at join points (parametric continity) Alternately, we can only reqire that the tangents of the reslting crve be continos (geometry continity) The latter gives more flexibility as we have need satisfy only two conditions rather than three at each join point
Example Here the p and q have the same tangents at the ends of the segment bt different derivatives Generate different Hermite crves This techniqes is sed in drawing applications
Higher Dimensional Approximations The techniqes for both interpolating and Hermite crves can be sed with higher dimensional parametric polynomials For interpolating form, the reslting matrix becomes increasingly more ill-conditioned and the reslting crves less smooth and more prone to nmerical errors In both cases, there is more work in rendering the reslting polynomial crves and srfaces