Vous êtes sur la page 1sur 53

Curves and Surfaces

B-spline Curves
• These curves are approximating rather than
interpolating curves.
• The curves come close to, but may not actually pass
through, the control points.
• Usually used as multiple, joined curve segments
• B-splines have C2 continuity between curve segments
• “Smoother” than other curve forms
• For a sequence of connected B-spline curves, each
curve segment is determined from four control points.
• Each control point contributes to 4 curve segments
(except the first three and last three)

2
B-spline Curves (2)
• By convention, curve segment Qi is determined by
control points Pi-3, Pi-2, Pi-1, and Pi
• Rather than defining each curve segment on the
interval 0 t  1, we make the parameter domains
sequential.
• Curve segment Qi is defined on the parameter range
ti t  ti+1
• Between two curve segments Qi-1 and Qi there is a
join point or knot at parameter value ti
• A uniform B-spline has knots that are equally spaced
in t.

3
B-spline Curve Example
P2
P1
P6
P3
t7
t4

t3 t5
P0
t6
P4 P5

4
B-spline Geometry
• The B-spline geometry vector is given by
 Pi  3 
 
Pi  2
G BS   
 Pi 1 
 
 i 
P

• The first curve segment, Q3 is defined by P0 to P3


over the parameter t3 = 0 to t4 = 1
• The second curve segment, Q4 is defined by P1 to P4
over the parameter t4 = 1 to t5 = 2
• The curve segment, Qm is defined by Pm-3 to Pm over
the parameter tm = m-3 to tm+1 = m-2

5
B-spline Properties
• Since each control point contributes to four
curve segments, moving one control point
alters four curve segments, but does not alter
the others.
• Because of the way we have parameterized t,
we define

Ti  ( t  t i )
3
( t  ti )
2
( t  ti ) 1 
• Then the curve segment is computed as
Q i ( t )  Ti M Bs G Bs , t i  t  t i 1

6
B-spline Properties
• The B-spline basis matrix MBs is defined as

1 3 3 1
 
1 3 6 3 0
M  
6  3 0
Bs
0 3
 
 1 4 1 0

• B-spline curve joins maintain C2 continuity


• B-splines are bounded by their convex hulls

7
Drawing Curves
• Once we have the curves defined, how do
we draw them?
• Two approaches:
1. Evaluate x(t), y(t), and z(t) for incrementally
spaced values of t in an iterative fashion.
• Draw line segments between the points at each iteration
• Can optimize using Horner’s method or forward
differences

2. Recursively subdivide the curve until the new


control points get sufficiently close to the curve
• Can generate a large number of curve segments

8
Advantages of B-spline curves
• B-spline curves require more information and
a more complex theory than Bézier curves.
• But it has advantages to offset these
shortcomings.
• a B-spline curve can be a Bézier curve.
• B-spline curves satisfy all important properties that
Bézier curves have.
• B-spline curves provide more control flexibility than
Bézier curves can do.

9
Properties of B-spline curves
• We can change the position of a control point without
globally changing the shape of the whole curve.
• Since B-spline curves satisfy the strong convex hull
property, they have a finer shape control.
• There are other techniques for designing and editing
the shape of a curve such as changing knots.
• B-spline curves are still polynomial curves and
polynomial curves cannot represent many useful
simple curves such as circles and ellipses.

10
Localized Control

Moving the control point B7 only changes the curve near that point.

11
Problems with B-splines
• B-splines cannot represent conic sections

• In order to represent them, we can use a ratio


of polynomials
p1 ( t )
Q (t ) 
p2 (t )

12
NURBS
• NURBS are one form of rational polynomial curves
• Non-Uniform Rational B-Spline
• Defined by :
• its order
• determines the number of control points that affect a region of the
curve
• The polynomial is degree one less than the order (i.e. order 4 is cubic
polynomial)
• a set of weighted control points
• a knot vector
• a sequence of values that determine how the control points affect the
curve
• NURBS curves are generalizations of both B-splines and
Bezier curves

13
NURBS
• NURBS are one form of rational polynomial curves
• Non-Uniform Rational B-Spline
• Defined by:

