Вы находитесь на странице: 1из 98

GRAPHICS

SUB CODE : CS71


BRANCH : IT
YEAR\SEM : IV \ VII

Presented by :MR.s.Vimal,M.E.,M.B.A
Asst.Prof / IT
UNIT - 2
THREE-DIMENSIONAL CONCEPTS

SYLLABUS

Three dimensional Object representation Three


Dimensional Geometric and modeling Transformations
Three dimensional Viewing - Color models Animation.
THREE DIMENSIONAL
CONCEPTS
Introduction
Graphics scenes can contain many different kinds of
objects
No one method can describe all these objects
Accurate models produce realistic displays of scenes
Polygon and quadric surfaces
Spline surfaces and construction techniques
Procedural methods
Physically-based modeling methods
Octree encodings
Boundary representations (B-reps)
Space-partitioning representations
Polygon Surfaces
The most commonly used boundary represent-
ation
All surfaces are described with linear equations
Simplify and speed up surface rendering and display of
objects
Precisely define a polyhedron
For non-polyhedron objects, surfaces are tesselated
Commonly used in design and solid modeling
The wireframe outline can be display quickly
Polygon Tables
Specify a polygon surface
Geometric tables
Vertex coordinates
Spatial orientation of the polygon
Attribute tables
Degree of transparency
Surface reflectivity
Texture
Polygon Tables
Convenient organization for geometric data
Vertex Table v1
Edge Table
Polygon Table
E3 E6
E1
S1
v3 S2 v5
E2
E4 E5
v2
v4
Polygon Tables
Polygon Tables
Alternative arrangements
Use just two tables: a vertex table and a polygon table
Some edges could get drawn twice
Use only a polygon table
This duplicates coordinate information
Extra information to the data tables
Expand the edge table to include forward pointers into the polygon
table
Common edges between polygons
Expand vertex table to contain cross-reference to corresponding
edges
Polygon Tables
Additional geometric information
The slope for each edge
Coordinate extents for each polygon
Tests for consistency and completeness
Every vertex is an endpoint for at least two edges
Every edge is part of at least one polygon
Every polygon is closed
Each polygon has at least one shared edge
Every edge referenced by a polygon pointer has a
reciprocal pointer back to the polygon
Plane equation
To produce a 3d object we must process i/p
data into several procedures
Transformation of modelling and viewing
To device coordinate
Identify visible surfaces
Application of surface rendering procedures
Plane Equations
The equation for a plane surface
Ax + By + Cz +D = 0
By Cramers rule:

Values of A,B,C and D are computed for each


polygon and stored with the other polygon data
Plane Equations
Orientation of a plane surface
Surface normal vector (A, B, C)
Distinguish two sides of a surface
Inside face
Outside face
The normal vector from inside to outside
Viewing the outer side of the plane in a right-handed
coordinate system
Vertices are specified in counterclockwise direction
Plane Equations

N=(A,B,
C)
Plane Equations
Plane Equations
Identify a point (x, y, z) as either inside or outside a
plane surface
In a right-handed coordinate system, the plane
parameters A, B, C, and D were calculated using
vertices selected in a counterclockwise order when
viewing the surface in an outside-to-inside direction.

If Ax+By+Cz+D<0, the point(x,y,z) is inside the surface


If Ax+By+Cz+D>0, the point(x,y,z) is outside the surface
Curved Lines and Surfaces
The generation of 3D curved lines and surfaces
An input set of mathematical functions
A set of user-specified data points
Curve and surface equations
Parametric (more convenient)
Nonparametric
Quadric Surfaces
Sphere
Ellipsoid
Torus
Quadric Surfaces
Primitives from which more complex objects can be
constructed

Sphere
x y z r
2 2 2 2

x r cos cos
/ 2 / 2
y r cos sin
z r sin
Quadric Surfaces
2
y z
2 2
x
Ellipsoid 1
r r r
x y z

x rx cos cos
/ 2 / 2
y ry cos sin
z rz sin
Quadric Surfaces
2
2
x y
2 2
Torus
r z 1
r
x y
r rz

x rx ( r cos ) cos

y ry ( r cos ) sin

z rz sin
Torus
Superquadrics
A generalization of the quadric representations
Incorporate additional parameters into the quadric equations
The number of additional parameters used is equal to the
dimension of the object.
Superellipse 2/s
y
2/s
x
1
r
rx y

