Parametric Curves and Surfaces by SanjuDudeja

VIEWS: 8 PAGES: 32

More Info
									1/26/2011 02:42                              1




                  Graphics II 91.547

                  Parametric Curves
                    and Surfaces
                        Session 3




                                       UML
1/26/2011 02:42                                                                      2




          Parametric Curves and Surfaces:
          Key Concepts

                                                       x
                                                       y
                  Point                                
                                                      z
                                                      1
                                                       


                  Curve, Surface              Collection of points


                                               x (u ) 
                                               y (u )
                  Parametric Representation            u  0...1
                                               z (u ) 
                                               1 
                                                             (for a curve)




                                                                               UML
1/26/2011 02:42                                                                          3




          Parametric Curves and Surfaces
          Key Concepts, contd.

             Multiplying a point by a scalar:           Scaling the representation

                                                    n
             Polynomial                  p( u )   c k u k
                                                   k 0

                                         x (u )  c0 x  c1 x u  c2 x u 2  c3 x u 3

              Control Points          Set of (degree+1) points that bear some
                                      relation to the desired curve or surface

                                      Set of (degree + 1) polynomials that, when
              Basis Functions         multiplied by the corresponding control
                                      points, produce the curve or surface
                                                                                   UML
1/26/2011 02:42                                                          4




          Continuity Considerations: C0 & C1 Continuity




                  p( u)



                          dp(u) dx(u)      dy (u)      dz (u)
                                     ix         iy         iz
                           du    du         du          du




                                                                   UML
1/26/2011 02:42                                               5




          How do we insure C0 and C1 continuity?



                            p1        p2




                    p0                             p3



                                                        UML
1/26/2011 02:42                                                                         6




          Bezier Curves:

                       1. Require interpolation at the endpoints of the curve:

                                        p o  p(0)
                                        p 3  p(1)

                       2. Require that the line segments P0 P1 and P3P2
                       match the first derivative of the curve at 0 and 1.

                                                         p1  p 0
                          p1      p2
                                               p'(0)        1
                                                                     3(p1  p 0 )
                                                             3

                                                         p3  p2
                                         p3
                                               p'(1)        1
                                                                     3(p 3  p 2 )
                  p0
                                                             3


                                                                                  UML
1/26/2011 02:42                                                           7




          Calculating the Bezier Geometry Matrix
                                                          3
                  p(u)  c0  c1u  c2 u  c3u   c k u
                                            2        3          k

                                                         k 0

                  Inserting the four conditions gives:

                  p 0  c0
                  p 3  c0  c1  c2  c3
                  p1  p 0  1 c1
                             3

                  p 3  p 2  1 (c1  2c2  3c3 )
                              3



                                                                    UML
1/26/2011 02:42                                                           8




          Calculating the Bezier Geometry Matrix


                  This gives four equations in four unknowns that

                  can be solved for :

                  c  M Bp
                  where M B   is the Bezier Geometry Matrix

                       1   0  0             0
                        3 3  0             0
                  MB                        
                        3 6 3              0
                        1 3  3            1
                                             

                                                                    UML
1/26/2011 02:42                                                   9




          Bezier Blending Functions

                  p ( u )  u T M Bp

                  This can be expressed:


                  p ( u)  b ( u) p
                                T
                                           where



                                   1  3u  3u 2  u 3 
                                    3u  6u 2  3u 3 
                  b ( u)  M B u                      
                              T

                                    3u  3u
                                           2      3
                                                        
                                                       
                                                       
                                               3
                                             u

                                                            UML
1/26/2011 02:42                              10




          Bezier Blending Functions:




                                       UML
1/26/2011 02:42                                                       11




          Convex Hull Property:
                               3

                               b ( u)  1
                              i 0
                                     i




                                              Curve must lie within
                         p1              p2   this region known as
                                              “convex hull” of the
                                              control points.




                  p0                           p3

                                                           UML
