modeling curved surfaces

52
1

Upload: sukey

Post on 07-Jan-2016

36 views

Category:

Documents


0 download

DESCRIPTION

Modeling Curved Surfaces. Curved Surfaces. The use of curved surfaces allows for a higher level of modeling, especially for the construction of highly realistic models. There are several approaches to modeling curved surfaces:. (1) Similar to polyhedral models , - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Modeling Curved Surfaces

1

Page 2: Modeling Curved Surfaces

2

The use of The use of curved surfacescurved surfaces allows for a higher level allows for a higher level of modeling, especially for the construction of highly of modeling, especially for the construction of highly

realistic models.realistic models.

There are several approaches to modeling There are several approaches to modeling curved surfaces:curved surfaces:

(1)(1) Similar to Similar to polyhedral modelspolyhedral models, , we model an object by using small we model an object by using small curved surface curved surface patchespatches (instead of polygons) placed next to each (instead of polygons) placed next to each

other.other.

(2)(2) Another approach is Another approach is solid modelingsolid modeling, , that constructs a model using elementary solid that constructs a model using elementary solid

objects (such as: polyhedra, spheres, cones etc.) as objects (such as: polyhedra, spheres, cones etc.) as building blocks.building blocks.

Curved SurfacesCurved Surfaces

Page 3: Modeling Curved Surfaces

3

There are two ways to construct a model:There are two ways to construct a model:

This is the process of building the model by This is the process of building the model by assembling many simpler objects.assembling many simpler objects.

For example, creating a (cylindrical) hole in a sphere For example, creating a (cylindrical) hole in a sphere or a cube.or a cube.

Additive ModelingAdditive Modeling

This is the process of removing pieces from a given This is the process of removing pieces from a given object to create a new object.object to create a new object.

Subtractive ModelingSubtractive Modeling

Curved SurfacesCurved Surfaces

We can represent curved We can represent curved surfaces using mesh of curves. So surfaces using mesh of curves. So

we learn to create curves first we learn to create curves first then move to curved surfaces.then move to curved surfaces.

Curved Surface Patch

Page 4: Modeling Curved Surfaces

4

Curve RepresentationCurve RepresentationThere are three ways to represent a curve

Explicit: y = f(x)y = mx + b y = x2

(–) Must be a single valued function(–) Vertical lines, say x = d?

Implicit: f(x,y) = 0x2 + y2 - r2 = 0

(+) y can be multiple valued function of x(–) Vertical lines?

Parametric: (x, y) = (x(t), y(t))(x, y) = (cost, sint)

(+) Easy to specify, modify and control(–) Extra hidden variable t, the parameter

Page 5: Modeling Curved Surfaces

5

Explicit RepresentationExplicit RepresentationCurve in 2D: y = f(x)Curve in 3D: y = f(x), z = g(x)Surface in 3D: z = f(x,y)Problems:

How about a vertical line x = c as y = f(x)?Circle y = (r2 – x2)1/2 two or zero values for x

• Rarely used in computer graphics

Page 6: Modeling Curved Surfaces

6

Implicit RepresentationImplicit RepresentationCurve in 2D: f(x,y) = 0

Line: ax + by + c = 0Circle: x2 + y2 – r2 = 0

Surface in 3d: f(x,y,z) = 0Plane: ax + by + cz + d = 0Sphere: x2 + y2 + z2 – r2 = 0

f(x,y,z) can describe 3D object:Inside: f(x,y,z) < 0Surface: f(x,y,z) = 0Outside: f(x,y,z) > 0

Page 7: Modeling Curved Surfaces

7

Parametric Form for Parametric Form for CurvesCurves

Curves: single parameter u (e.g. time)x = x(t), y = y(t), z = z(t)

Circle: x = cos(t), y = sin(t), z = 0

Tangent described by derivative

Magnitude is “velocity”

dt

tdzdt

tdydt

tdx

dt

tdp

tz

ty

tx

tp

Page 8: Modeling Curved Surfaces

8

Parametric Form for Parametric Form for SurfacesSurfaces

Use parameters u and vx = x(u,v), y = y(u,v), z = z(u,v)

Describes surface as both u and v varyPartial derivatives describe tangent plane at each point p(u,v) = [x(u,v) y(u,v) z(u,v)]T

vvuz

vvuy

vvux

uvuz

uvuy

uvux

v

vup

u

vup

,

,

,

,

,

,

,,

Page 9: Modeling Curved Surfaces

9

Advantages of Parametric Advantages of Parametric FormForm

Parameters often have natural meaningEasy to define and calculate

Tangent and normalCurves segments (for example, 0 u 1)Surface patches (for example, 0 u,v 1)