x rx cos s


y ry sin s
Superquadrics
Superellipsoid
s2
x 2 / s2 y 2 / s2 s1
z
2 / s1

1
rx r
y rz

x rx cos cos
s1 s2

/ 2 / 2
y ry cos sin
s1 s2

z rz sin s1

Spline Representations
Spline: In drafting terminology
A flexible strip used to produce a smooth curve through
a designated set of points
Several small weights are distributed along the strip
Spline Curve: In computer graphics
Any composite curve formed with (cubic) polynomial
sections satisfying specified continuity conditions at the
boundary of the pieces.
Spline surface
Described with two sets of orthogonal spline curves
There are several different kinds of spline specifications
Superellipse
Interpolation and Approximation
Splines
Control points
A set of coordinate positions indicates the general shape of
the curve
A spline curve is defined, modified, and manipulated with
operations on the control points.
Interpolation curves: the curve passes through each
control points
Digitize drawings
Specify animation path
Approximation curves: fits to the general control-points
path without necessarily passing through any control points
Design tools to structure surfaces
To see microsoft word
Interpolation and Approximation
Splines
Interpolation and Approximation
Splines
Convex hull
The convex polygon boundary encloses a set of control
points.
Provide a measure for the deviation of a curve or
surface from the region bounding the control points
Interpolation and Approximation
Splines
Control graph (control polygon, characteristic polygon)
Parametric Continuity
Continuity conditions
To ensure a smooth transition from one section of a
piecewise parametric curve to the next.
Set parametric continuity by matching the parametric
derivatives of adjoining curve sections at their common
boundary.
Zero-order (C0) continuity
First-order (C1) continuity
Second-order (C2) continuity
The rates of change of the tangent vectors for
connecting sections are equal at their intersection.
Parametric Continuity
Geometric Continuity
Geometric continuity
C2
p0
Parametricpderivatives
1 of the two
p2 sections to be
proportional
C1 to each other at the joint
Zero-order geometric continuity (G0)
C3
First-order
p0 geometric continuity (G1)
p1 p2
Second-order geometric continuity (G2)
C1
With geometric continuity, the curve is pulled
toward the section with the greater tangent
vector.
Spline Specifications
Three methods for specifying a spline
A set of boundary conditions imposed on the spline
The matrix characterizes the spline
The set of blending functions (or basis functions)
Boundary conditions
x(u)=axu3+bxu2+cxu+dx 0<=u<=1
On the endpoints x(0) and x(1).
First derivatives at the endpoints x(0) and x(1).
Determine the values of ax, bx, cx, and dx.
Spline Specifications
Cubic Spline Interpolation
Methods
Cubic polynomials
Offer a reasonable compromise between
flexibility and speed of computation.
Compared to higher-order polynomials
Less calculations and memory
More stable
Compared to lower-order polynomials
More flexible for modeling arbitrary curve
shapes
Cubic Spline Interpolation Methods

Cubic interpolation splines


Given a set of control points
Fitting the input points with a piecewise cubic polynomial curve
Suppose we have n + 1 control points
pk ( xk , yk , zk )
The parametric cubic polynomial is
x (u ) a x u 3 bx u 2 cx u d x
y(u) a yu byu cyu d y
3 2
0 u 1
z(u) azu3 bzu 2 czu d z
Cubic Spline Interpolation Methods

For each of these three equations


We need to determine the values of coefficients a, b, c, and d.
Setting enough boundary conditions at the joints

A piecewise continuous cubic-spline interpolation of n + 1 control points


Natural Cubic Splines
A mathematical representation of the original drafting
spline
Two adjacent curve sections have C2 at their joint.
If there are n + 1 control points to fit
n curve sections
4n polynomial coefficients
Four boundary conditions at each of the n-1 interior control points
Need additional conditions at P0 and Pn.
Disadvantage
No local control
Hermite Interpolation
Hermite (French mathematician Carles Hermite)spline
With a specified tangent at each control point
Can be adjusted locally

Where Dpk and Dp k+1 are the derivatives at pk and p k+1