1/26/2011 02:42                                                              12




          Further look at the Bezier blending functions:

                  Factoring the blending functions gives:

                                (1  u) 3 
                               3u(1  u) 2 
                        b(u)   2          
                               3u (1  u) 
                                           
                                           
                                      3
                                    u
                  These are an instance of the Bernstein Polynomials
                  for k=3.

                                       d!
                        bkd (u)               u k (1  u) d  k
                                  k !(d  k )!

                                                                       UML
1/26/2011 02:42                                 13




          Bezier Curves:
          Code Example



                           120 goto 120




                                          UML
1/26/2011 02:42                                                                     14




          An interesting geometric construction
                            p   0        p1
                                          1                    p0
                                1                               2

                                               2
                                              p1
                                                                    p1
                                                                     2

                                    p3
                                     0
                            p2
                             0
                       p1
                        0




                  p0
                   0
                                                                         p0
                                                                          3

                            pir (u)  (1  u)pir 1 (u)  upir11 (u)
                            r  1,..., n
                            i  0,..., n  r
                            pi0 (u)  pi
                                                                              UML
1/26/2011 02:42                                               15




          Recursive subdivision of Bezier curves

                        0
                       p1                 p0
                                           2




                  p0
                   0
                                                   p0
                                                    3




                                                        UML
1/26/2011 02:42                                                            16




          Bezier surface patch

                                         p 33
                                                   Convex hull of patch



                    p 03
                                                       p 30

                                  p 00

                            i 3 j 3
                  p(u, v )    bi (u)bj (v )pij  u T M B PM T v
                                                               B
                            i 0 j o
                                                                     UML
1/26/2011 02:42                                                                       17




          Bezier surface patch
          Corner boundary conditions
                  Four equations for each corner gives 16 total.


                     p(0,0)  p 00      Patch must interpolate the corner.
                     p
                         (0,0)  3(p10  p 00 ) Defines derivative in u direction.
                     u
                     p
                         (0,0)  3(p 01  p 00 ) Defines derivative in v direction.
                     v
                      p
                       2

                           (0,0)  9(p 00  p 01  p10  p11 ) “Twist”
                     u v


                                                                             UML
1/26/2011 02:42                                                                                  18




          Rendering the Bezier patch by recursive
          subdivision




                  Connect new control
                  points to form new
                  curves.

                                                                     First subdivide curves of
                                                                     constant v.



                             Finally subdivide these curves to form 4 new patches.


                                                                                           UML
1/26/2011 02:42                                               19




          Recursive subdivision of Bezier curves

                        0
                       p1                 p0
                                           2




                  p0
                   0
                                                   p0
                                                    3




                                                        UML
1/26/2011 02:42                                      20




          The Utah Teapot: 32 Bezier Patches




                                               UML
1/26/2011 02:42                                       21




          Utah Teapot: Polygon Representation




                                                UML
1/26/2011 02:42                        22




          Rendering the Teapot




                                 UML
1/26/2011 02:42                                                                23




          Conversion between curve representations


                  Given a cubic Bezier curve expressed in terms of the
                  Bezier geometry matrix, MB:

                                 p ( u )  u T M Bp
                  The same curve can be expressed in terms of another
                  polynomial basis with matrix M and matrix of control
                  points q.
                                  p(u)  u Mq
                                           T




                   Solving for q gives:

                                  q  M 1M Bp
                                                                         UML
1/26/2011 02:42                                                                      24




          Conversion between curve representations:
          an example
                    Suppose you have a matrix of four control points, q and
                    a cubic interpolating those points q(u). The curve is obtained
                    by the interpolating geometry matrix MI   :
                        q(u)  u T M I q      where      M I  A 1
                   We want to find p such that:    q( u)  u M Bp
                                                             T




                                                  1   0   0  0
                                                   5 3  3 1 
                  p  M 1M B q   where            6
                                           MI MB  1
                                            1              2 3
                                                                  
                                                   3  2 3  5
                        I                                3
                                                                6
                                                  0          1
                                                      0   0      
                                                                              UML
