+ All Categories
Home > Documents > MAE 152 Computer Graphics for Scientists and Engineers

MAE 152 Computer Graphics for Scientists and Engineers

Date post: 19-Jan-2016
Category:
Upload: alka
View: 40 times
Download: 0 times
Share this document with a friend
Description:
MAE 152 Computer Graphics for Scientists and Engineers. Splines and Bezier Curves. Introduction. |Representing Curves A number of small line-segments joined Interpolation Parametric equations Types of curve we study Natural Cubic Splines and Bezier Curves Derivation Implementation. - PowerPoint PPT Presentation
Popular Tags:
76
MAE 152 Computer Graphics for Scientists and Engineers Splines and Bezier Curves
Transcript
Page 1: MAE 152 Computer Graphics for Scientists and Engineers

MAE 152Computer Graphics for Scientists

and Engineers

Splines and Bezier Curves

Page 2: MAE 152 Computer Graphics for Scientists and Engineers

Introduction• |Representing Curves

– A number of small line-segments joined

• Interpolation

• Parametric equations

• Types of curve we study

– Natural Cubic Splines and Bezier Curves

• Derivation

• Implementation

Page 3: MAE 152 Computer Graphics for Scientists and Engineers

“Computers can’t draw curves.”

The more points/line segments that are used, the smoother the curve.

Page 4: MAE 152 Computer Graphics for Scientists and Engineers

Why have curves ?

• Representation of “irregular surfaces”• Example: Auto industry (car body design)

– Artist’s representation– Clay / wood models– Digitizing– Surface modeling (“body in white”)– Scaling and smoothening– Tool and die Manufacturing

Page 5: MAE 152 Computer Graphics for Scientists and Engineers

Curve representation• Problem: How to represent a curve easily

and efficiently

• “Brute force and ignorance” approaches:

• storing a curve as many small straight line segments

– doesn’t work well when scaled – inconvenient to have to specify so many points– need lots of points to make the curve look smooth

• working out the equation that represents the curve– difficult for complex curves– moving an individual point requires re-calculation of the

entire curve

Page 6: MAE 152 Computer Graphics for Scientists and Engineers

Solution - Interpolation

•Define a small number of points

•Use a technique called “interpolation” to invent the extra points for us.

•Join the points with a series of (short) straight lines

Page 7: MAE 152 Computer Graphics for Scientists and Engineers

The need for smoothness• So far, mostly polygons• Can approximate any geometry, but

– Only approximate– Need lots of polygons to hide discontinuities

• Storage problems

– Math problems• Normal direction• Texture coordinates

– Not very convenient as modeling tool

• Gets even worse in animation– Almost always need smooth motion

Page 8: MAE 152 Computer Graphics for Scientists and Engineers

Geometric modeling• Representing world geometry in the computer

– Discrete vs. continuous again

• At least some part has to be done by a human– Will see some automatic methods soon

• Reality: humans are discrete in their actions• Specify a few points, have computer create

something which “makes sense”– Examples: goes through points, goes “near” points

Page 9: MAE 152 Computer Graphics for Scientists and Engineers

Requirements

• Want mathematical smoothness– Some number of continuous derivatives of P

• Local control– Local data changes have local effect

• Continuous with respect to the data– No wiggling if data changes slightly

• Low computational effort

Page 10: MAE 152 Computer Graphics for Scientists and Engineers

A solution• Use SEVERAL polynomials

• Complete curve consists of several pieces

• All pieces are of low order– Third order is the most common

• Pieces join smoothly

• This is the idea of spline curves– or just “splines”

Page 11: MAE 152 Computer Graphics for Scientists and Engineers

Parametric Equations - linear

x0,y0

x1,y1

dy

dx

(13,8)

(2,3)

P0

P1

(7.5,4)

Walk from P0 to P1 at a constant speed.

Start from P0 at t=0

Arrive at P1 at t=1

dx = x1 - x0

dy = y1 - y0

Where are you at a general time t?

x(t) = x0 + t.dx

y(t) = y0 + t.dy

Equation(s) of a straight line as a function of an arbitrary parameter t.

Page 12: MAE 152 Computer Graphics for Scientists and Engineers

Why use parametric equations?

• One, two, three or n-dimensional representation is possible

• Can handle “infinite slope” of tangents

• Can represent multi-valued functions

Page 13: MAE 152 Computer Graphics for Scientists and Engineers

For this class …

• Natural Cubic Spline

