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

CS3500 Computer Graphics Module On Representation of Primitives

This document discusses different representations of primitives in computer graphics. It begins by explaining that points, lines, polygons and solids are the basic objects that graphics can draw. It then covers various ways of representing points, curves, surfaces and 3D objects like polygons. This includes explicit representations using equations, as well as parametric and piecewise representations using vertices, edges, and other geometric elements. The key considerations in choosing a representation are rendering speed and efficiency as well as ease of processing and manipulation.

Uploaded by

api-3799599
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
119 views

CS3500 Computer Graphics Module On Representation of Primitives

This document discusses different representations of primitives in computer graphics. It begins by explaining that points, lines, polygons and solids are the basic objects that graphics can draw. It then covers various ways of representing points, curves, surfaces and 3D objects like polygons. This includes explicit representations using equations, as well as parametric and piecewise representations using vertices, edges, and other geometric elements. The key considerations in choosing a representation are rendering speed and efficiency as well as ease of processing and manipulation.

Uploaded by

api-3799599
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 49

CS3500 Computer Graphics

Module on Representation of Primitives


P. J. Narayanan
Spring 2005

CS3500
1

Representations of Primitives
• How do we represent different curves and surfaces for
graphics?

• An issue for graphics programmers, not for the graphics


system.

• Considerations: Representational Efficiency, Ease of


Manipulation, Rendering Speed/Efficiency, Ease of
Processing

CS3500 March 17, 2005


2

What can Graphics Ultimately Draw?


• 0-D objects: points.

• 1-D objects: Fundamentally a line, defined by two end


points.

• 2-D objects: A planar polygon. Triangle is the simplest.

• 3-D objects: Solid rendering!

• Everything else is broken up into the above.

CS3500 March 17, 2005


3

Points
• Most fundamental entity. Other primitives ultimately use
points and their interconnections.

• Represented using point coordinates: 2 numbers for 2D


and 3 numbers for 3D.

• Ideally real (floating point) numbers are used.

• Give the coordinates in the object or world space and not


in window or framebuffer space.

CS3500 March 17, 2005


4

Curves and Surfaces


• Representation could use equations of different kinds.
• Ellipse in 2D: ax2 +by 2 = 1; Sphere in 3D: x2 +y 2 +z 2 = r2.
• We can draw only lines or polygons. The curve or surface
has to be approximated using them before drawing.
• A priori approximation: Represent a sphere using 100
triangular patches.
• Not good if the curve/surface may be viewed at different
resolutions. Approximation to be done while rendering.
• Representation is compact; rendering is expensive.
CS3500 March 17, 2005
5

Piecewise Linear Curves


• Example: Lines, Polygons.
• Representation using lines is exact.

• Line segments are represented using endpoints.

• Line, Line Strip, Line Loop, Pencils of lines.

• Represented using a sequence of end points.

• Each point has 2 or 3 coordinates.

CS3500 March 17, 2005


6

Vertex List and Vertex Index


• Repeating the point coordinates is wasteful if a point is
used for multiple lines.

• Describe vertices as a Vertex List at start, which is a


table of all vertices in the object.

• The index of a vertex in the table is used in place of its


coordinates when describing lines and line loops.

• Reduces the representational complexity or size if


vertices are involved in many lines.
CS3500 March 17, 2005
7

1 x1, y1, z1 L1: 1, 2, 4, 5, 6, 2


2 x2, y2, z2
L2: 1, 3, 4
3 x3, y3, z3

n xn, yn, zn Lm: 1, 5, 8, 31, 4, 21, 22

• Since the reuse of the points is explicit, points after


modelling, viewing, and projection can be remembered.

• Disadvantage: One level of table lookup is required.

CS3500 March 17, 2005


8

End of Class 27

CS3500 March 17, 2005


9

Piecewise Polygonal Surfaces


• Polygon representation is exact for polyhedral objects.

• A polygon mesh represents them as a collection of


independent polygons.

• Explicit Representation: list a polygon as a sequence


of points. Pi = {(x1, y1, z1), (x2, y2, z2), · · · , (xk, yk, zk)}.

• An easy representation. Shared vertices are described


multiple times.

CS3500 March 21, 2005


10

Properties of Representations
• What do we want from representations?
• Drawing the polygon quickly/easily is most important.
• Reduced representational complexity or size.
• The following questions should be answered easily:
Which vertices define a given edge? Which edges meet
on a vertex? Which edges do 2 polygons share? Etc.
• Explicit representation is good for drawing.
Not good to answer these questions.

CS3500 March 21, 2005


11

Vertex List Representation