Page 10: Modeling Curved Surfaces

10

Lagrange PolynomialLagrange Polynomial

Problems:y=f(x), no multiple valuesHigher order functions tend to oscillateNo local control (change any (xi, yi) changes the whole curve)Computationally expensive due to high degree.

Given n+1 points (x0, y0), (x1, y1) …….. (xn, yn)To construct a curve that passes through these points we can use Lagrange polynomial defined as follows:.

Page 11: Modeling Curved Surfaces

11

Piecewise Linear Piecewise Linear PolynomialPolynomial

To overcome the problems with Lagrange polynomial

Divide given points into overlap sequences of 4 pointsconstruct 3rd degree polynomial that passes through these points, p0, p1 , p2 , p3 then p3, p4 , p5 , p6 etc.Then glue the curves so that they appear sufficiently smooth at joint points.

Questions:Questions:1.1. Why 3Why 3rdrd Degree curves used? Degree curves used?2.2. How to measure smoothness at joint point?How to measure smoothness at joint point?

Page 12: Modeling Curved Surfaces

12

A curve is approximated by a A curve is approximated by a piecewise polynomialpiecewise polynomial curve. curve.

Cubic polynomialsCubic polynomials are most often used are most often used because: because:

(1)(1) Lower-degree polynomials offer too little Lower-degree polynomials offer too little flexibility in controlling the shape of the curve.flexibility in controlling the shape of the curve.

(2)(2) Higher-degree polynomials can introduce Higher-degree polynomials can introduce unwanted wiggles and also require more unwanted wiggles and also require more

computation.computation.

(3)(3) No lower-degree representation allows a curve No lower-degree representation allows a curve segment to be defined by two given endpoints with segment to be defined by two given endpoints with

given derivative at each endpoints.given derivative at each endpoints.

(4)(4) No lower-degree curves are nonplanar in 3D. No lower-degree curves are nonplanar in 3D.

Why Cubic Curves?Why Cubic Curves?

Page 13: Modeling Curved Surfaces

13

If the If the directionsdirections (but not necessarily the (but not necessarily the magnitudes) of the two segments’ tangent vectors magnitudes) of the two segments’ tangent vectors are equal at a join point.are equal at a join point.

GG 1 1 GeometricGeometric ContinuityContinuity

If the direction and magnitude of If the direction and magnitude of QQnn((tt) through the ) through the nnth derivative are equal at the join point.th derivative are equal at the join point.

CC nn ParametricParametric ContinuityContinuity

Measure of SmoothnessMeasure of Smoothness

If two curve segments join together.If two curve segments join together.GG

0 0 GeometricGeometric ContinuityContinuity CC 0 0 ParametricParametric ContinuityContinuity

C0

If the If the directions and magnitudesdirections and magnitudes of the two of the two segments’ tangent vectors are equal at a join point.segments’ tangent vectors are equal at a join point.

CC 1 1 ParametricParametric ContinuityContinuity

C1

If the direction and magnitude of If the direction and magnitude of QQ22((tt) (curvature or ) (curvature or accelerationacceleration) are equal at the join point.) are equal at the join point.

CC 22 ParametricParametric ContinuityContinuity

C2

Page 14: Modeling Curved Surfaces

14

Measure of SmoothnessMeasure of Smoothness

S

Joint Point

C0

C1

C2

Q1

Q2

Q3

TV3=2*TV1

TV2=TV1• QQ11& Q& Q22 are C are C11 and G and G11 continuouscontinuous

• QQ11& Q& Q33 are G are G11 continuous continuous only as Tangent vectors only as Tangent vectors have different have different magnitude.magnitude.

• Observe the effect of Observe the effect of increasing in magnitude increasing in magnitude of TVof TV

P0

• By increasing parametric By increasing parametric continuity we can continuity we can increase smoothness of increase smoothness of the curve.the curve.

Page 15: Modeling Curved Surfaces

15

Desirable Properties of a Desirable Properties of a CurveCurve

Simple controllines need only two pointscurves will need more (but not significantly more)

Intuitive controlPhysically meaningful quantities like position, tangent, curvature etc.

Global Vs. Local ControlPortion of curve effected by a control point.

General ParameterizationHandle multi-valued x-y mapping

Page 16: Modeling Curved Surfaces

16

Desirable Properties of a Desirable Properties of a Curve Curve cont’dcont’d

Interpolation Vs ApproximationAxis Independent

Equation might change but the shape remain same under a coordinate transform(translation, rotation, scaling) of a curve = (translation, rotation, scaling) of its control points.

Degree of Smoothness.May need more or lessMay need varying degrees of smoothness in a single curve.