1/26/2011 02:42                                                      25




          Drawing Bezier curves and surfaces:
          Evaluators


                                 Parameter
                                 Generation

        Establish Evaluator:   Parameter(s)
              glMap1{fd}()
              glMap2{fd}()
                                               Curve/surface
        Evaluate Points:           Evaluator   value
      glEvalCoord1{fd}()
      glEvalCoord2{fd}()


                                     Control
                                     Points
                                                               UML
1/26/2011 02:42                                                      26




          One Dimensional Evaluators

                  Void glMap1{fd](GLenum target, TYPE u1, TYPE u2,
                                  Glint stride,Glint order,
                                  TYPE *points);

                       target: specifies what the control points
                               represent
                       u1: beginning parameter value
                       u2: end parameter value
                       stride: number of values in each block of
                               control point storage
                       order: order of the Bezier curve (degree+1)
                       *points: pointer to array of control points




                                                               UML
1/26/2011 02:42                                                       27




          One Dimensional Evaluators:
          target parameter


                  GL_MAP_VERTEX_3           x,y,z vertex coords.
                  GL_MAP_VERTEX_4           x,y,z,w vertex coords
                  GL_MAP1_INDEX             color index
                  GL_MAP1_COLOR_4           RGBA
                  GL_MAP2_NORMAL            normal coordinates
                  GL_MAP1_TEXTURE_COORD_1   s texture coords.
                  GL_MAP1_TEXTURE_COORD_2   s,t texture coords.
                  GL_MAP1_TEXTURE_COORD_3   s,t,r texture coords.
                  GL_MAP1_TEXTURE_COORD_4   s,t,r,q texture coords.




                                                             UML
1/26/2011 02:42                                            28




          One Dimensional Evaluators:
          Code Example



                                  120 goto 120



                                                 ?




                                                     UML
1/26/2011 02:42                                                                      29




          Mesh Generation:
          One Dimensional
                  void glMapGrid1{fd} (Glint n, TYPE u1, TYPE u2);

                  Defines a grid that goes from u1 to u2 in n evenly spaced steps.


                  void glEvalMesh1 (GLenum mode, GLint p1, Glint p2);

                  mode is either GL_POINT or GL_LINE depending on whether you
                  want to draw individual points or connected lines.

                  p1, p2 are the grid values between which the mesh is to be
                  evaluated




                                                                             UML
1/26/2011 02:42                                                       30




          Two Dimensional Evaluators

          Void glMap2{fd](GLenum target, TYPE u1, TYPE u2,
                          Glint ustride,Glint uorder, TYPE v1,
                          TYPE v2, GLint vstride, Glint vorder,
                          TYPE *points);

                  target: specifies what the control points
                          represent
                  u1, v1: beginning parameter value
                  u2, v2: end parameter value
                  stride: number of values in each block of
                          control point storage
                  order: order of the Bezier curve (degree+1)
                  *points: pointer to array of control points




                                                                UML
1/26/2011 02:42                                                                     31




          Mesh Generation:
          Two Dimensional
                  void glMapGrid2{fd} (GLint nu, TYPE u1, TYPE u2
                                       GLint nv, TYPE v1, TYPE v2);

                  Defines a two dimensional grid that goes from u1 to u2
                  in nu evenly spaced steps and from v1 to v2 in nv evenly
                  spaced steps.


                  void glEvalMesh2 (GLenum mode, GLint p1, GLint p2,
                                                 GLint q1, GLint q2);

                  mode is either GL_POINT , GL_LINE , or GL_FILL depending
                  on whether you want to draw individual points, connected lines,
                  or a filled mesh.

                  p1, p2, q1, q2 are the grid values between which the mesh
                  is to be evaluated
                                                                             UML
1/26/2011 02:42                                        32




          Two Dimensional Evaluators:
          Code Examples



                                  120 goto 120




                                                 UML

								
To top