Chapter 6
Chapter 6
3rd Edition
F. S. Hill, Jr. and S. Kelley
Chapter 6.1-3
Modeling Shapes with
Polygonal Meshes
S. M. Lea
University of North Carolina at Greensboro
© 2007, Prentice Hall
3D Modeling
• Polygonal meshes capture the shape of complex
3D objects in simple data structures.
– Platonic solids, the Buckyball, geodesic domes,
prisms.
– Extruded or swept shapes, and surfaces of revolution.
– Solids with smoothly curved surfaces.
• Animated Particle systems: each particle
responds to conditions.
• Physically based systems: the various objects in
a scene are modeled as connected by springs,
gears, electrostatic forces, gravity, or other
mechanisms.
Particle Systems Example
• Particle system showing water droplets in a
fountain. (Courtesy of Philipp Crocoll);
Starfield simulation (Courtesy of Ge Wang)
Polygonal Meshes
• A polygonal mesh is a collection of
polygons (faces) that approximate the
surface of a 3D object.
– Examples: surfaces of sphere, cone, cylinder
made of polygons (Ch. 5); barn (below).
Polygonal Meshes (2)
• Polygons are easy to represent (by a
sequence of vertices) and transform.
• They have simple properties (a single
normal vector, a well-defined inside and
outside, etc.).
• They are easy to draw (using a polygon-fill
routine, or by mapping texture onto the
polygon).
Polygonal Meshes (3)
• Meshes are a standard way of
representing 3D objects in graphics.
• A mesh can approximate the surface to
any degree of accuracy by making the
mesh finer or coarser.
• We can also smooth the polygon edges
using rendering techniques.
Polygonal Meshes (4)
• Meshes can model both solid shapes and
thin skins.
– The object is solid if the polygonal faces fit
together to enclose space.
– In other cases, the faces fit together without
enclosing space, and so they represent an
infinitesimally thin surface.
• In both cases we call the collection of
polygons a polygonal mesh (or simply a
mesh).
Polygonal Meshes (5)
• A polygonal mesh is described by a list of
polygons, along with information about the
direction in which each polygon is facing.
• If the mesh represents a solid, each face has an
inside and an outside relative to the rest of the
mesh.
• In such a case, the directional information is
often simply the outward pointing normal vector
to the plane of the face used in the shading
process.
Polygonal Meshes (6)
• The normal direction to a face determines
its brightness.
Polygonal Meshes (7)
• For some objects, we associate a normal
vector to each vertex of a face rather than
one vector to an entire face.
– We use meshes, which represent objects with
smoothly curved faces such as a sphere or
cylinder. We will refer to the faces of such
objects, but with the idea that there is a
“smooth-underlying surface”.
– When we display such an object, we will want
to de-emphasize the individual faces of the
object in order to make the object look
smooth.
Polygonal Meshes (8)
• Each vertex V1, V2, V3, and V4 defining the side wall of
the barn has the same normal n1, the normal vector to
the side wall.
• But vertices of the front wall, such as V5, will use normal
n2. (Note that vertices V1 and V5 are located at the same
point in space, but use different normals.)
Polygonal Meshes (9)
• For the smoothly curved surface of the cylinder,
both vertex V1 of face F1 and vertex V2 on face
F2 use the same normal n, the vector
perpendicular to the underlying smooth surface.
Defining a Polygonal Mesh
• A mesh consists of 3 lists: the vertices of
the mesh, the outside normal at each
vertex, and the faces of the mesh.
• Example: the basic barn has 7 polygonal
faces and 10 vertices (each shared by 3
faces).
Defining a Polygonal Mesh (2)
• It has a square floor
one unit on a side.
• Because the barn has
flat walls, there are
only 7 distinct normal
vectors involved, the
normal to each face
as shown.
Defining a Polygonal Mesh (3)
• The vertex list reports the locations of the
distinct vertices in the mesh.
• The list of normals reports the directions of
the distinct normal vectors that occur in
the model.
• The face list indexes into the vertex and
normal lists.
Vertex List for the Barn
vertex x y z
0 0 0 0
1 1 0 0
2 1 1 0
3 0.5 1.5 0
4 0 1 0
5 0 0 1
6 1 0 1
7 1 1 1
8 0.5 1.5 10
9 0 1 1
Normal List for the Barn
• The normal normal nx ny nz
list (as unit 0 -1 0 0
vectors, to
the 7 basic 1 -0.707 0.707 0
planes or 2 0.707 0.707 0
polygons). 3 1 0 0
4 0 -1 0
5 0 0 1
6 0 0 -1
Face List for the Barn
Face Vertices Normal
0 (left) 0, 5, 9, 4 0,0,0,0
1 (roof left) 3, 4, 9, 8 1,1,1,1
2 (roof right) 2, 3, 8, 7 2, 2, 2,2
3 (right) 1, 2, 7, 6 3, 3, 3, 3
4 (bottom) 0, 1, 6, 5 4, 4, 4, 4
5 (front) 5, 6, 7, 8, 9 5, 5, 5, 5, 5
6 (back) 0, 4, 3, 2, 1 6, 6, 6, 6, 6
Defining a Polygonal Mesh (4)
• Only the indices of the vertices and normals are
used.
• The list of vertices for a face begins with any
vertex in the face, and then proceeds around the
face vertex by vertex until a complete circuit has
been made.
– There are two ways to traverse a polygon: clockwise
and counterclockwise. For instance, face #5 above
could be listed as (5, 6, 7, 8, 9) or (9, 8, 7, 6, 5).
– Convention: Traverse the polygon
counterclockwise as seen from outside the object.
Defining a Polygonal Mesh (5)
• Using this order, if you traverse around the
face by walking from vertex to vertex, the
inside of the face is on your left.
• Using the convention allows algorithms to
distinguish with ease the front from the
back of a face.
• If we use an underlying smooth surface,
such as a cylinder, normals are computed
for that surface.
3D File Formats
• There is no standard file format.
• Some formats have been found to be efficient and easy
to use: for example, the .qs file format developed by the
Stanford University Computer Graphics Laboratory. This
particular mesh model has 2,748,318 points (about
5,500,000 triangles) and is based on 566,098 vertices.
3D File Formats (2)
• OpenGL has the capability to load a
variety of 3D model formats such as (but
not limited to) 3DS, VRML, PLY, MS3D,
ASE and OBJ.
• A number of resources are available on
the book’s companion web site that cover
loading 3D mesh models into OpenGL.
Calculating Normals
• Take any three non-collinear points on the face,
V1, V2, and V3, and compute the normal as their
cross product m = (V1 - V2) × (V3 - V2) and
normalize it to unit length.
– If the two vectors V1 - V2 and V3 - V2 are nearly
parallel, the cross product will be very small and
numerical inaccuracies may result.
– The polygon may not be perfectly planar. Thus the
surface represented by the vertices cannot be truly
flat. We need to form some average value for the
normal to the polygon, one that takes into
consideration all of the vertices.
Newell's Method for Normals
• Given N vertices, define next(i) = ni = (i+1)
mod N.
• Traverse the vertices for the face in
counter-clockwise order from the outside.
• The normal given by the values on the
next slide points to the outside (front) of
the face.
Normal (Newell’s Method)
N 1
n x y i y ni z i z ni
i 0
N 1
n y z i z ni xi x ni
i 0
N 1
n z xi x ni y i y ni
i 0
Properties of Meshes
• A closed mesh represents a solid object (which
encloses a volume).
• A mesh is connected if there is an unbroken
path along the edges of the mesh between any
two vertices.
• A mesh is simple if it has no holes. Example: a
sphere is simple; a torus is not.
• A mesh is planar if every face is a plane
polygon. Triangular meshes are frequently used
to enforce planarity.
Properties of Meshes (2)
• A mesh is convex if the line connecting any two
interior points is entirely inside the mesh.
• Exterior connecting lines are shown for non-
convex objects below (step and torus).
Meshes for Drawing Non-physical
Objects
• The figure labeled
IMPOSSIBLE looks DONUT
P
Platonic Solids
• All the faces are identical and each is a
regular polygon.
Duals
• Every Platonic solid P
has a dual Platonic solid
D. The vertices vi of D
are the centers of faces
of P, calculated as
1 n 1
c vi
n i 0
• The duals are
tetrahedron-tetrahedron,
hexahedron-octahedron,
dodecahedron-
icosahedron.
Flattened Models
• To keep track of
vertex and face
numbering, we
use a flat model,
which is made by
cutting along
certain edges of
each solid and
unfolding it to lie
flat.
Normal Vectors for the Platonic
Solids
• Normals can be found
using Newell’s method.
• Also, because of the high
degree of symmetry of a
Platonic solid, if the solid
is centered at the
origin, the normal vector
to each face is the vector
from the origin to the
center of the face (the
average of the vertices of
the face).
Vertex and Face lists for a
Tetrahedron
• For the unit cube having vertices (±1,±1,±1), and
the tetrahedron with one vertex at (1,1,1), the
tetrahedron has vertex and face lists given
below.
14 10 19
7 9
15 9
8
11 7 0 1 9
11
18 4 7 10 16
13 3 0 6 17
4 5 6 2 8 4
1
2 5
5 8
12 3 11
4 4
Prism Model for Icosahedron
Flattened Model for Dodecahedron
2 1 2 2 12
12 1 3
12 1 6 5
3 0 13
11 5 0 4 18 13
13
4 2 7
8 0 11
16 7 16
17 6
15 14
16 1 7 8 10 19
9 8 19
10
19 9 9 8 9
Archimedean Solids
• Have more than one type of polygon as faces;
semi-regular.
• Examples: truncated cube (octagon and triangle)
Truncated Cube
• Each edge of the cube is divided into three
1
parts; the middle part of length A
and the middle portion of each 1 2
edge is joined to its neighbors.
• Thus if an edge of the cube has endpoints
C and D, two new vertices, V and W, are
formed as the affine combinations
1 A 1 A W
1 A
C
1 A
V C D D
2 2 2 2
Number of Archimedean Solids
• Given the constraints that faces must be
regular polygons, and that they must occur
in the same arrangement about each
vertex, there are only 13 possible
Archimedean solids.
• Archimedean solids have sufficient
symmetry that the normal vector to each
face is found using the center of the face.
Truncated Icosahedron
• The truncated icosahedron (soccer ball) consists
of regular hexagons and pentagons.
• More recently this shape has been named the
Buckyball after Buckminster Fuller, because of
his interest in geodesic structures similar to this.
• Crystallographers have discovered that 60
atoms of carbon can be arranged at the vertices
of the truncated icosahedron, producing a new
kind of carbon molecule that is neither graphite
nor diamond.
• The material has been named Fullerene.
The Buckyball and Flattened
Version (Partial)
Computer Graphics using OpenGL,
3rd Edition
F. S. Hill, Jr. and S. Kelley
Chapter 6.4-5
Modeling Shapes with
Polygonal Meshes
S. M. Lea
University of North Carolina at Greensboro
© 2007, Prentice Hall
Extruded Shapes
• A large class of shapes can be generated
by extruding or sweeping a 2D shape
through space.
• In addition, surfaces of revolution can also
be approximated by extrusion of a polygon
once we slightly broaden the definition of
extrusion.
Extruded Shapes
• Prism:
formed by
sweeping
the arrow
along a
straight
line.
• Flattened
version.
Extruded Shapes (2)
• Base has vertices (xi, yi, 0) and top has vertices
(xi, yi, H).
• Each vertex (xi, yi, H) on the top is connected to
corresponding vertex (xi, yi, 0) on the base.
• If the polygon has n sides, then there are n
vertical sides of the prism plus a top side (cap)
and a bottom side (base), or n+2 faces
altogether.
• The normals for the prism are the face normals.
These may be obtained using the Newell
method, and the normal list for the prism
constructed.
Vertex List for the Prism
• Suppose the prism's base is a polygon
with N vertices (xi, yi). We number the
vertices of the base 0, . . . , N-1 and those
of the cap N, . . ., 2N -1, so that an edge
joins vertices i and i + N.
• The vertex list is then easily constructed to
contain the points (xi, yi, 0) and (xi, yi, H),
for i = 0, 1, ..., N-1.
Face List for the Prism
• We first make the side faces and then add
the cap and base.
• For the j-th wall (j = 0,...,N-1) we create a
face with the four vertices having indices j,
j + N, next(j)+ N, and next(j) where next(j)
is j+1 % N.
• Code: if (j < n-1) next = ++j; else next = 0;
• Or j = (++j) % N;
Arrays of Extruded Prisms
• OpenGL can reliably draw only convex
polygons. For non-convex prisms, stack
the parts.
Drawing Arrays of Extruded Prisms
• We need to build a mesh out of an array of prisms:
void Mesh:: makePrismArray(...)
• Its arguments are a list of (convex) base polygons
(in the xy-plane), and perhaps a vector d that
describes the direction and amount of extrusion.
• The vertex list contains the vertices of the cap and
base polygons for each prism, and the individual
walls, base, and cap of each prism are stored in the
face list.
• Drawing such a mesh involves some wasted effort,
since walls that abut would be drawn (twice), even
though they are ultimately invisible.
Special Case: Extruded Quadstrips
• Quadstrip (an OpenGL primitive) can be
created and then extruded as for prism.
Quadstrip Data Structure
• quad-strip = {p0, p1, p2, ...., pM-1}
• The vertices are understood to be taken in
pairs, with the odd ones forming one edge
of the quad-strip, and the even ones
forming the other edge.
• Not every polygon can be represented as
a quad-strip.
Drawing Extruded Quadstrips
• When a mesh is formed as an extruded quad-
strip, only 2M vertices are placed in the vertex
list, and only the outside (2M-2) walls are
included in the face list. Thus no redundant walls
are drawn when the mesh is rendered.
• A method for creating a mesh for an extruded
quad-strip would take an array of 2D points and
an extrusion vector as its parameters:
void Mesh:: makeExtrudedQuadStrip(Point2 p[ ],
int numPts, Vector3 d);
Example: Arch
Special Case: Twisted Extrusions
• Base is n-gon, top is scaled, translated,
and possibly rotated version of base.
• Specifically, if the base polygon is P, with
vertices {p0, p1, ..., pN-1}, the cap polygon
has vertices P’ = { Mp0, Mp1, ..., MpN-1}
where M is some 4 by 4 affine
transformation matrix.
Examples
• A), B): cap is
smaller version
of base.
• C): cap is
rotated
through θ
about z-axis
before
translation.
• D): cap P’ is
rotated
arbitrarily
before
translation.
Segmented Extrusions
• Below: a square P extruded three times, in different
directions with different tapers and twists. The first
segment has end polygons M0P and M1P, where the
initial matrix M0 positions and orients the starting end of
the tube. The second segment has end polygons M1P
and M2P, etc.
Special Case: Segmented
Extrusions
• We shall call the various transformed
squares the “waists” of the tube.
• In this example the vertex list of the mesh
contains the 16 vertices M0p0, M0 p1, M0
p2, M0 p3, M1p0, M1p1, M1p2, M1p3, ...,
M3p0, M3p1, M3p2, M3p3.
• The “snake” used the matrices Mi to grow
and shrink the tube to represent the body
and head of a snake.
Methods for Twisted Extrusions
• Multiple extrusions used, each with its own
transformation. The extrusions are joined
together end to end.
• The extrusion tube is wrapped around a
space curve C, the spine of the extrusion
(e.g., helix C(t) = (cos(t), sin(t), bt)).
Method for Twisted Extrusions (2)
• We get the curve values at various points
ti and then build a polygon perpendicular
to the curve at C(ti) using a Frenet frame.
Method for Twisted Extrusions (3)
• We create the Frenet frame at each point
along the curve: at each value ti a
normalized vector T(ti) tangent to the curve
is computed. It is given by C’(ti), the
derivative of C(ti).
• Then two normalized vectors, N(ti) and
B(ti), which are perpendicular to T(ti) and
to each other, are computed. These three
vectors constitute the Frenet frame at ti.
Method for Twisted Extrusions (5)
• Once the Frenet Frame is computed, the
transformation matrix M that transforms the
base polygon of the tube to its position and
orientation in this frame is the transformation
that carries the world coordinate system i, j,
and k into this new coordinate system N(ti),
B(ti), T(ti), and the origin of the world into the
spine point C(ti).
• Thus the matrix has columns consisting directly
of N(ti), B(ti), T(ti), and C(ti) expressed in
homogeneous coordinates:
M = (N(ti)| B(ti)| T(ti)| C(ti))
Method for Twisted Extrusions (4)
• Example: C(t) = (cos (t), sin(t), bt) (a helix)
• The tangent vector to the curve: T = derivative of
C(t); specifically, T = (1 + b2)-1 (-sin(t), cos(t), b)
• The acceleration vector is the derivative of the
tangent vector, and thus the second derivative of
the curve C: A = (-cos(t), -sin(t), 0). A is
perpendicular to T, because A·T = 0. We let B =
TxA/|TxA|. B is called the binormal vector to the
curve.
• A final vector N = BxT forms a reference frame,
the Frenet frame, at point ti on the curve. N is
perpendicular to both B and T.
Method for Twisted Extrusions (5)
• If the curve is awkward numerically, the
derivatives for the reference frame vectors
may be approximated over a small
distance ε by T(ti) = (C(t+ε) - C(t-ε))/(2 ε),
B(ti) = (C(t+ε) - 2C(t) + C(t-ε))/ε2.
Examples
a). Tangents to the helix. b). Frenet frame
at various values of t, for the helix.
Examples
• Helix, C(t) = (cos t, sin
t, bt). A decagon (10
sides) is wrapped
around the helix.
Examples (2)
• Toroidal spiral, C(t) = (a + b cos(qt)
cos(pt), (a + b cos(qt)) sin(pt), c sin(qt)).
• A) p = 2, q = 5; B) p = 1, q = 7.
Examples (3)
• Helix with t-dependent scaling: Matrix Mi is
multiplied by a matrix which provides t-
dependent scaling (g(t) = t) along the local
x and y.
g (t ) 0 0 0
0 g (t ) 0 0
M M
0 0 1 0
0 0 1
0
Application of Frenet Frames
• Another application for Frenet frames is
analyzing the motion of a car moving along a
roller coaster.
• If we assume a motor within the car is able to
control its speed at any instant, then knowing the
shape of the car’s path is enough to specify C(t).
• Now if suitable derivatives of C(t) can be taken,
the normal and binormal vectors for the car’s
motion can be found and a Frenet frame for the
car can be constructed for each relevant value of
t.
Application of Frenet Frames (2)
• This allows us to find the forces operating
on the wheels of each car and the
passengers.
Special Case: Discretely Swept
Surfaces of Revolution
• Example: polygon positioned away from y
axis and then rotated around y axis along
some curve ((a) circle, (b) Lissajous
figure).
Discretely Swept Surfaces of
Revolution (2)
• Example: rotating a polyline around an
axis to produce a 3D figure.
Discretely Swept Surfaces of
Revolution (3)
• This is equivalent to circularly sweeping
a shape about an axis.
• The resulting shape is often called a
surface of revolution. Below: 3 versions
of a pawn based on a mesh that is swept
in discrete steps.
Discretely Swept Surfaces of
Revolution (3)
• Glass: polyline with Pj
= (xj, yj, 0).
• To rotate the polyline
to K equispaced
angles about the y-
axis: θi = 2πi/K, i = 0,
1, 2, …, K, and
cos(i ) 0 sin(i ) 0
~ 0 1 0 0
M
sin(i ) 0 cos(i ) 0
1
0 0 0
Mesh Approximations to Smooth
Objects
• Given a smooth surface, tesselate it:
approximate it by triangles or
quadrilaterals with vertices on the smooth
surface, connected by straight lines not on
the surface.
• If the mesh is fine enough (the number of
faces is large enough), shading can make
the surface look smooth.
Mesh Approximations to Smooth
Objects (2)
• The faces have vertices that are found by
evaluating the surface’s parametric
representation at discrete points.
• A mesh is created by building a vertex list
and face list in the usual way, except now
the vertices are computed from formulas.
• The vertex normal vectors are computed
by evaluating formulas for the normal to
the smooth surface at discrete points.
Mesh Approximations to Smooth
Objects (3)
• In Ch. 4.5, we used the planar patch given
parametrically by P (u, v) = C + au + bv, where
C is a point, a and b are vectors, and u and v
are in [0, 1].
– This patch is a parallelogram in 3D with corner
vertices C, C + a, C + b, and C + a + b.
• More general surface shapes require three
functions X(), Y(), and Z() so that the surface
has parametric representation in point form P(u,
v) = (X(u, v), Y(u, v), Z(u, v)) with u and v
restricted to suitable intervals.
Mesh Approximations to Smooth
Objects (4)
• Different surfaces are characterized by
different functions: X, Y, and Z.
– The notion is that the surface is at (X(0, 0),
Y(0, 0), Z(0, 0)) when both u and v are zero,
at (X(1, 0), Y(1, 0), Z(1, 0)) when u = 1 and v
= 0, and so on.
• Letting u vary while keeping v constant
generates a curve called a v-contour.
Similarly, letting v vary while holding u
constant produces a u-contour.
Mesh Approximations to Smooth
Objects (2)
• Method: describe surface as P(u, v) = (X(u, v),
Y(u, v), Z(u, v)) (parametric form) and use the
implicit form for the equation of the surface: F(x,
y, z) = 0.
• Given a point Q, Q is inside the object if F(Q) <
0, on it if F(Q) = 0, and outside it if F(Q) > 0.
• Example: the plane that passes through point B
and has normal vector n is described by the
equation nx x + ny y + nz z = D (where D = n•B),
so the implicit form for this plane is F(x, y, z) = nx
x + ny y + nz z - D.
Mesh Approximations to Smooth
Objects (3)
• Sometimes it is more convenient to think of F as
a function of a point P, rather than a function of
three variables x, y, and z, and we write F(P) = 0
to describe all points that lie on the surface.
• For the plane, we define F(P) = n·(P - B) and
say that P lies in the plane if and only if F(P) =
n·(P-B) is zero.
• If we wish to work with coordinate frames with P
= (x, y, z, 1)T, the implicit form for a plane is even
simpler: F(P) = n·P, where n = (nx, ny, nz –D)T.
Mesh Approximations to Smooth
Objects (4)
• The normal to a surface at a point P(u0, v0) on the
surface is found by considering a very small region of the
surface around P(u0, v0).
• If the region is small enough and the surface varies
smoothly, the region will be essentially flat and will have
a well-defined normal direction.
Mesh Approximations to Smooth
Objects (5)
• The normal vector in parametric or gradient form is
n (u0,v0) = P P
u v u 0,v 0
n (x0, y0, z0) = F F F F
x , y , z
x 0, y 0, z 0
• (Normalize n.)
• The result of applying an affine transformation M to
the surface P(u,v) or F(x, y, z) is P(u, v) → MP(u, v),
F(P) → F(M-1P) and n(u,v) → M-1(n(u,v)).
Computer Graphics using OpenGL,
3rd Edition
F. S. Hill, Jr. and S. Kelley
Chapter 6.5-6
Modeling Shapes with
Polygonal Meshes
S. M. Lea
University of North Carolina at Greensboro
© 2007, Prentice Hall
Generic Sphere
• Center (0, 0, 0), radius 1;
• F(x, y, z) = x2 + y2 + z2 -1 = 0, or F(P)=|P|2-1.
• P(u, v) = (cos v cos u, cos v sin u, sin v), with 0
≤v ≤ 2π, -π/2 ≤ u ≤ π/2
Sphere (2)
• u-contours are longitude lines (meridians), v-
contours are latitude lines (parallels).
• The normal vector (gradient) 2(x, y, z) is radially
outward.
• The parametric form is n(u, v) = -cos(v)p(u, v),
also radially outward. The scale factor -cos(v)
will disappear when we normalize n.
• We must use p(u,v) rather than -p(u,v) for the
normal, so that it does indeed point radially
outward.
Generic Tapered Cylinder
• Axis coincides with z-axis; circular cross section of
radius 1 at base, s when z = 1; extends in z from 0 to 1.
• The tapered cylinder with an arbitrary value of s provides
formulas for the generic cylinder and cone by setting s to
1 or 0, respectively.
Generic Tapered Cylinder (2)
• The wall of the tapered cylinder is given by the
implicit form F( x, y, z) x 2 y 2 (1 (s 1)z)2
for 0 < z < 1, and by the parametric form
P(u, v ) ((1 ( s 1)v ) cos(u ), (1 ( s 1)v ) sin(u ), v )
• When the tapered cylinder is a solid object, we
add two circular discs at its ends: a base and a
cap. The cap is a circular portion of the plane z
= 1, characterized by the inequality x2 + y2 < s2,
or given parametrically by P(u, v) = (v cos(u), v
sin(u), 1) for v in [0, s].
Generic Tapered Cylinder (3)
• The normal vector to the wall of the tapered
cylinder is n(x, y, z) = (x, y, -(s - 1)(1+ (s - 1)z)),
or in parametric form n(u, v) = (cos(u), sin(u), 1
– s).
• For the generic cylinder the normal is simply
(cos(u), sin(u), 0).
• The normal is directed radially away from the
axis of the cylinder. For the tapered cylinder it is
also directed radially, but shifted by a constant z-
component.
Generic Cone
• A cone whose axis coincides with the z-
axis, has a circular cross section of
maximum radius 1, and extends in z from
0 to 1. It is a tapered cylinder with small
radius of s = 0.
Generic Cone (2)
• Wall: F(x, y, z) = x2 + y2 - (1 - z)2 = 0 for 0
< z < 1; parametric form P(u, v) = ((1-v)
cos(u), (1- v) sin(u), v) for azimuth u in [0,
2π] and v in [0, 1].
• Using the results for the tapered cylinder
again, the normal vector to the wall of the
cone is (x, y, 1-z).
• Fig. 6.54 shows normal vectors for all
generic surfaces.
Mesh for the Generic Sphere
• We slice the sphere along azimuth lines and
latitude lines.
• We slice the sphere into nSlices slices around
the equator and nStacks stacks from the South
Pole to the North Pole.
• The figure (next slide) shows the example of 10
slices and 8 stacks.
• The larger nSlices and nStacks are, the better
the mesh approximates a true sphere.
Mesh for the Generic Sphere (2)
Mesh for the Generic Sphere (3)
• To make slices we need nSlices values of u
around the equator between 0 and 2π. Usually
these are chosen to be equispaced: ui =
2πi/nSlices, i = 0, 1, ..., nSlices -1.
• We put half of the stacks above the equator and
half below. The top and bottom stacks will
consist of triangles; all other faces will be
quadrilaterals.
• This requires we define (nStacks + 1) values of
latitude: vj = π - π j/nStacks, j = 0, 1, ..., nStacks.
Mesh for the Generic Sphere (4)
• The vertex list: put the north pole in pt[0],
the bottom points of the top stack into the
next 12 vertices, etc. There will be 98
points.
• The normal vector list: norm[k] is the
normal for the sphere at vertex pt[k] in
parametric form; n(u,v) is evaluated at
(u,v) used for the points.
– For the sphere this is particularly easy
since norm[k] is the same as pt[k].
Mesh for the Generic Sphere (5)
• The face list: Put the top triangles in the
first 12 faces, the 12 quadrilaterals of the
next stack down in the next 12 faces, etc.
• The first few entries in the face list will
contain the data
number of vertices: 3 3 3 ...
vertex indices: 0 1 2 023 0 3 4 ...
normal indices: 0 1 2 023 0 3 4 ...
General Meshes
• Ultimately we need a method, such as
makeSurfaceMesh(), that generates appropriate
meshes for a given surface P(u, v).
• Some graphics packages have routines that are
highly optimized for triangles, making triangular
meshes preferable to quadrilateral ones.
• We can use the same vertices, but alter the face list
by replacing each quadrilateral with two triangles.
– For instance, a face that uses vertices 2, 3, 15, 14
might be subdivided into two triangles, one using 2, 3,
15 and the other using 2, 15, 14.
Mesh for the Tapered Cylinder
• We use nSlices = 10 and
nStacks = 1.
• A decagon is used for the
cap and base.
• If you prefer to use only
triangles, the walls, the
cap, and the base could
be dissected into triangles.
Ruled Surfaces