Hermite Interpolation
Hermite Interpolation
Cardinal Splines
Cardinal splines
Interpolating piecewise cubics with specified endpoint tangents at
the boundary of each section.
The difference from Hermite splines.
Not have to give the endpoint tangents
A section is completely specified with four consecutive
control points.
p(0) pk
p(1) pk 1
1
p' (0) (1 t )( pk 1 pk 1 )
2
1
p' (1) (1 t )( pk 2 pk )
2
Cardinal Splines
Cardinal Splines
In matrix form

pk 1
p
p ( u ) [u 3 u 2 u 1] M C k
pk 1

k 2
p

S 2 S S 2 S
2S S 3 3 2S S Where s = (1-t)/2
MC
S 0 S 0

0 1 0 0
Cardinal Splines
Expanding matrix equation into polynomial form

p(u ) pk 1 ( su 3 2 su 2 su ) pk [( 2 s )u 3 ( s 3)u 2 1]

pk 1[( s 2)u 3 (3 2 s )u 2 su )] pk 2 ( su 3 su 2 )
pk 1CAR0 (u) pk CAR1 (u) pk 1 pk 1CAR2 (u) pk 2 pk 1CAR3 (u)
Bezier Curves
A spline approximation method
Developed by Pierre Bezier
Renault automobile bodies
Given n + 1 control points
n
p(u ) pk BEZ k ,n (u ) 0 u 1
k 0
Bernstein polynomials
BEZ k ,n (u) C(n, k )uk (1 u)nk
BEZ k ,n (u ) (1 u ) BEZ k ,n 1 (u ) uBEZ k 1,n 1 (u )
n k 1
Bezier Curves
The degree of the Bezier polynomial
One less than the number of control points used.
The relative position of control points
With certain placements, we obtain degenerate
Bezier polynomials.
Properties of Bezier Curves

It always passes through the first and last control


points.
p(0) p0 p(1) pn

Values of the parametric first derivatives


p' (0) n( p1 p0 ) p' (1) n( pn pn1 )
The slope at the beginning of the curve is along the line joining
the first two control points.
The slope at the end of the curve is along the line joining the
last two control points
Properties of Bezier Curves
The parametric second derivative
p' ' (0) n(n 1)[( p2 p1 ) ( p1 p0 )]
p' ' (1) n(n 1)[( pn2 pn1 ) ( pn1 pn )]
The Bezier blending functions
They are all positive.
Their sum is always 1:
n

BEZ
k 0
k ,n (u ) 1

The convex-hull property is hold


Properties of Bezier Curves
Design Techniques Using Bezier
Curves
Closed Bezier curves
Specifying the first and last control points at the
same position.
Multiple control points
Specifying multiple control points at a single
coordinate position gives more weight to that
position.
Design Techniques Using Bezier
Curves
Composite Bezier Curves
C1 continuity: Position p1
p'1 pn ( pn pn1 )
C2 continuity: Position p2
p'2 pn2 4( pn pn1 )
Cubic Bezier Curves
Four blending functions for cubic Bezier curves

BEZ 0,3 (u) (1 u)3


BEZ1,3 (u) 3u(1 u)2
BEZ 2,3 (u) 3u2 (1 u)
BEZ 3,3 (u) u3
Blending function BEZ 1,3 is maximum at u = 1/3.
Blending function BEZ 2,3 is maximum at u = 2/3.
Bezier curves do not allow for local control of the curve shape.
Cubic Bezier Curves
Cubic Bezier Curves
Bezier Surfaces
m n
The Bezier P(u, v) p j ,k BEZ j ,m (v )BEZ k ,n (u)
surface j 0 k 0

Its parametric
vector function
is formed as
the Cartesian
product of
Bezier
blending
functions
Bezier Surfaces
A Composite Bezier Surfaces
B-Spline Curves
B-splines have two advantages over Bezier
splines:
The degree is independent of the number of control
points.
Allow local control of the shape.
Blending function formulation
n
P(u ) pk Bk ,d (u ) umin u umax 2 d n 1
k 0

The range of parameter u depends on how we choose


the B-spline parameters.
B k,d are polynomials of degree d - 1.
B-Spline Curves
An example: Uniform, Quadratic B-Splines
d n3 0u6
B-Spline Curves
B-Spline Curves
B-Spline Curves
B-spline blending functions
Cox-deBoor recursion formulas:

