0% found this document useful (0 votes)
66 views

Computer Graphics Using OpenGL - 4

The document discusses various methods for representing 3D objects in computer graphics, including polyhedra, spline curves, and Bézier splines. Spline curves can be interpolation or approximation splines, with Hermite and Bézier splines discussed as examples. The properties and mathematical definitions of splines, including continuity conditions and basis functions, are covered in detail.

Uploaded by

Mohit Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
66 views

Computer Graphics Using OpenGL - 4

The document discusses various methods for representing 3D objects in computer graphics, including polyhedra, spline curves, and Bézier splines. Spline curves can be interpolation or approximation splines, with Hermite and Bézier splines discussed as examples. The properties and mathematical definitions of splines, including continuity conditions and basis functions, are covered in detail.

Uploaded by

Mohit Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 80

CSE202

Computer Graphics Using


OpenGL
Unit III
3D Representation

01-05-2021
3D Representation
• Polyhedra
• Spline representation
• Hermite interpolation splines
• Bezier spline curves and surfaces
• B-spline curve equations
• Uniform B-spline
• B-spline surfaces
• OpenGL curve functions

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 2


3D Representation
• Graphics scenes can contain many different kinds of objects and
material surfaces:
• trees, flowers, clouds, rocks, water, bricks, steel, glass etc.
• There is no single method that we can use to describe objects
• Boundary representations(B-reps)
• describe a 3D object as a set of surfaces that separate the object interior from
the environment (Ex: Polyhedra, Spline)
• Space partitioning representation
• partitioning the object into a set of small, non-overlapping, contiguous solids
(Ex.octree representation)

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 3


Polyhedra
• Most commonly used boundary representation for 3D graphics
• All object descriptions as sets of surface polygons
• All surfaces are described with linear equations
• To describe an object as a set of polygon facets, we give the list of
vertex coordinates for each polygon section over the object surface
• The vertex coordinates and edge information for the surface sections
are then stored in tables

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 4


Polyhedra (Contd.)
• Polygon tables

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 5


Polyhedra (Contd.)

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 6


Spline Representations
• Splines are another example of boundary representation
• A spline is a flexible strip used to produce a smooth curve through a
designated set of point
• Spline can be represented as a piecewise cubic polynomial function
whose first and second derivatives are continuous across the various
curve sections
• A spline surface can be described with two sets of spline curves
• Splines are used to design curve and surface shapes, to digitize
drawings, CAD etc

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 7


Interpolation and Approximation Splines
• Specify a spline curve by giving a set of coordinate positions, called
control points, which indicate the general shape of the curve
• These coordinate positions are then fitted with piecewise-continuous,
parametric polynomial functions
• Interpolation
 all the control points are connected
 used to digitize drawings or to specify animation paths
 Ex: Hermite spline
• Approximation
 some, or all, of the control points are not on the curve path
 used primarily as design tools to create object shapes
 Ex: B - spline

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 8


Interpolation and Approximation Splines
(Contd.)

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 9


Splines (Contd.)

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 10


Splines (Contd.)
• Convex hull - a set of control points forms a boundary for a region of
space

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 11


Splines (Contd.)
• Control graph - A polyline
connecting the sequence of
control points for an
approximation spline curve
• Control polygon or characteristic
polygon

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 12


Parametric Continuity Conditions
• Continuity conditions - to ensure a smooth transition from one
section of a piecewise parametric spline to the next
• Each section of a spline curve is described with a set of parametric
coordinate functions

• Zero-order parametric continuity


• simply that the curves meet

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 13


Parametric Continuity Conditions (Contd.)
• First-order parametric continuity
• Tangent lines - two successive curve sections are equal at their joining point

• Second-order
• both the first and second parametric derivatives of the two curve sections are
the same at the intersection

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 14


Geometric Continuity Conditions
• Another method for joining two successive curve sections is to specify
conditions
• The parametric derivatives of the two sections are proportional to
each other at their common boundary
• Zero-order
• two successive curve sections must have the same coordinate position at the
boundary point
• First-order
• the parametric first derivatives are proportional at the intersection of two
successive sections

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 15


Geometric Continuity (Contd.)
• Second-order
• both the first and second parametric derivatives of the two curve sections are
proportional at their boundary

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 16


Spline Specifications
• There are three equivalent methods for specifying a spline
representation
1) state the set of boundary conditions on the spline
2) state the matrix that characterizes the spline
3) set of blending functions(or basis functions)
• Parametric cubic polynomial representation for the “x” coordinate
along the path of a spline-curve section

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 17


Spline Specifications (Contd.)

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 18


Spline Specifications (Contd.)

• Blending functions or basis function

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 19


Spline Surfaces
• A spline surface is to specify two sets of spline curves using a mesh of
control points
• The spline-curve blending functions

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 20


Cubic-Spline Interpolation Methods
• Used to set up paths for object motions
• Cubic splines require less calculations and storage space, and they are
more stable
• Cubic interpolation splines are obtained by fitting the input points
with a piecewise cubic polynomial curve that passes through every
control point

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 21


Cubic-Spline Interpolation (Contd.)
• The parametric cubic polynomial that is to be fitted between each
pair of control points

• We need to determine the values for the four coefficients a, b, c, and


d in the polynomial representation

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 22


Natural Cubic Splines
• Two adjacent curve sections have the same first and second
parametric derivatives at their common boundary
• Each curve must pass through the control point
• If we have n+1 control points, then we have “n” curve sections with a
total of 4n polynomial coefficients to be determined

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 23


Hermite Interpolation
• It is an interpolating piecewise cubic polynomial
• Hermite splines can be adjusted locally because each curve section
depends only on its endpoint constraints

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 24