Page 17: Modeling Curved Surfaces

17

Given Given n n + 1 points + 1 points PP00((xx00, , yy00), ), PP11((xx11, , yy11), …, ), …, PPnn((xxnn, , yynn))

If we require the curve to If we require the curve to pass throughpass through all the points.all the points.

InterpolationInterpolation

we wish to find we wish to find a curvea curve that, in some sense, that, in some sense, fits the fits the shape outlined by these pointsshape outlined by these points..

If we require only that the curve be If we require only that the curve be nearnearthese points.these points.

ApproximationApproximation

Based on requirements we are faced with Based on requirements we are faced with two problems:two problems:

Interpolation Vs. Interpolation Vs. ApproximationApproximation

Page 18: Modeling Curved Surfaces

18

Parametric Representation Parametric Representation of Linesof Lines

Interpolation of two pointsIn Parametric form: P1

P2

2

1

2

1

1

12

121

121

121

101

1111)(

)()(

)()(

)()(

x

xtt

x

xt

x

xxttx

yytyty

xxtxtx

PPtPtP

ParameterT Co-eff

C

BasisMatrix

M

GeometryG

BlendingFunction

B

yyy

xxx

BGTMGTCty

BGTMGTCtx

)(

)(

Page 19: Modeling Curved Surfaces

19

10 ,

,

,

23

23

23

tdtctbtatz

dtctbtaty

dtctbtatx

tztytxtQ

zzzz

yyyy

xxxx

CTtQ

ddd

ccc

bbb

aaa

ttttQ

zyx

zyx

zyx

zyx

T

C

123

Parametric Cubic CurvesParametric Cubic Curves

Page 20: Modeling Curved Surfaces

20

Parametric Cubic CurvesParametric Cubic CurvesNow co-efficient matrix C can be expressed as a multiple of basis(weight) matrix M and geometry matrix G.

GMTCTtztytxtQ

vectorgeometryixbasis matr

G

G

G

G

mmmm

mmmm

mmmm

mmmm

ttttQ

4

3

2

1

44434241

34333231

24232221

14131211

23 1)(

Each element of geometry vector G has 3 component for x, y and z.Components of G can be expressed as Gx, Gy and Gz.

Page 21: Modeling Curved Surfaces

21

x

x

x

x

x

g

g

g

g

mmmm

mmmm

mmmm

mmmm

tttGMTtx

4

3

2

1

44434241

34333231

24232221

14131211

23 1)(

x

functionblendinga

x

x

x

gmtmmtmt

gmtmmtmt

gmtmmtmt

gmtmmtmttx

44434242

143

34333232

133

24232222

123

14131212

113

Parametric Cubic CurvesParametric Cubic CurvesMultiplying out only the x-component we get

The curve is a weighted sum of the elements of geometry matrixThe weights are each cubic polynomials of t called blending function

Page 22: Modeling Curved Surfaces

22

Derivative of Derivative of Q(t)Q(t)Derivative of Q(t) is the parametric tangent vector of the curve.

zzzyyyxxx ctbtactbtactbtatQ

CttCTdt

dtQ

tzdt

dty

dt

dtx

dt

dtQ

dt

tdQ

232323

0123

)(

222

2

Page 23: Modeling Curved Surfaces

23

A curve segment A curve segment QQ((tt) is defined by ) is defined by constraintsconstraints on: on:

Each cubic polynomial of Each cubic polynomial of QQ((tt) has ) has 4 coefficients4 coefficients,,

(1)(1) endpoints endpoints

(2)(2) tangent vectors tangent vectors

andand (3) (3) continuity between segments continuity between segments

so so 4 constraints4 constraints will be needed, will be needed,allowing us allowing us

to formulate to formulate 4 equations in the 4 unknowns4 equations in the 4 unknowns,,then solving for the unknowns.then solving for the unknowns.

Curve Design : Curve Design : Determining Determining CC

Page 24: Modeling Curved Surfaces

24

A cubic A cubic Hermite curveHermite curve segment interpolating the segment interpolating the endpoints endpoints PP11 and and PP4 4 is determined by constraints is determined by constraints

ononthe endpoints the endpoints PP11 and and PP44

andandtangent vectors at the endpoints tangent vectors at the endpoints RR11 and and RR44

PP11

PP44

RR11

RR44

Hermit CurvesHermit Curves

Page 25: Modeling Curved Surfaces

25

The Hermite Geometry Vector:The Hermite Geometry Vector:

4

1

4

1

R

R

P

P

GH

x

x

HH

HHxxxxx

GMttt

GMTCTdtctbtatx

123

23

The constraints on The constraints on xx(0) and (0) and xx(1):(1):

x

x

HHx

HHx

GMPx

GMPx

11111

10000

4

1

Hermit CurvesHermit Curves

Page 26: Modeling Curved Surfaces

26

xHH GMtttx

0123

2

Hence the tangent-vector constraints:Hence the tangent-vector constraints:

x

x

HHx

HHx

GMRx

GMRx

01231

01000

4

1

The 4 constraints can be written as:The 4 constraints can be written as:

xx HHH

x

GMG

R

R

P

P

0123

0100

1111

1000

4

1

4

1

Hermit CurvesHermit Curves

Page 27: Modeling Curved Surfaces

27

0001

0100

1233

1122

0123

0100

1111

10001

HM

4

231

23

423

123

2

32132

RttRttt

PttPtt

GBGMTtztytxtQ HHHH

Hermit CurvesHermit Curves

Page 28: Modeling Curved Surfaces

28

11

11tt

ff((tt))

PP11 PP44

RR11

RR44

The Hermite Blending FunctionsThe Hermite Blending Functions

Hermit CurvesHermit Curves

Page 29: Modeling Curved Surfaces

29

Indirectly specifies the endpoint tangent vectors Indirectly specifies the endpoint tangent vectors by specifying two intermediate points that are not by specifying two intermediate points that are not

on the curve.on the curve.

34434

12211

31

30

PPPPQR

PPPPQR

PP11

PP44

PP22

PP33

BBézier Curvesézier Curves

Page 30: Modeling Curved Surfaces

30

The BThe Bézier ézier Geometry Vector:Geometry Vector:

4

3

2

1

P

P

P

P

GB

BHBH GM

P

P

P

P

R

R

P

P

G

4

3

2

1

4

1

4

1

3300

0033

1000

0001

BBBHBH

BHBHHH

GMTGMMT

GMMTGMTtQ

BBézier Curvesézier Curves

Page 31: Modeling Curved Surfaces

31

0001

0033

0363

1331

HBHB MMM

4

3

3

2

22

13 13131 PtPttPttPt

GMTtQ BB

The 4 polynomials in The 4 polynomials in BBB B = = T . MT . MB B are called the are called the Bernstein polynomialsBernstein polynomials..

BBézier Curvesézier Curves

Page 32: Modeling Curved Surfaces

32

The Bernstein PolynomialsThe Bernstein Polynomials

11

11

tt

ff((tt))

1BB

2BB3BB

4BB

BBézier Curvesézier Curves

A Bézier curve is bounded by the convex hull of its control points.

Page 33: Modeling Curved Surfaces

33

What's a Spline?What's a Spline?Smooth curve defined by some control pointsMoving the control points changes the curve

Page 34: Modeling Curved Surfaces

34

SplinesSplines

Page 35: Modeling Curved Surfaces

35

Other CurvesOther CurvesNatural Cubic Spline

C0, C1 and C2 continuous cubic polynomialSmoother than previous curves which don’t have C2 continuity.Interpolates all of the control points

B-SplinesC0, C1 and C2 continuous cubic polynomialDon’t interpolate the control pointsVarieties:

Uniform Vs Nonuniform Rational Vs Non-rational

Catmull-Rom splinesAnd many more….

Page 36: Modeling Curved Surfaces

36

Q(0)Q(1)

Catmull-Rom SplinesCatmull-Rom SplinesInterpolation splines i.e. Passes through all control points.Tangent at any control point is parallel to the line joining the control points adjacent to that point.

i

i

i

i

ii

ii

i

i

BasisHermite

BsCR

P

P

P

P

T

PP

PP

P

P

T

GMTtQi

1

2

3

2

31

1

2

0020

0101

1452

1331

21

2)(

2)(

0001

0100

1233

1122

Page 37: Modeling Curved Surfaces

37

Curve RenderingCurve RenderingBrute-Force methodForward differencingRecursive sub-division

Brute-Force methodt = 0;for (i=0; i <= 100; i++) {

x(t) = axt3+ bxt2+ cxt+ dx

y(t) = ayt3+ byt2+ cyt+ dy

x(t) = azt3+ bzt2+ czt+ dz

Plot3d( x(t), y(t), z(t) );t += 0.01;

}

Page 38: Modeling Curved Surfaces

38

Curve RenderingCurve RenderingForward differencing method

Page 39: Modeling Curved Surfaces

39

Curve RenderingCurve RenderingForward differencing method

= 1 / n;

f =d; f = a3+ b3+ c; f 2= 6a3+ 2b2; f 3= 6a3;

Plot(f.x, f.y, f.z );

for (i=0; i <= n; i++) {

f += f ; f += f 2; f 2+= f 3;

Plot(f.x, f.y, f.z );

}

Page 40: Modeling Curved Surfaces

40

Curve RenderingCurve RenderingRecursive sub-division

Void DrawCurveRecSub(curve, )

{

if (Straight(curve, )

DrawLine(curve);

else {

SubdivideCurve(curve, leftCurve, rightCurve);

DrawCurveRecSub(leftCurve, );DrawCurveRecSub(RightCurve, );

}

}

P1

P4P2

P3d2

d3

Straight if d2 < and d3 <

Page 41: Modeling Curved Surfaces

41

Sub-Division of BSub-Division of Bézier ézier CurvesCurves

Page 42: Modeling Curved Surfaces

Curved SurfacesCurved Surfaces

Page 43: Modeling Curved Surfaces

43

Planer SurfacesPlaner SurfacesUsing bi-linear interpolation

Page 44: Modeling Curved Surfaces

44

Parametric Bicubic Parametric Bicubic SurfacesSurfaces

1

1

1

1

),(

)(

2

3

00010203

10111213

20212223

30313233

23

2

3

23

00011023

3233

33

2323

23

t

t

t

cccc

cccc

cccc

cccc

sss

t

t

t

dcba

d

c

b

a

sss

atasatsatsa

dtctbtadcsbsastsQ

dctbtattQ

product cartesian using surface Curved

ts

T

MGMC

TCStsQ

),(

Page 45: Modeling Curved Surfaces

45

Parametric Bicubic Parametric Bicubic SurfacesSurfaces

Generalization of parametric cubic curvesThe elements of geometry matrix are curves themselves instead of constants.

)(

)(

)(

)(

1)(),(

4

3

2

1

23

tG

tG

tG

tG

MssstGMStsQ ss

4

3

2

1

)(

i

i

i

i

ti

g

g

g

g

MTtG

Page 46: Modeling Curved Surfaces

46

Parametric Bicubic Parametric Bicubic SurfacesSurfaces

TTTT

TTt

t

ABCCBA

TM

gggg

gggg

gggg

gggg

tG

tG

tG

tG

gggg

gggg

gggg

gggg

MTtGtGtGtG

44434241

34333231

24232221

14131211

4

3

2

1

44342414

43332313

42322212

41312111

4321

)(

)(

)(

)(

)()()()(

Page 47: Modeling Curved Surfaces

47

Parametric Bicubic Parametric Bicubic SurfacesSurfaces

TMGMStsz

TMGMStsy

TMGMStsx

tsTMGMStsQ

TM

gggg

gggg

gggg

gggg

MS

tG

tG

tG

tG

MStsQ

Ttzs

Ttys

Ttxs

TTts

TTtss

),(

),(

),(

1,0),(

)(

)(

)(

)(

),(

44434241

34333231

24232221

14131211

4

3

2

1

is form the z, and yx,

of each for separately Written

Page 48: Modeling Curved Surfaces

48

Hermite SurfacesHermite SurfacesHarmite Surfaces are completely defined by a 4X4 geometry Matrix GH

The surface is a stacking of (s) CurvesEach (s) curve is a Harmite CurveWith end points and end tangents as function of (t)

Page 49: Modeling Curved Surfaces

49

Hermite SurfaceHermite Surface

Page 50: Modeling Curved Surfaces

50

Hermite SurfaceHermite Surface

P(0,0)

P(0,1)P(1,1)

P(1,0)

t

)0,0(Pt

)1,0(Pt )1,1(P

t

)0,1(Pt

s

)0,0(Ps

)1,1(Ps

)0,1(Ps

)0,0(Ps

)0,0(2

Pts

)1,0(2

Pts

)1,1(2

Pts

)0,1(2

Pts

Page 51: Modeling Curved Surfaces

51

Connecting Hermite Connecting Hermite PatchesPatches

To join two patches in s direction:

Patch 1 Patch 2

t = 1

t = 0

s = 1

s = 0s = 0 s = 1

t = 1

t = 0t

s

44434241

24232221

44434241

24232221

21

kgkgkgkg

gggg

gggg

gggg

PatchPatch

For C1 continuity k = 1

Page 52: Modeling Curved Surfaces

52

BBézier Surfaceézier SurfaceBézier geometry matrix G consists of 16 control points.Bézier bicubic formulation can be derived in exactly the same way as the Hermite cubic:

TTBBB

TTBBB

TTBBB

TMGMStsz

TMGMStsy

TMGMStsx

z

y

x

),(

),(

),(

P41

P42P43

P44

P34

P24

P14

P13

P12P11

P21

P31P32

P33

P22 P23