• Bezier Curves

Page 14: MAE 152 Computer Graphics for Scientists and Engineers

Splines

• Define the “knots”– (x0,y0) - (x3,y3)

• Calculate all other points

spline

knots

Page 15: MAE 152 Computer Graphics for Scientists and Engineers

Continuity

• Parametric continuity Cx– Only P is continuous: C0

• Positional continuity

– P and first derivative dP/du are continuous: C1• Tangential continuity

– P + first + second: C2• Curvature continuity

• Geometric continuity Gx– Only directions have to match

Page 16: MAE 152 Computer Graphics for Scientists and Engineers

)0(G

)1(G

(a)

(b)

(c)

continuity order th0

continuity order st1

continuity order nd2)2(G

)0(C

)1(C

)2(C

Order of continuity

Page 17: MAE 152 Computer Graphics for Scientists and Engineers

Wiggling effect

• Example: – Four data points– Third degree polynomial – Might look something like:

• This the ONLY third degree polynomial which fits the data

• Wiggling gets much worse with higher degree

Page 18: MAE 152 Computer Graphics for Scientists and Engineers

Polynomial parametric equations• To represent a straight

line - linear parametric equation (i.e. one where the highest power of t was 1).

• For curves, we need polynomial equations. Why? Because the graphs of polynomial equations wiggle!

Page 19: MAE 152 Computer Graphics for Scientists and Engineers

Natural Cubic Spline

• spline, n. 1 A long narrow and relatively thin piece or strip of wood, metal, etc. 2 A flexible strip of wood or rubber used by draftsmen in laying out broad sweeping curves, as in railroad work.

• A natural spline defines the curve that minimizes the potential energy of an idealized elastic strip.

Page 20: MAE 152 Computer Graphics for Scientists and Engineers

• A natural cubic spline defines a curve, in which the points P(u) that define each segment of the spline are represented as a cubic P(u) = a0 + a1u + a2u2 + a3u3

• Where u is between 0 and 1 and a0, a1, a2 and a3 are (as yet) undetermined parameters.

• We assume that the positions of n+1 control points Pk, where k = 0, 1,…, n are given, and the 1st and 2nd derivatives of P(u) are continuous at each interior control point.

Page 21: MAE 152 Computer Graphics for Scientists and Engineers

• Undesirable wiggles and oscillations for higher orders

• The lowest order polynomials to satisfy the following conditions

Why cubic?

Caution! Heavy math ahead!

Page 22: MAE 152 Computer Graphics for Scientists and Engineers

minu

maxu

u

0u

1u

2u

nu1nu

)(uQ

A parametrically defined curve

)()()(

)(uzuyux

uQ

sequenceknot uniform then , Ifvectorknot sequenceknot

iu

uuuuuuuuuu

i

nn

nn

),,,,( 110

max110min

Parameterization

Page 23: MAE 152 Computer Graphics for Scientists and Engineers

0u 1u 2u 3u iu 1iu mu

)(uY)(1 uY

)(0 uY)(2 uY

)(uYm

i 1i

10

,,2,1,0),()(Y

),(

1i

1

u

niuu

uuYu

uuuuY

ii

i

ii

non-uniform

“Re-parameterization”

Page 24: MAE 152 Computer Graphics for Scientists and Engineers

0V

1V

2V

3V

4V

5V6V

Interpolation

0V

1V 2V

3V 4V

5V

6V

Approximation

Interpolation versus Approximation

Page 25: MAE 152 Computer Graphics for Scientists and Engineers

0y1y

2y

3y

4y

5y 6y)(0 uY )(uY

)(5 uY

u

6u

0u

1)1(

)1(

1

≡32)1(

≡)0(

≡)1(

≡)0(

iiiii

iii

iiiiii

iii

DdcbY

DbY

ydcbaY

yaY

5,...,010

)( 32

iu

uducubau iiii

Yi

11

11

)(2

2)(3

iiiii

iiiii

ii

ii

DDyyd

DDyyc

Db

ya

1 2 3 4 5

Hermite Interpolation

Page 26: MAE 152 Computer Graphics for Scientists and Engineers

Hermite Spline• Say the user provides • A cubic spline has degree 3, and is of the form:

– For some constants a, b, c and d derived from the control points, but how?

• We have constraints:– The curve must pass through x0 when t=0– The derivative must be x’0 when t=0– The curve must pass through x1 when t=1– The derivative must be x’1 when t=1

dctbtatx 23

1010 ,,, xxxx

Page 27: MAE 152 Computer Graphics for Scientists and Engineers

10

))(1() 11

avrage hted weig

(y (2) i iii yyy

directly specifying (3)

1,, ii yyy and through parabola a fitting e.g.

llyautomatica D Computing

(1)

-1i

i

1iy

iy

1iy1iP

iP

1iP

How to specify slope Di

Page 28: MAE 152 Computer Graphics for Scientists and Engineers

Hermite SplineA Hermite spline is a curve for which the user provides:

– The endpoints of the curve– The parametric derivatives of the curve at the endpoints

• The parametric derivatives are dx/dt, dy/dt, dz/dt – That is enough to define a cubic Hermite spline, more

derivatives are required for higher order curves

Page 29: MAE 152 Computer Graphics for Scientists and Engineers

Hermite Spline• Solving for the unknowns gives:

• Rearranging gives:

0

0

0101

0101

23322

xdxc

xxxxbxxxxa

)2( )(x

)132( )32(

230

231

230

231

tttxtt

ttxttxx

10121

0011

1032

00322

3

0101t

t

t

xxxxx

or

Page 30: MAE 152 Computer Graphics for Scientists and Engineers

Hermite curves in 2D and 3D• We have defined only 1D splines:

x = f(t:x0,x1,x’0,x’1)

• For higher dimensions, define the control points in higher dimensions (that is, as vectors)

10121

0011

1032

00322

3

0101

0101

0101

t

t

t

zzzz

yyyy

xxxx

z

y

x

Page 31: MAE 152 Computer Graphics for Scientists and Engineers

Basis Functions• A point on a Hermite curve is obtained by

multiplying each control point by some function and summing

• The functions are called basis functions

-0.4

-0.2

0

0.2

0.4

0.6

0.8

1

1.2

x1

x0

x'1

x'0

Page 32: MAE 152 Computer Graphics for Scientists and Engineers

0V

1V

2V

3V

4V

5V6V

An interpolating cubic spline

),(

))(),(()(

iii

iii

yxV

uyuxuQ

Hermite and Cubic Spline Interpolation

Page 33: MAE 152 Computer Graphics for Scientists and Engineers

(knots) jointsat continuity )2(C

0y1y

2y

iy

1iy

my)(0 uY )(uY

)(1 uYm

)(1 uY

mm

ii

ii

ii

ii

yY

yY

miYY

YY

yY

yY

)1(

)0(

11 )0()1(

)0()1(

)0(

)1(

1

00

)2()2(1

)1()1(1

1

44 m

2

need two more Eq’s to determine all coefficients10)( 32 miuducubauY iiiii : note

Spline Interpolation

0)1(

0)0()2(1

)2(0

mY

Y

Natural Spline

Page 34: MAE 152 Computer Graphics for Scientists and Engineers

11

)(34

)(2

2)(3

262

1111

11

11

11

mi

yyDDD

DDyyd

DDyyc

Db

ya

cdc

iiiii

iiiii

iiiii

ii

ii

iii

tion,simplifica and onsubstitutiBy

(4)

0)1(

0)0(

)1(

)0(

)0()1(

)0()1(

)0(

)1(

)2(1

)2(0

1

00

)2()2(1

)1()1(1

1

m

mm

ii

ii

ii

ii

Y

Y

yY

yY

YY

YY

yY

yY

(8)

(7)

(6)

(5)

(4)

(3)

(2)

(1)

11 mi

32 tdtctbay iiiii

Deriving Natural Cubic Splines

)(32

(8) from Similarly,

)(32

tion,simplifica and onsubstitutiBy

02

(7), From

conditions-end Applying

11

0110

0

mmmm yyDD

yyDD

c

Page 35: MAE 152 Computer Graphics for Scientists and Engineers

)(3

)(3

)(3

)(3

21

141

....

141

141

141

12

1

2

02

01

1

0

mm

mm

m yy

yy

yy

yy

D

D

D

Tri-Diagonal Matrix for Natural Cubic Spline

Page 36: MAE 152 Computer Graphics for Scientists and Engineers

iP

mP0P

2P

1P

HomeworkHomework

)(34 1111 iiiii yyDDD

)(3

)(3

)(3

)(3

411

141

....

141

141

141

114

10

2

02

1

1

0

m

mm

m

m yy

yy

yy

yy

D

D

D

Closed Curves

Page 37: MAE 152 Computer Graphics for Scientists and Engineers

Bezier Curves

• An alternative to splines

• M. Bezier was a French mathematician who worked for the Renault motor car company.

• He invented his curves to allow his firm’s computers to describe the shape of car bodies.

Page 38: MAE 152 Computer Graphics for Scientists and Engineers

? and provide to How 41 R R

1P4P

1R 4R

mation Approxi

and

!!! points control additional two provide , and providing of Instead

32

41

PP

RR1P

4P

2P 3P

Bezier Approximation

Page 39: MAE 152 Computer Graphics for Scientists and Engineers

Bezier curves

• Typically, cubic polynomials

• Similar to Hermite interpolation– Special way of specifying end tangents

• Requires special set of coefficients

• Need four points– Two at the ends of a segment– Two control tangent vectors

Page 40: MAE 152 Computer Graphics for Scientists and Engineers

Bezier curves• Control polygon: control points connected to each

other

• Easy to generalize to higher order– Insert more control points– Hermite – third order only

Page 41: MAE 152 Computer Graphics for Scientists and Engineers

De Casteljau algorithm

• Can compute any point on the curve in a few iterations

• No polynomials, pure geometry

• Repeated linear interpolation– Repeated order of the curve times

• The algorithm can be used as definition of the curve

Page 42: MAE 152 Computer Graphics for Scientists and Engineers

De Casteljau algorithm

Third order, u=0.75

Page 43: MAE 152 Computer Graphics for Scientists and Engineers

De Casteljau algorithm

Page 44: MAE 152 Computer Graphics for Scientists and Engineers

De Casteljau algorithm

Page 45: MAE 152 Computer Graphics for Scientists and Engineers

De Casteljau algorithm

Page 46: MAE 152 Computer Graphics for Scientists and Engineers

De Casteljau Algorithm

3P

1P 2P

t

t1

t1 t1

t1t1

t

tt

t

0P0P

1P

2P

3P

t1

t

t1

t

t1

t

10)1( tPPt

21)1( tPPt

32)1( tPPt

t1

t

t1

t

22

102 )1(2)1(

Pt

tPtPt

32

212 )1(2)1(

Pt

tPtPt

t1

t

33

22

12

03

)1(3

)1(3

)1(

Pt

Ptt

tPt

Pt

ii

i

tti

33

0

)1(3

Page 47: MAE 152 Computer Graphics for Scientists and Engineers

0

1

1

3)1( t2)1(3 -tt

3t

)1(3 2 -tt

Now,

1)1(3 3

3

0

ii

i

tti

What does it mean ?

10)1(3

)1(3)1(3)1()(

0001

0033

0363

1331

1)(

33

0

43

32

22

13

4

3

2

1

23

t, Ptt

i

PtP-ttP-ttPttQ

GMT

P

P

P

P

ttttQ

iii

i

bb

3))1(( tt

Page 48: MAE 152 Computer Graphics for Scientists and Engineers

Bezier Polynomial Function

iniin tt

ini

ntB

)1.(.

)!(!

!)(

Page 49: MAE 152 Computer Graphics for Scientists and Engineers

Parametric equations for x(t),y(t)

)(.)(0

tBxtx in

n

ii

)(.)(0

tByty in

n

ii

Page 50: MAE 152 Computer Graphics for Scientists and Engineers

Some Bezier Curves

Page 51: MAE 152 Computer Graphics for Scientists and Engineers

Bezier Curves - properties• Not all of the control points are on the line

– Some just attract it towards themselves• Points have “influence” over the course of the line• “Influence” (attraction) is calculated from a

polynomial expression• (show demo applet)

Page 52: MAE 152 Computer Graphics for Scientists and Engineers

1P

3P

2P

4P

Convex Hull property

Page 53: MAE 152 Computer Graphics for Scientists and Engineers

Bezier Curve Properties• The first and last control points are interpolated• The tangent to the curve at the first control point is along

the line joining the first and second control points• The tangent at the last control point is along the line

joining the second last and last control points• The curve lies entirely within the convex hull of its control

points– The Bernstein polynomials (the basis functions) sum to 1 and are

everywhere positive• They can be rendered in many ways

– E.g.: Convert to line segments with a subdivision algorithm

Page 54: MAE 152 Computer Graphics for Scientists and Engineers

Disadvantages

• The degree of the Bezier curve depends on the number of control points.

• The Bezier curve lacks local control. Changing the position of one control point affects the entire curve.

Page 55: MAE 152 Computer Graphics for Scientists and Engineers

Invariance• Translational invariance means that translating

the control points and then evaluating the curve is the same as evaluating and then translating the curve

• Rotational invariance means that rotating the control points and then evaluating the curve is the same as evaluating and then rotating the curve

• These properties are essential for parametric curves used in graphics

• It is easy to prove that Bezier curves, Hermite curves and everything else we will study are translation and rotation invariant

Page 56: MAE 152 Computer Graphics for Scientists and Engineers

Longer Curves• A single cubic Bezier or Hermite curve can only capture a

small class of curves– At most 2 inflection points

• One solution is to raise the degree– Allows more control, at the expense of more control points

and higher degree polynomials– Control is not local, one control point influences entire curve

• Alternate, most common solution is to join pieces of cubic curve together into piecewise cubic curves– Total curve can be broken into pieces, each of which is cubic– Local control: Each control point only influences a limited

part of the curve– Interaction and design is much easier

Page 57: MAE 152 Computer Graphics for Scientists and Engineers

Piecewise Bezier Curve

“knot”P0,0

P0,1 P0,2

P0,3

P1,0

P1,1

P1,2

P1,3

Page 58: MAE 152 Computer Graphics for Scientists and Engineers

Continuity• When two curves are joined, we typically want some

degree of continuity across the boundary (the knot)– C0, “C-zero”, point-wise continuous, curves share the same point

where they join– C1, “C-one”, continuous derivatives, curves share the same

parametric derivatives where they join– C2, “C-two”, continuous second derivatives, curves share the same

parametric second derivatives where they join– Higher orders possible

• Question: How do we ensure that two Hermite curves are C1 across a knot?

• Question: How do we ensure that two Bezier curves are C0, or C1, or C2 across a knot?

Page 59: MAE 152 Computer Graphics for Scientists and Engineers

Achieving Continuity• For Hermite curves, the user specifies the derivatives, so

C1 is achieved simply by sharing points and derivatives across the knot

• For Bezier curves:– They interpolate their endpoints, so C0 is achieved by sharing

control points– The parametric derivative is a constant multiple of the vector

joining the first/last 2 control points– So C1 is achieved by setting P0,3=P1,0=J, and making P0,2 and J and

P1,1 collinear, with J-P0,2=P1,1-J– C2 comes from further constraints on P0,1 and P1,2

Page 60: MAE 152 Computer Graphics for Scientists and Engineers

Bezier Continuity

P0,0

P0,1 P0,2

J

P1,1

P1,2

P1,3

Disclaimer: PowerPoint curves are not Bezier curves, they are interpolating piecewise quadratic curves! This diagram is an approximation.

Page 61: MAE 152 Computer Graphics for Scientists and Engineers

Problem with Bezier Curves

• To make a long continuous curve with Bezier segments requires using many segments

• Maintaining continuity requires constraints on the control point positions– The user cannot arbitrarily move control vertices and

automatically maintain continuity

– The constraints must be explicitly maintained

– It is not intuitive to have control points that are not free

Page 62: MAE 152 Computer Graphics for Scientists and Engineers

Bezier Basis Functions for d=3

0

0.2

0.4

0.6

0.8

1

1.2

B0

B1

B2

B3

Page 63: MAE 152 Computer Graphics for Scientists and Engineers

Bezier Curves in OpenGL

• OpenGL supports Beziers through mechanism called evaluators used to compute the blending functions, bi (u), of any degree.

• Smooth curves and surfaces are drawn by approximating them with large number of small line segments or polygons. Described mathematically by a small number of parameters such as control points.

• 1D Bezier curves can also be used to define paths in time for animation

• Evaluator is a way to compute points on a curve or surface using only control points. They do not require uniform spacing of u. Bezier curves can then be rendered at any precision.

Page 64: MAE 152 Computer Graphics for Scientists and Engineers

Evaluators• A Bezier curve is a vector-valued function of one

variableC(u) = [X(u) Y(u) Z(u)]

and a Bezier surface patch is a vector-valued function of two variable

S(u,v) = [X(u,v) Y(u,v) Z(u,v)]

• To use evaluator– first define the function C(u) or S(u,v)– then use the glEvalCoord{12}() command

Page 65: MAE 152 Computer Graphics for Scientists and Engineers

Berstein Polynomial & Bezier Curve

ini

n

iPuBuC )(

0

inini uu

i

nuB

)1(

12

1

uu

uuC

Page 66: MAE 152 Computer Graphics for Scientists and Engineers

One-Dimensional Evaluators

GLfloat ctrlpoints[4][3] = {...};void init(void) {glMap1f(GL_MAP1_VERTEX_3, 0.0, 1.0,

3, 4, &ctrlpoints[0][0]);}

void display(void) { glBegin(GL_LINE_STRIP);for(i=0; i<=30; i++)

glEvalCoord1f((GLfloat)i/30.0);glEnd();

}

Page 67: MAE 152 Computer Graphics for Scientists and Engineers

Defining 1-D EvaluatorglMap1(target,u1,u2,stride,order,points);

• target: tells what the control points represent

• u1,u2: the range of the variable u

• stride: the number of floating-point values to advance in the data between one control point and the next

• order: the degree plus one, and it should agree with the number of control points

• points: pointer to the first coordinate of the first control point

Page 68: MAE 152 Computer Graphics for Scientists and Engineers

Evaluating 1-D EvaluatorglEvalCoord1(u); glEvalCoord1v(*u);

• Causes evaluation of the enabled maps

• u: the value of the domain coordinate

• More than one evaluator can be defined and evaluated at a time. – (ex) GL_MAP1_VERTEX_3 and GL_MAP1_COLOR_4– In this case, calls to glEvalCoord1() generates both a

position and a color.

Page 69: MAE 152 Computer Graphics for Scientists and Engineers

point ctrlpts[ ] = { ……. } ; glMaplf ( GL_MAP1_VERTEX_3, 0.0, 1.0, 3, 4, ctrlpts);glEnable (GL_MAP1_VERTEX_3);

/* GL_MAP1_VERTEX_3 specifies data type for ctrlpts , range of u = [ 0.0, 1.0], 3 is the number of values between control points , (order = degree +1) = 4 */

/* With evaluator enabled, draw line segments for Bezier curve */

e.g. /* define and enable 1D evaluator for Bezier cubic curve */

 glBegin (GL_LINE_STRIP);for ( i = 0; i <= 30; i ++)

glEvalCoord1f ( (Glfloat) i/30.0);glEnd ( )

Page 70: MAE 152 Computer Graphics for Scientists and Engineers

One-Dimensional Grid and Its Eval.

• define a one-dimensional evenly spaced grid using glMapGrid1*(), and then evaluate the (part of) grid points using glEvalMesh1()

• glMapGrid1(n, u1, u2);defines a grid that goes from u1 to u2 in n steps.

• glEvalMesh1(mode, p1, p2);mode: GL_POINT or GL_LINEevaluates from integer indices p1 to p2 with evenly spaced coordinate

Page 71: MAE 152 Computer Graphics for Scientists and Engineers

Bezier Surface

ijmj

ni

m

j

n

iPvBuBvuS )()(,

00

Page 72: MAE 152 Computer Graphics for Scientists and Engineers

Two-Dimensional Evaluators

• Everything is similar to the one-dimensional case, except that all the commands must take two parameters, u and v, into account

1. Define evaluator(s) with glMap2*()2. Enable them with glEnable()3. Invoke them by calling glEvalCoord2() between a glBegin() and glEnd() or by specifying and applying a mesh with glMapGrid2() and glEvalMesh2()

Page 73: MAE 152 Computer Graphics for Scientists and Engineers

Defining and Evaluating

glMap2(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder,

points);

glEvalCoord2(u, v);

glEvalCoord2v(*values);

• Example

Page 74: MAE 152 Computer Graphics for Scientists and Engineers

Grid and Its Evaluation

glMapGrid2(nu, u1, u2, nv, v1, v2);

glEvalMesh2(mode, i1, i2, j1, j2);

Page 75: MAE 152 Computer Graphics for Scientists and Engineers

Using Evaluators for TexturesGLfloat ctrlpoints[4][4][3] = {...};GLfloat texpts[2][2][2] = {...};void init(void) { glMap2f(GL_MAP2_VERTEX_3,...,

&ctrlpoints[0][0][0]);glMap2f(GL_MAP2_TEXTURE_COORD_2,...,

&texpts[0][0][0]);glEnable(GL_ MAP2_VERTEX_3);glEnable(GL_MAP2_TEXTURE_COORD_2);glMapGrid2f(...);

}void display(void) { glEvalMesh2(...);

}

Page 76: MAE 152 Computer Graphics for Scientists and Engineers

End Of Curves


Recommended