Hermite Interpolation(Contd.)

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 25


Hermite Interpolation(Contd.)
• We can write the vector equivalent

• The matrix equivalent of equation is

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 26


Hermite Interpolation(Contd.)
• Substituting endpoint values 0 and 1 for parameter “u”

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 27


Hermite Interpolation(Contd.)
• Substituting endpoint values 0 and 1 for parameter “u”

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 28


Hermite Interpolation(Contd.)

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 29


01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 30
Hermite Interpolation(Contd.)
• We can determine expressions for the polynomial Hermite blending
functions

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 31


Hermite Interpolation(Contd.)

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 32


Bézier Spline Curves
• This method was developed by the French engineer Pierre Bézier for
use in the design of Renault automobile bodies
• Highly useful and convenient for curve and surface
• Easy to implement
• A Bézier curve section can be fitted to any number of control points

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 33


Bézier Curve Equations

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 34


Bézier Curve (Contd.)

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 35


Bézier Curve (Contd.)

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 36


Bézier Curve (Contd.)

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 37


Bézier Curve (Contd.)

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 38


Properties of Bézier Curves
• Bézier curve is that connects the first and last control points

• Values for the parametric first derivatives of a Bézier curve at the


endpoints can be calculated from control-point coordinates as

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 39


Properties of Bézier Curves (Contd.)
• The parametric second derivatives of a Bézier curve at the endpoints
are calculated as

• Bézier curve is that it lies within the convex hull of the control point
• Bézier blending functions are all positive and their sum is always 1:

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 40


Design Techniques Using Bézier Curves
• A closed Bézier curve is generated when we set the last control-point
position to the coordinate position of the first control point

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 41


Cubic Bézier Curves
• Many graphics packages provide functions for displaying only cubic
splines
• Cubic Bézier curves are generated with four control points
• The four blending functions for cubic Bézier curves

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 42


Cubic Bézier Curves (Contd.)

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 43


Cubic Bézier Curves (Contd.)

(a-b)^3=a^3-b^3-3a^2b+3ab^2

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 44


Cubic Bézier Curves (Contd.)

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 45


Cubic Bézier Curves (Contd.)
• At u=1, the only nonzero function is BEZ3,3(1)=1
• A cubic Bézier curve always begins at control point p0 and ends at the
position of control point p3
• Blending function BEZ1,3 is maximized at u=1/3, and BEZ2,3 is
maximized at u=2/3

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 46


Cubic Bézier Curves (Contd.)

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 47


Cubic Bézier Curves (Contd.)
• A matrix formulation for the cubic-Bézier curve function is

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 48


Bézier Surfaces
• Two sets of orthogonal Bézier curves can be used to design an object
surface
• Bézier blending functions

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 49


Bézier Surfaces (Contd.)

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 50


Problem - Bézier
• Construct the Bézier curve of order 3 and with 4 polygon vertices
A(1,1), B(2,3), C(4,3) and D(6,4)

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 51


01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 52
01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 53
Problem – Bezier

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 54


Problem – Bezier

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 55


Problem – Bezier
• Find equation of Bezier curve which passes through points (0, 0) and
(-2, 1) and is controlled through points (7, 5) and (2, 0).

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 56


Problem – Bezier

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 57


B-Spline Curves
• B-splines are generated by approximating a set of control points
• B-splines have two advantages over Bézier splines
1) the degree of a B-spline polynomial can be set independently of the
number of control points
2) B-splines allow local control over the shape of a spline

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 58


B-Spline Curve Equations
• B-spline curve using a blending-function formulation as

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 59


B-Spline Curve Equations (Contd.)

n=

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 60


d=4; k varying from 0 to 3
u0=0;u1=1;u2=2;u3=3;.... u7=7

B-Spline Curve Equations (Contd.)

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 61


B-Spline Curve Equations (Contd.)

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 62


B-Spline Curve Equations (Contd.)

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 63


B-Spline Curve Equations (Contd.)

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 64


d=1; k varying from 0 to 6

B-Spline Curve Equations (Contd.)

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 65


B-Spline Curve Equations (Contd.)

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 66


B-Spline Curve Equations (Contd.)

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 67


B-Spline Curve Equations (Contd.)

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 68


B-Spline Curve Equations (Contd.)

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 69


B-Spline Curve Equations (Contd.)

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 70


B-Spline Curve Equations (Contd.)

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 71


B-Spline Curve Equations (Contd.)

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 72


B-Spline Curve (Contd.)
• Each subinterval endpoint uj is referred to as a knot, and the entire
set of selected subinterval endpoints is called a knot vector

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 73


B-Spline Properties

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 74


Uniform Periodic B-Spline Curves
• When the spacing between knot values is constant, the resulting
curve is called a uniform B-spline
• Example:

• Many applications have uniform knot values with a separation of 1


and a starting value of 0

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 75


Uniform Periodic B-Spline (Contd.)
• Uniform B-splines have periodic blending functions

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 76


B-Spline Surfaces
• B-spline surface is similar to that for Bézier splines
• B-spline surface can be created by using the tensor product of
B-spline blending functions in the form

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 77


OpenGL Curve Functions

• A coordinate position along the curve path is calculated with

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 78


OpenGL Curve Functions (Contd.)
• OpenGL provides the following functions, which we can use to
produce a set of uniformly spaced parameter values

• OpenGL Bézier-surface routines are accomplished with

01-05-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 79


References
• Donald D. Hearn, M. Pauline Baker and Warren Carithers, “Computer
Graphics with OpenGL”, Pearson Education, Fourth Edition, 2011.

01-05-2021 80

You might also like