n
wi Bi N i ,k (t )
i 1
Q (t ) 

n
wi N i ,k (t )
i 1

• with:
w i  scalar wei ght for each control point
B i  control points
N i , k ( t )  the B - spline curve
k  B - spline parameter

14
NURBS
• If the weights are set to 1, the NURBS
becomes a regular B-spline
• NURBS can represent conics exactly.

15
Non-Uniform

Non-Uniform Knot Vector


Uniform Knot Vector {0.0, 1.0, 2.0, 3.75, 4.0, 4.25, 6.0, 7.0}
{0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0}
The knot intervals for B2 and B3:
{3.75, 4.0} and {4.0, 4.25} are narrower.

16
NURBS examples (from U of Calgary)

17
Parametric Bicubic Surfaces
• An extension to curves by adding another
dimension
t = 1.0
t = 0.8
t = 0.6

t = 0.4

t = 0.2
t = 0.0
s = 0.6 s = 0.8
s = 0.0 s = 0.2 s = 0.4 s = 1.0
18
Curve Equation
• Remember, the equation of the curve is:

Q ( t )  TMG

• Or, equivalently:

Q ( s )  SMG

• Where G is the geometry vector, and s is a


constant

19
The Surface Equations
• If we allow G to be a function, we get
 G1 (t ) 
 
G 2 (t )
Q ( s , t )  SMG ( t )  SM  
 G 3 (t ) 
 
G 4 (t ) 

i.e., the geometry can now change, based on


t

20
The Surface Equations
• For a fixed t1, Q(s, t1) is a curve, since G(t1) is
a constant.

• Taking a new t2 that is near in value to t1 will


give another curve which is slightly different
from the first.

• Repeating the process for some number of


parameters t, with 0  t < 1 will give a group of
curves that define a surface.
21
The Surface Equations
• Each of the Gi(t) functions are cubics, and can
be represented as:
G i ( t )  TM G i
• where

 g i1 
 
gi2
Gi   
 g i3 
 
 gi4 
22
Surface Equations
• Taking the transpose of this gives us
T
G i (t )  G i M T
T T

• If we substitute this back into our original


equation, and expand to include all four
geometry terms, we get:

Q ( s , t )  SM G M T
T T T

23
Surface Equations
• So,
T
x ( s , t )  SM G x M T
T T

T
y ( s , t )  SM G y M T
T T

T
z ( s , t )  SM G z M T
T T

• With G being the geometry matrix and M


being the basis matrix.

24
Bezier Surfaces
• The ends of each patch require 4 control
points in the s direction.

• The t direction gives rise to 4 control points


also

• Thus, there are 4x4 or 16 control points


required for each patch.

25
Bezier Surface Example

26
Joining Bezier Surfaces
P 21
P 31

• Multiple Bezier P 32
P 11

P 22 P 12
surfaces can be P 41

joined with C0 P 42 P 33
P 23
P 13

continuity by: P 43
P 34
P 24

• Making the four P 44


P 14

P 25
control points at the P 35
P 15

join common P 45

between the two P 36


P 26
patches P 46
P 37 P 16

P 47 P 27

P 17
27
Joining Bezier Surfaces
P 21
P 31

• To join with C1 P 11

P 32
continuity we must P 41
P 22 P 12

also enforce the P 42 P 33


P 23
P 13
following stipulations: P 34
P 24

1. The control points on P 43

P 14
either side of the join P 44
P 25
must be collinear P 35
P 15
2. All of the pairs of line P 45

segments joining the P 36

three collinear control P 26

P 46
points must have P 37 P 16
lengths that have the P 47 P 27
same ratios
P 17
28
Joining Bezier Surfaces
P 21
P 31

• For this example P 32


P 11

P 22 P 12
the following ratios P 41
P 23
must be equal: P 42 P 33 P 13

P 24
P 34
P 43
P13 P14 P23 P24 P33 P34 P43 P44
   P 44
P 14

P14 P15 P24 P25 P34 P35 P44 P45 P 35 P 25