• List vertices as a Vertex List first. Use indices into the
list to represent vertices.
V = {(x1, y1, z1), (x2 , y2, z2), · · · , (xn, yn, zn)}
P1 = (1, 3, 5), P2 = (2, 4, 7, 8, 3), . . .
• Reduced size as shared vertices are described only once.
• Additional look-up time while processing.
• Can write a program to determine how many edges are
incident on a vertex by comparing indices.
• Not easy to find edges shared between polygons.
CS3500 March 21, 2005
12

Edge List Representation


• List edges as an Edge List, with explicit polygon
incidence, in addition to the vertex list.
• Polygons described in terms of indices of edges in order.
E1 = (1, 2, P1, P2), E2 = (4, 8, P3, P2), E3 = · · · , . . .
P1 = (1, 3, 6, 7), P2 = (4, 6, 8, 12, 1), P3 = · · · , . . .
• Easy to find edges shared between polygons, polygons
that use an edge, etc.
• Some are immediately available; some need searching.

CS3500 March 21, 2005


13

Planes of Polygons
• The plane normal of polygons may be needed.
• Plane equation: nTp = 0, with homogeneous vectors.
• Cross-product of 2 non-parallel sides gives 3 components
of n. Fourth obtained by substituting a point.
• For an N -sided polygons, the area of projection onto each
plane can also give the first 3 components.
• nTp is a measure of the distance from p to the plane.
• An enumeration of N points in 3D may not be planar!

CS3500 March 21, 2005


14

Example
Different representations: size, complexity.

CS3500 March 21, 2005


15

Representation of Curves
• Explicit: y = f (x), z = f (x).
Problems: Multiple y-values difficult, rotation changes
representation, slope of ∞ hard to represent.

• Implicit: f (x, y, z) = 0.
How do we represent segments? Tangents?

• Parametric: x = x(t), y = y(t), z = z(t).


Additional parameter introduced makes everything easy.
Tangent: x0(t), y 0(t), z 0(t)

CS3500 March 21, 2005


16

Parametric Representation of Lines


• P = P1 + t (P2 − P1) = (1 − t) P1 + t P2.

• 0 ≤ t ≤ 1 for line segment; any t for the whole line.

• Represents 3 equations, one each in x, y, and z.

• Get a 1-D structure with a 1-parameter family.

CS3500 March 21, 2005


17

Degree of the Parametric Curve


• Can be linear, quadratic, cubic, or a general polynomial in
the parameter t.
• Curve gets richer if higher degree polynomial is used.
• Linear: Too restrictive; only lines.
• Quadratic: Only planar curves even in 3D.
• Cubic: Non-planar curves with good control.
• Higher: Richer, but too many wiggles. Hard to control.

CS3500 March 21, 2005


18

Parametric Cubic Curves


 
ax ay az
 bx by bz 
 
3 2
• Q(t) = [x(t) y(t) z(t)] = [t t t 1]  =TC
 cx cy cz 
dx dy dz

• Parametric tangent vectors by differentiating:


Q0(t) = [3t2 2t 1 0] C

• Required curves may be split into multiple parametric


cubic segments that join together.

CS3500 March 21, 2005


19

Geometric & Parametric Continuity


• What happens at the join of two curve segments?
• If the curves meet, they have G0 geometric continuity.
If their tangent vectors are parallel G1 continuity.
If nth derivatives are parallel, Gn continuity.
• If tangent vectors are equal, parametric continuity C 1.
If nth derivatives are equal, C n continuity.
• G1 is sufficient for the “smooth” or “continuous” look.
• Usually, parametric continuity implies geometric continuity.

CS3500 March 21, 2005


20

Example
G2
G1

G0

Curve is pulled more when the tangent magnitude


increases.

CS3500 March 21, 2005


21

Parametric Cubic Curves: Summary


 
ax ay az
 bx by bz 
 
3 2
• Q(t) = [x(t) y(t) z(t)] = [t t t 1]  =TC
 cx cy cz 
dx dy dz
• Parametric tangent vectors by differentiating:
Q0(t) = [3t2 2t 1 0] C
• Required curves may be split into multiple parametric
cubic segments that join together.
• If nth derivatives are parallel, Gn continuity.
• If nth derivatives are equal, C n continuity.
CS3500 March 04, 2004
22

Geometry Vector
• Cubic curves have 4 unknowns. Need four constraints
from the geometry to solve for them.

• Could be 4 points, or 2 points and 2 tangents, etc.

• The column vector consisting of these constraints (each


is a vector), is called the Geometry Vector
G = [G1 G2 G3 G4]T.

• We can write C in terms of the Geometry Vector.

CS3500 March 04, 2004


23

Basis Matrix
 
m11 m12 m13 m14
 m21 m22 m23 m24 
 
• Write C = M · G =   G
 m31 m32 m33 m34 
m41 m42 m43 m44

• M is called the Basis Matrix.


 
T
G1
GT2
 
• B = T M = [T·m1 T·m2 T·m3 T·m4] 
 
GT3

 
GT4

CS3500 March 04, 2004