Knot vector: The selected set of subinterval endpoints u j.


We can choose any value for the subinterval endpoints
satisfying the relation u j+1 u j
B-Spline Curves
B-Spline Curves
B-Spline Curves
B-Spline Curves
Values for umin and umax depend on:
The number of control points we select.
The value we choose for parameter d.
How we set up the subintervals.
B-Spline Curves
Properties of B-spline curves
Have degree d - 1 and C d-2 continuity over the range
of u.
For n + 1 control points, the curve is described with
n + 1 blending functions.
Each B k,d is defined over d subintervals, starting at
knot value u k.
The range of parameter u is divided into n + d
subintervals by n + d + 1 knot values.
With knot values {uo, u1, ..., u n+d}, the resulting B-
spline curve is defined from u d-1 to u n+1.
Any one control point can affect the shape of at most
d curve sections.
B-Spline Curves
Convex Hull property
The B-spline curve holds the property.
For any parameter value of u in the interval from
knot value u d-1 to u n+1, the sum over all basis
functions is 1.
n

B
k 0
k ,d (u ) 1

For different knot vectors, there are three


classes:
Uniform
Open uniform
Non-uniform
Uniform, Periodic B-Splines
Uniform B-spline
The spacing between knot values is constant.
{-1.5,-1.0,-0.5,0.0,0.5,1.0,1.5,2.0}
Often normalized to the range between 0 and 1.
{0.0,0.2,0.4,0.6,0.8,1.0}
Uniform B-splines have periodic blending functions.
Periodic blending function
For given values of n and d, all blending functions
have the same shape.
Each successive blending function is simply a shifted
version of the previous function:
Bk ,d (u ) Bk 1,d (u u ) Bk 2,d (u 2u )
Uniform, Periodic B-Splines
Uniform, Periodic B-Splines
Uniform, Periodic B-Splines
Example: d = n = 3
Knot vector = {0, 1, 2, 3, 4, 5, 6}
p1 p2 Pstart =1/2(P0+P1)
Pend =1/2(P2+P3)

Pstart = P1 -P0
p0
p3 Pend = P3 -P2

The slope at the start position is parallel to the line


joining the first two control points.
The slope at the end position is parallel to the line
joining the last two control points.
Cubic, Periodic B-Splines
For cubics, d = 4 and each blending function spans four
subintervals. If we are to fit the cubic control
points,then we could use the integer vector
{0,1,2,3,4,5,6,7}
An alternate formulation:
start with the boundary conditions,
normalized interval u[0,1]
1
p(0) ( p0 4 p1 p2 )
6
1
p(1) ( p1 4 p2 p3 )
6
1
p' (0) ( p2 p0 )
2
1
p' (1) ( p3 p1 )
2
Cubic, Periodic B-Splines
A matrix formulation for a cubic periodic B-spline with
four control points
P0 1 3 3 1
P 0

p (u ) u 3 u 2
u 1 MB 1
P2
MB
1 3 6 3
6 3 0 3

0

P3 1 4 1 0
1
B0,3 (u ) (1 u )3
6
1
B1,3 (u ) (3u 3 6u 2 4)
6
1
B2,3 (u ) ( 3u 3 3u 2 3u 1)
6
1 3
B3,3 (u ) u
6
Cubic, Periodic B-Splines
Example:
A closed, periodic, piecewise, cubic B-spline constructed
with cyclic specification of the six control points.
Open, Uniform B-Splines
A class between uniform and nonuniform B-
splines
Knot spacing is uniform except at the ends where
knot values are repeated d times.
Example:
{0, 0, 1, 2, 3, 3}, for d = 2 and n = 3
{0, 0, 0, 0, 1, 2, 2, 2, 2}, for d = 4 and n = 4
For any d and n, the knot vector
Open, Uniform B-Splines
Characteristics are very similar to Bezier
splines
When d = n + 1, open B-splines reduce to Bezier
splines, all knot values are either 0, or 1.
Example: a cubic, open B-splines (d = 4)
Knot vector = {0, 0, 0, 0, 1, 1, 1, 1}
An open B-spline passes through the first and
last control points.
Specifying multiple control points at the same
coordinate position pulls curve closer.
Nonuniform B-Splines
Nonuniform B-splines
We can specify any values and intervals for the knot
vector.
{0, 1, 2, 3, 3, 4}
{0, 2, 2, 3, 3, 6}
{0, 0.2, 0.6, 0.9, 1.0}
Provides increased flexibility in controlling a curve
shape.
Multiple knot values reduce the continuity by 1 for
each repeat of a particular value.
B-Spline Surfaces
The Cartesian product of B-spline
blending functions in the form:
n1 n2
P(u, v ) pk1 ,k2 Bk1 ,d1 (u )Bk2 ,d 2 (v )
k1 0 k2 0