P 15

P 45

P 36
P 26

P 46
P 37 P 16

P 47 P 27

P 17
29
Displaying Surfaces
• Surfaces are displayed in a manner similar
to curves.

1. Iteratively evaluate the surface equation at s and t


intervals, then draw polygons for those patches

2. Subdivide the surface until the patch size is small


enough

30
NURBS Surfaces
• NURBS –
• Non Uniform
• - knots can have any spacing desired
• Rational
• the blending functions are the ratios of two polynomials
• B-Spline
• the surface type is B-spline
• Very flexible and powerful
• Also somewhat complex
• Can represent conics exactly
• Used extensively, particularly in CAD

31
NURBS Examples

http://www.geomagic.com
32
http://gallery.mcneel.com/

33
http://gallery.mcneel.com/

34
http://gallery.mcneel.com/

35
NURBS in OpenGL
gluNurbsSurface(GLUnurbs *nurb,
Glint sKnotCount,
GLfloat *sKnots,
Glint tKnotCount,
GLfloat *tKnots,
Glint sStride,
Glint tStride,
GLfloat *control,
Glint sOrder,
Glint tOrder,
GLenum type)
36
NURBS in OpenGL
• nurb – specifies the NURBS object – gluNurbsSurface(GLUnurbs *nurb,
created with Glint sKnotCount,
gluNewNurbsRenderer GLfloat *sKnots,
• sKnotCount –number of knots in the Glint tKnotCount,
GLfloat *tKnots,
s direction Glint sStride,
• sKnots – the array of s knots Glint tStride,
• tKnotCount – number of knots in the GLfloat *control,
Glint sOrder,
t direction Glint tOrder,
• tKnots – the array of t knots GLenum type)
• sStride – offset between control
points in the s direction
• tStride – offset between control
• sOrder – order of the NURBS in s
points in the t direction
• tOrder – order of the NURBS in t
• control – array of control points
• type – type of surface

37
Trimming Curves
• Sometimes we want “holes” in the surface
• Can define them using trimming curves
• Define a NURBS curve on the NURBS surface
• Draw the surface everywhere except inside
the curve

38
39
40
Subdivision Surfaces
• One problem with the surfaces we have
discussed is the difficulty in changing
resolution for a portion of the surface
• If we want more detail at one part of the patch,
we have to introduce a whole new patch
• Subdivision surfaces allow local refinement of
the control mesh
• This gives more flexibility in the objects to be
modeled

41
Subdivision Surfaces
• Idea: recursively subdivide the patch to finer
and finer resolution

Refinement 1 Refinement 2

Refinement ∞

42
Standard Subdivision
• Given initial control points, recursively
subdivide until desired smoothness is reached

43
Adaptive Subdivision
• Generally some areas of the surface have
higher curvature, and thus should be
subdivided further than other areas
• Can apply an adaptive subdivision scheme to
subdivide more where we want finer control of
the surface

44
Adaptive Subdivision Surface Example

Original Mesh After one refinement

After two refinements The limit – infinite refinement


from http://grail.cs.washington.edu/projects/subdivision/
45
Subdivision Surfaces

Geri’s Game (1997) : Pixar Animation Studios

46
Subdivision Surface Example

http://mrl.nyu.edu/~dzorin/sig98course/multires/sld005.htm
47
Allowing for Sharp Edges and Creases
• Often we want to permit
sharp edges
• How can we smooth
some of the surface, but
not all?
• Tag edges as sharp or
non-sharp
• If an edge is sharp, apply
sharp subdivision rules
• Otherwise apply normal
subdivision rules

48
T-splines
• Introduced by Dr. Sederberg in 2003
• Allow T-junctions in the surfaces
T-junction

49
T-Splines

50
T-spline Hole Filling

51
T-spline example

52
Summary
• Surfaces allow for a higher level of realism
• Used in all CAD packages
• NURBS surfaces are the most popular type
• Subdivision surfaces allow for increased
surface detail, and for local adaptation
• T-splines allow for even more flexibility

53

Vous aimerez peut-être aussi