24

Blending Functions
• Q(t) = T M G = B G.

• B gives the blending functions using which the end


points are interpolated to get the curve.

• (1 − t) and t were the blending functions for parametric


lines.

• Different families of parametric curves differ in the


geometry vector and the basis matrix.

CS3500 March 04, 2004


25

End of Class 28

CS3500 March 04, 2004


26

Hermite Curves

• Geometry Vector: 2 end points P1, P4 and 2 end tangents


R1, R4, written as GH = [P1 P4 R1 R4]T

• Hermite Cubic Curves are characterized by the special


type of Geometry Vector. That defines the Basis Matrix of
the special kind also.

• Q(t) = T · MH · GH

• But, P1 = Q(0), P4 = Q(1), R1 = Q0(0), R4 = Q0(1).


CS3500 March 04, 2004
27
 
0 0 0 1
1 1 1 1
 
• Therefore, GH =   MH GH
0 0 1 0
3 2 1 0
  −1  
0 0 0 1 2 −2 1 1
1 1 1 1  −3 3 −2 −1 
   
• Giving, MH =  =
0 0 1 0  0 0 1 0 
 
3 2 1 0 1 0 0 0
• Blending functions for P1, P4, R1, R4 respectively are:
(2t3 − 3t2 + 1), (−2t3 + 3t2), (t3 − 2t2 + t) and (t3 − t2).
• Only one of them is non-zero at both end points.
CS3500 March 04, 2004
28

Hermite Curve: Properties


• Only one of them is non-zero
at both end points.
• Easy continuity conditions. 1 P1 P4

• C0, G0: P4 is common


between 2 segments.
R1
• G : 1
R4i−1
= kRi1, for
consecutive segments. 1
R4

• k = 1 for C1 continuity.

CS3500 March 04, 2004


29

Bézier Curves

• Geometry Vector has 4 points: GB = [P1 P2 P3 P4]T.

• P1 and P4 are the end points. Others give tangents:


R1 = Q0(0) = 3(P2 − P1), R4 = Q0(1) = 3(P4 − P3).

 
1 0 0 0
 0 0 0 1
 
• GH =   GB = MHB · GB
 −3 3 0 0
0 0 −3 3

CS3500 March 04, 2004


30
 
−1 3 −3 1
3 −6 3 0
 
• Thus, MB = MH · MHB =
 
 −3 3 0 0

1 0 0 0

• Bézier blending functions are:


(1 − t)3, 3t(1 − t)2, 3t2(1 − t), t3

• They are called Bernstein Polynomials, add up to 1


at every point, are positive everywhere, are terms of
binomial expansion of (t + (1 − t))3

CS3500 March 04, 2004


31

Bézier Curves: Properties


• Curve lies inside the convex-
hull of the control points.
• C0, G0 continuity when P4 1
P1 P4
is the first point of the next
segment. P2
P3
1
• G continuity when
(P3 − P4) = k(P5 − P4). 1

• C1 continuity when k = 1.

CS3500 March 04, 2004


32

Drawing Cubic Curves


• Draw them as line segments. Start with t = 0, increment
t by δ in each step and evaluate the curve point Q(t).
• Use Horner’s rule: ((at + b)t + c)t + d. How many
multiplications and additions per point?
• 11m + 10a for conventional method and 9m + 10a using
Horner’s rule per 3D point.
• Draw the line segment between curve points
Q(t = iδ) and Q(t = (i + 1)δ) till t = 1.
• Step size δ should be a function of the “zoom factor” or
how large the curve appears.
CS3500 March 04, 2004
33

Parametric Bicubic Surfaces

• Surfaces are 2D entities. Need 2 parameters s and t, one


in each dimension.

• Q(s, t) = S · M· [G1(t) G2(t) G3(t) G4(t)]T


Gi(t) = T · M · G i, i = 1, 2, 3, 4
Gi is a Geometry Vector of the curve i.

• Each value of t defines a curve; a family of such curves


with varying s defines the surface.
CS3500 March 04, 2004
34
 
g11 g12 g13 g14
g g g g
 
• Combining, we get S · M ·  21 22 23 24  · MT · TT
 
 g31 g32 g33 g34 
g41 g42 g43 g44
where, gij are the boundary points, each with x, y, z
coordinates.

• x(s, t) = S M Gx MT TT, y(s, t) = S M Gy MT TT, etc.

• 16 boundary conditions needed to define the parametric


bicubic surface.

• C0, G0, C1, G1 continuities can be defined similarly.


CS3500 March 04, 2004
35

Hermite Surfaces
• Q(s, t) = S · MH · GH(t) = S · MH · GH · MTH · TT
• GH(t) = [P1(t) P4(t) R1(t) R4(t)]T
• GH in turn
 consists of points and tangents. 