Where pk1 ,k 2 are (n1 + 1) by (n2 + 1) control points


Three-Dimensional Graphics

A 3D point (x,y,z) x,y, and Z coordinates T


We will still use column vectors to represent points
Homogeneous coordinates of a 3D point
(x,y,z,1)
Transformation will be performed using 4x4 matrix
y

x
z
Right hand coordinate system
X x Y = Z ; Y x Z = X; Z x X = Y;
Y
y

x
+z
x

Left hand coordinate system


Not used in this class and
Right hand coordinate system Not in OpenGL
3D transformation
Translation
Very similar to 2D transformation
Translation
x = x + tx; y = y + ty; z = z + tz
X 1 0 0 tx X
Y 0 1 0 ty Y
=
Z 0 0 1 tz Z
1 0 0 0 1 1

homogeneous coordinates
3D transformation
Translation
Very similar to 2D transformation
Translation
x = x + tx; y = y + ty; z = z + tz
X 1 0 0 tx X
Y 0 1 0 ty Y
=
Z 0 0 1 tz Z
1 0 0 0 1 1

homogeneous coordinates
Scaling

X = X * Sx; Y = Y * Sy; Z = Z * Sz

X Sx 0 0 0 X
Y 0 Sy 0 0 Y
=
Z 0 0 Sz 0 Z
1 0 0 0 1 1
3D ROTATION

3D rotation is done around a rotation axis


Fundamental rotations rotate about x, y, or z
axes
Counter-clockwise rotation is referred to as
positive rotation (when you
look down negative axis)
y

+ x
z
Rotation

Rotation about Z similar to 2D rotation


x = x cos() y sin() y
y = x sin() + y cos()
z = z
+ x
cos() -sin() 0 0 z
sin() cos() 0 0
0 0 1 0
0 0 0 1

OpenGL - glRotatef(, 0,0,1)


Rotation y

Rotation about y (z -> y, y -> x, x->z)


x
z = z cos() x sin() +
z
x = z sin() + x cos()
y = y

cos() 0 sin() 0
x
0 1 0 0
-sin() 0 cos() 0
0 0 0 1
+ z

OpenGL - glRotatef(, 0,1,0) y


y

Rotation about x (z -> x, y -> z, x->y)


x
y = y cos() z sin() +
z
z = y sin() + z cos()
x = x

1 0 0 0
z
0 cos() -sin() 0
0 sin() cos() 0
0 0 0 1
+ y
OpenGL - glRotatef(, 1,0,0) x
Computer Animation
Lets talk about computer
animation
Must generate 30 frames per second of
animation (24 fps for film)
Issues to consider:
Is the goal to replace or augment the artist?
What does the artist bring to the project?

Is the scene/plot fixed or responsive to user?


What can we automate?
Design of Animation
Sequences
Steps :
State-board layout
Object definitions
Key-frame Definitions
Generation of in-between frames
General Animation Functions
Object Manipulation and Rendering
Generation of in-betweens
Animation Packages
Object Shapes
Camera movement functions
Raster Animations
Real-time in-limited applications generated
Sequence of raster operations for 2D & 3D
Object Animation in 2D path
Predefine object as successive positions
Set pixels of first position to on values
Change color table values accordingly
Animation Languages
Includes graphics editor,Keyframe generator,in-
between generator & routines.
Graphics Editor
Scene Description
Action specification
Keyframe systems
Parameterized systems
Scripting systems
Computer Animation
Keyframing
Traditional animation technique
Dependent on artist to generate key frames
Additional, inbetween frames are drawn
automatically by computer

Morphing
Motion Specifications
Direct Motion Specification
Goal Directed Systems
Kinematics & Dynamics

Вам также может понравиться