CHAPTER 10 Curves and Surfaces

24
CHAPTER 10 Curves and Surfaces Vivian by Richard S. Wright Jr.

description

CHAPTER 10 Curves and Surfaces. by Richard S. Wright Jr. Vivian. Objectives. Introduce OpenGL evaluators Learn to render polynomial curves and surfaces Discuss quadrics in OpenGL - GLUT Quadrics - GLU Quadrics. What Does OpenGL Support?. - PowerPoint PPT Presentation

Transcript of CHAPTER 10 Curves and Surfaces

Page 1: CHAPTER  10 Curves and Surfaces

CHAPTER 10

Curves and Surfaces

Vivian

by Richard S. Wright Jr.

Page 2: CHAPTER  10 Curves and Surfaces
Page 3: CHAPTER  10 Curves and Surfaces

Objectives• Introduce OpenGL evaluators• Learn to render polynomial curves

and surfaces• Discuss quadrics in OpenGL

- GLUT Quadrics- GLU Quadrics

Page 4: CHAPTER  10 Curves and Surfaces

What Does OpenGL Support?

• Evaluators: a general mechanism for working with the Bernstein polynomials- Can use any degree polynomials- Can use in 1-4 dimensions- Automatic generation of normals and texture coordinates- NURBS supported in GLU

• Quadrics– GLU and GLUT contain polynomial

approximations of quadrics

Page 5: CHAPTER  10 Curves and Surfaces

Quadrics

Page 6: CHAPTER  10 Curves and Surfaces

Quadrics• Void

gluQuadricDrawStyle(GLUquadricObj *obj, GLenum drawStyle);

• void gluQuadricNormals(GLUquadricObj *pbj, GLenum normals);

Page 7: CHAPTER  10 Curves and Surfaces

Draw a quadrics• Draw a sphere:

– void gluSphere(GLUQuadricObj *obj, GLdouble radius, GLint slices, GLint stacks);

Page 8: CHAPTER  10 Curves and Surfaces

Draw a quadricsvoid gltDrawUnitAxes(void)

Page 9: CHAPTER  10 Curves and Surfaces

Curves and Surfaces Overview

• What is a parametric curve/surface?• Why use parametric curves &

surfaces?• Bézier curves & surfaces• NURBS• Trimmed surfaces• OpenGL library

Page 10: CHAPTER  10 Curves and Surfaces

What is a parametric curve?2D parametric curve takes the form

xy

f(t)g(t)

Where f(t) and g(t)are functions of t

=

Example: Line thru points a and bxy

(1-t) ax + t bx(1-t) ay+ t by

=

Mapping of the real line to 2D: here t in [0,1] line segment a,b

y = mx + b

Page 11: CHAPTER  10 Curves and Surfaces

What is a parametric curve?3D curves defined similarly

xyz

f(t)g(t)h(t)

=

Example: helixxyz

cos(t)sin(t)t

=

Page 12: CHAPTER  10 Curves and Surfaces

Parametric representation of curves and surfaces.

Page 13: CHAPTER  10 Curves and Surfaces

Control Points

The order of the curve is represented by the number of control points used to describe its shape. The degree is one less than the order of the curve.

Page 14: CHAPTER  10 Curves and Surfaces

Bézier CurvesExample

slinear: b(t) = (1-t) b0 + t b1

quadratic: b(t) = (1-t)2 b0 + 2(1-t)t b1 + t2 b2cubic: b(t) = (1-t)3 b0 + 3(1-t)2 t b1 + 3(1-t)t2 b2 + t3 b3

Bernstein basis Bin (t) = {n!/(n-i)! i!} (1-t)n-i ti

n=1

n=2

n=3

Page 15: CHAPTER  10 Curves and Surfaces

Continuity

Page 16: CHAPTER  10 Curves and Surfaces

Bézier Curves in OpenGLBasic steps:

Define curve by specifying degree, control points and parameter space [u0,u1]

Enable evaluatorCall evaluator with parameter u in [u0, u1]

Specify each u:glEvalCoord1*()

Autocreate uniformly spaced u:glMapGrid1*()glEvalMesh1()

glMap1*()

or

Color and texture available too!

Page 17: CHAPTER  10 Curves and Surfaces

What is a parametric surface?

3D parametric surface takes the form

xyz

f(u,v)g(u,v)h(u,v)

Where f,g,h are bivariate functions of u and v

=

mapping u,v-space to 3-space;this happens to be a function too

Example: x(u,v) =

uvu2 + v2

Page 18: CHAPTER  10 Curves and Surfaces

Bézier Surfaces in OpenGLBasic steps:

Define curve by specifying degree, control points and parameter space [u0,u1]

Enable evaluatorCall evaluator with parameter u in [u0, u1,v0 , v1]

glMap2*()

Page 19: CHAPTER  10 Curves and Surfaces

Bézier SurfaceMultiple patches connected smoothly

Conditions on control netsimilar to curves …difficult to do manually

Page 20: CHAPTER  10 Curves and Surfaces

NURBSNon-uniform Rational B-splines

B-splines are piecewise polynomialsOne or more Bezier curves /surfacesOne control polygon

Rational: let’s us represent circles exactly

GLU NURBS utility

Page 21: CHAPTER  10 Curves and Surfaces

From Bézier to B-Splines

Page 22: CHAPTER  10 Curves and Surfaces

Creating a NURBS Surface• Evaluator →NURBS• Knots

Page 23: CHAPTER  10 Curves and Surfaces

Trimming

Page 24: CHAPTER  10 Curves and Surfaces

Trimmed SurfacesParametric surface with parts of the

domain “invisible”

Jorg Peters’ UFL group

GLU Trimmed NURBS utility

SurfLab

domain