x(0, 0) x(0, 1) xt(0, 0) xt(0, 1)
 x(1, 0) x(1, 1) xt(1, 0) xt(1, 1) 
 
G Hx = 
 xs(0, 0) xs(0, 1) xst(0, 0) xst(0, 1) 

xs(1, 0) xs(1, 1) xst(1, 0) xst(1, 1)
∂x ∂x ∂ 2x
where xt = ∂t , xs = ∂s , xst = ∂s∂t

CS3500 March 04, 2004


36

Bézier Surfaces
• Q(s, t) = S · MB · GB(t) = S · MB · GB · MTB · TT

• GH(t) = [P1(t) P2(t) P3(t) P4(t)]T.

• GB consists of 16 points defining the Bézier surface.

• Convex-hull property holds. The surface is bound by the


16 control points.

CS3500 March 04, 2004


37

Surface Normals
• Partial derivatives define tangents.
∂ Q(s,t)
∂s = [3s2 2s 1 0] · M · G · MT · TT
∂ Q(s,t)
∂t = S · M · G · MT · [3t2 2t 1 0]T

• These are 3-vectors, with independent x, y, z components.

• Surface normal is given by their cross product.


∂ Q(s,t) (s,t)
n(s, t) = ∂s × ∂ Q∂t

CS3500 March 04, 2004


38

Displaying Bicubic Surfaces


• Draw them as curves with fixed s, varying t and vice
versa.

• Draw them as quads looping over s and t. Or as 2


triangles.

• Define suitable step sizes in s and t based on the display


resolution.

• Draw quads with vertices


Q(s, t), Q(s + δs, t), Q(s + δs, t + δt), Q(s, t + δt)
CS3500 March 04, 2004
39

Cubic Curves: Summary


• Q(t) = T · M · G, G consists of 4 boundary conditions.

• Hermite curves: 2 end points and 2 end tangents.

• Bézier curves: 2 end points and 2 other points for end


tangents.
   
2 −2 1 1 −1 3 −3 1
 −3 3 −2 −1   3 −6 3 0 
   
• MH =   , MB = 
 0 0 1 0   −3 3 0 0

1 0 0 0 1 0 0 0

CS3500 March 09, 2004


40

Bicubic Surfaces: Summary


• Each value of t defines a curve; a family of such curves
with varying s defines the surface. And vice versa too.
 
g11 g12 g13 g14
g g g g
 
• Q(s, t) = S · M ·  21 22 23 24  · MT · TT
 
 g31 g32 g33 g34 
g41 g42 g43 g44
gij give the 16 necessary boundary conditions, in terms
of x, y, z coordinates.

• C0, G0, C1, G1 continuities can be defined easily.


CS3500 March 09, 2004
41

End of Class 29

CS3500 March 09, 2004


42

Solid Objects
• Most objects are solid, though we see only their outer
surface.

• For Graphics, only the appearance is important. Hence,


the representation of the surface is sufficient.

• We need to know they are solid for many applications.

• Solid modelling is an important area in manufacturing,


engineering, etc.

• A number of ways to model and represent solids exist.


CS3500 March 09, 2004
43

Modelling and Representing Solids


• Parameterized Primitive Instancing: Define objects of
interest as primitives. Instance them with size, shape,
material parameter values for different objects. Nut/bolts,
Rivets, Wheels, etc.

• Sweep Representations: Translational sweep (extrusion),


rotational sweep, and arbitrary sweep.

• Boundary Representations: Describe objects in terms of


its surface boundaries: faces, edges, vertices. Polyhedral
and Nonpolyhedral b-reps.
CS3500 March 09, 2004
44

• Spatial Partitioning Reps: Divide space into cells and


describe objects in terms of the cells they occupy!

• Constructive Solid Geometry: Combine elementary


primitives using regularized Boolean operators. Rich
algebra for forming objects exist.

CS3500 March 09, 2004


45

Volume Cells
• Rectangular volume cells or voxels are common for
representation.

• A voxel is either part of the object or not; partial


occupancy is difficult.

• Voxel size is critical. Smaller the voxels, better the


represenatation.

• An O(n3) structure! Memory/storage requirements are


huge. Time complexity even more serious!
CS3500 March 09, 2004
46

Octrees

• A top-down, divide-and-conquer representation of solid


objects.

• Divide the object recursively using 3 orthogonal planes


into 8 octants if it is not homogeneous.

• Octants named using: Up/Down, Left/Right, Front/Back.

• Number of nodes in the octree is proportional to the


objects surface area mostly.
CS3500 March 09, 2004
47

• Algorithms to manipulate and reason about objects using


octree representation are available.
Y

2 3
6 2 3
6 7 3 3
6 7 7
6 1
4 5 5

1 X
5
4 5

• Why call it a tree?

CS3500 March 09, 2004


48

End of Class 30

CS3500 March 09, 2004

You might also like