REPRESENTATIONS
CEng477
IntroductiontoComputerGraphics
Object Representations
Types of objects:
geometrical shapes, trees, terrains, clouds, rocks, glass,
hair, furniture, human body, etc.
Not possible to have a single representation for all
Polygon surfaces
Spline surfaces
Procedural methods
Physical models
Fractals
Two categories
Boundary representations
Space-partitioning representations
The inside of the object is divided into nonoverlapping regions and the object is
represented as a collection of these interior
components. E.g., octree representation
Levels of detail
Interpolated shading
Data Structures
Efficiency
Intersection calculations
Normal calculations
Flexibility
Interactive systems
Integrity
Polygon Tables
Vertices Edges
V1:(x1,y1,z1)
V2:(x2,y2,z2)
V3:(x3,y3,z3)
V4:(x4,y4,z4)
V5:(x5,y5,z5)
V6:(x6,y6,z6)
V7:(x7,y7,z7)
V8:(x8,y8,z8)
E1: V1,V2
E2: V2,V3
E3: V2,V5
E4: V4,V5
E5: V3,V4
E6: V4,V7
E7: V7,V8
E8: V6,V8
E9: V1,V6
E10: V5,V6
E11: V5,V7
Forward pointers:
i.e. to access
adjacent surfaces
edges
V2
Polygons
S1:
S2:
S3:
S4:
E1,E3,E10,E9
E2,E5,E4,E3
E10,E11,E7,E8
E4,E6,E11
E2
E1
V3
E3
V1
V5
E9
E10
E5
E4
V4
E6
E11
V7
V6
E7
E8
V8
V1:
V2:
V3:
V4:
V5:
V6:
V7:
V:
E1,E9
E1,E2,E3
E2,E5
E4,E5,E6
E3,E4E10,E11
E8,E9,E10
E6,E7,E11
E ,E
E1:
E2:
E3:
E4:
E5:
E7:
E9:
S1
S2
S1,S2
S2,S4
S2 E6: S4
S3 E8: S3
S1 E10: S1,S3
Slope of edges
Normals
Integrity checks
V,
E a , E b such that V
E,
S such that E S
E a ,V
Eb
S , S is closed
S 1,
S 2 such that S 1 S 2
S k is listed in E m
E m is listed in S k
Polygon Meshes
Triangle strips:
10
12
1 2 3 4 5 6 7 8 9 10 11 12
Quadrilateral meshes:
nm array of vertices
11
Plane Equations
1,
k 1, 2, 3
z 1 y 3 z1 z 2
x1 z 3 x1 x2
y1 x3 y1 y 2
x 2 y 3 z1 y 1 z 3 x 3 y 1 z 2 y 2 z 1
Surface Normal:
N A,B ,C
extracting normal from vertices:
N V2 V1
V3 V1
V2
Counterclockwise
order.
V1
V3
Tetrahedron
glutWireTetrahedron ( );
glutSolidTetrahedron ( );
Cube
glutWireCube (edgeLength);
glutSolidCube (edgeLength);
Creates a cube centered at the worldcoordinate origin with the given edge length.
Octahedron
glutWireOctahedron ( );
glutSolidOctahedron ( );
Dodecahedron
glutWireDodecahedron ( );
glutSolidDodecahedron ( );
Icosahedron
glutWireIcosahedron ( );
glutSolidIcosahedron ( );
Curved Surfaces
Quadric surfaces
Superquadrics
Spline Surfaces
Quadric Surfaces
Spheres
Ellipsoids
Tori
Paraboloids
Hyperboloids
Sphere
Non-parametric equation
x2 y2 z 2 r 2
x r cos cos ,
/ 2 / 2
y r cos sin ,
z r sin
Ellipsoid
Non-parametric equation
2
y
x
z
r
r
r
z
x
y
x rx cos cos ,
y ry cos sin ,
z rz sin
/ 2 / 2
Superquadrics
Superellipse
x
rx
rx ry
2/ n
r
y
2/ n
x rx cos ,
n
y ry sin
n
Superellipse
Superellipsoid
x
r
x
2 / s2
r
y
s 2 / s1
2 / s2
z
rz
2 / s1
x rx cos cos ,
/ 2 / 2
y ry cos sin ,
s1
s1
z rz sin
s1
s2
s2
Superellipsoid
GLU functions
Examples
GLU cylinder
GLUT cone
GLUT sphere
GLUT functions
glutWireTeapot(size);
glutSolidTeapot(size);
Example:
GLUquadricObj *mySphere;
mySphere = gluNewQuadric();
gluQuadricStyle (mySphere, GLU_LINE);
gluSphere (mySphere, r, nLong, nLat);
Quadric styles
GLU_POINT
GLU_SILHOUETTE
GLU_FILL
gluDeleteQuadric (name);
Spline Representations
Interpolated
Approximated
Parametric equations:
x x(u ),
y y (u ),
z z (u ),
u1 u u2
Geometric continuity:
Similar to parametric continuity but only the direction of
derivatives are significant. For example derivative (1,2)
and (3,6) are considered equal.
G0, G1, G2 : zero order, first order, and second order
geometric continuity.
Spline Equations
0 u 1
z (u ) a z u 3 bz u 2 c z u d z
x(u ) u 3
u2
ax
b
x
u 1
cx
U C
dx
General form:
x(u ) U M s M g
Mg:
x1 (0) p 0 , xn (1) p n
x1(0) 0, xn (1) 0
Hermite Interpolation
End point constraints for each segment is given as:
P(0) p k ,
P(0) Dp k ,
P(1) p k 1 ,
P(1) Dp k 1 ,
P (u ) u 3
u2
u 1
a
b
c
P(u ) 3u 2
2u 1 0
pk 0
p k 1 1
Dp k 0
Dp k 1 3
0
1
0
2
0
1
1
1
1
1
0
a
b
c
d
c
d
a
b
a 0
b 1
c 0
d 3
0
1
0
2
0
1
1
1
1
1
0
pk
p k 1
Dp k
Dp k 1
Hermite curves
a 0
b 1
c 0
d 3
0
1
0
2
0
1
1
1
1
1
0
pk 2 2 1
1 pk
p k 1 3 3 2 1 p k 1
MH
Dp k 0
0
1
0 Dp k
Dp k 1 1
0
0
0 Dp k 1
pk
p k 1
Dp k
Dp k 1
P (u ) p k (2u 3 3u 2 1) p k 1 (2u 3 3u 2 ) Dp k (u 3 2u 2 u ) Dp k 1 (u 3 u 2 )
Hermite curves
Bzier Curves
P (u ) p k BEZk ,n (u ),
0 u 1
k 0
n k
BEZk ,n (u ) u (1 u ) n k ,
k
n
n!
k k!(n k )!
BEZ0,3 (1 u ) 3
BEZ1,3 3u (1 u ) 2
BEZ2,3 3u 2 (1 u )
BEZ3,3 u 3
p0
p
P (u ) u 3 u 2 u 1 M Bez 1
p2
1 3 3 1
p3
3 6 3 0
M Bez
3 3
0 0
0
0 0
1
p0
multiplied with
p2
multiplied with
p1
multiplied with
p3
The four Bzier blending functions for cubic curves (n=3, i.e. 4 control
P (0) p 0 ,
P (1) p n
P(0) np 0 np1
P(1) np n 1 np n
p 0 p n
n
p1 p n (p n p n 1 )
n
n and n are the number of
Bzier Surfaces
0 u, v 1
Bzier Patches
Matrix form
u2
1 3 3
3 6 3
u 1
3 3
0
0
0
1
1
0
0
p 0, 0
p
1, 0
p 2,0
p 3, 0
p 0,1 p 0, 2
p1,1 p1, 2
p 2,1 p 2, 2
p 3,1 p 3, 2
p 0,3
p1,3
p 2,3
p 3, 3
1 3 3
3 6 3
3 3
0
0
0
1
Joining patches:
similar to curves. C0, C1 can be established by choosing
control points accordingly.
1
0
0
v3
2
v
v
1
x(u ) a x u 3 bx u 2 c x u d x
x(u ) ((a x u bx )u c x )u d x
Forward-difference calculations:
Incremental calculation of the next value.
uk 1 uk ,
xk a x uk bx
xk 1 xk x
k 0,1,2,...
u0 0
xk 1 a x (uk ) bx
x a x
constant
Cubic equations
xk a x u k3 bx uk2 c x u k d x
xk 3a xu k2 (3a x 2 2bx )u k (a x 3 bx 2 c x )
xk 1 xk 2 xk
2 xk 6a x 2uk 6a x 3 2bx 2
2 xk 1 2 xk 3 xk
3 x k 6 a x
x0 d x
x0 a x 3 bx 2 c x
2 x0 6a x 3 2bx 2
Once we compute these initial values, the calculation for next x-coordinate
position takes only three additions.
Example
x0 d x
x0 a x bx c x
3
2 x0 6a x 3 2bx 2
3 x k 6 a x 3
Example:
(ax,bx,cx,dx)=(1,2,3,4), = 0.1
3 xk 6 1 3 0.006
x
4.000
4.321
4.688
5.107
5.584
6.125
6.736
7.423
8.192
9.049
x
0.321
0.367
0.419
0.477
0.541
0.611
0.687
0.769
0.857
0.951
2
2
x
0.046
0.052
0.058
0.064
0.070
0.076
0.082
0.088
0.094
0.100
glEnable (GL_MAP1_VERTEX_3)
glDisable (GL_MAP1_VERTEX_3)
glEvalCoord1* (uValue)
Example
GLfloat ctrlPts [4] [3] = {{0.0,1.0,2.0},};
glMap1f (GL_MAP1_VERTEX_3,0.0,1.0,3,4,&ctrlPts[0][0]);
glEnable (GL_MAP1_VERTEX_3);
Glint k;
glBegin (GL_LINE_STRIP);
for (k=0;k<=50;k++)
glEvalCoord1f(GLfloat (k) / 50.0);
glEnd ();
glEnable (GL_MAP2_VERTEX_3)
glDisable (GL_MAP2_VERTEX_3)
Example
GLfloat ctrlPts [4] [4] [3] = {{{0.0,1.0,2.0},
};
glMap2f
(GL_MAP2_VERTEX_3,0.0,1.0,3,4,0.0,1.0,12,
4,&ctrlPts[0][0][0]);
glEnable (GL_MAP2_VERTEX_3);
glMapGrid2f (40,0.0,1.0,40,0.0,1.0);
glEvalMesh2 (GL_LINE,0,40,0,40);
// GL_POINT and GL_FILL is also available with
glEvalMesh2()
Sweep Representations
Use reflections, translations and rotations to
construct new shapes.
v
P(u)
u
Translational
Sweep
u
Rotational
Sweep
Translational Sweep
Rotational Sweep
Hierarchical Models
Scene Graphs
T
T
L
T
G
T
G
T
A B
A B
A B
B A
union(transA(box),diff(transB(box),transC(cylinder)))
+
-
T
T
A CSG Tree
Implementing CSG
Ray Casting
Ray Casting
Implementation Details
B
P
C
Q
V Vij
i, j
Octrees
5
0
1
2
Classification:
Fractal Dimension
Fractal dimension:
Fractal Dimension
The relationship between the number
of subparts and the scaling factor is
ns
DE
ns 1
D
Koch curve
Initiator:
Generator:
n 4
n : number of pieces
s 1 3
ln 4
ln 1 1 3
s: scaling factor
1.2619
Exercise
Initiator
Generator
Exercise
Initiator
Generator
Random Variation
Using a probability
distribution function we
can introduce small
variations during the
subdivision of the object
for more realism.
Z AB ( Z A Z B ) / 2 r ,
Z BC ( Z B Z C ) / 2 r ,
Z DA ( Z D Z A ) / 2 r ,
Z CD ( Z C Z D ) / 2 r ,
Z M ( Z AB Z BC Z CD Z DA ) / 4 r ,
B
M