Thursday September 1, 2009: CSE 458: Computer Graphics
Thursday September 1, 2009: CSE 458: Computer Graphics
Lecture 2
Thursday September 1, 2009
1
Today’s Theme
2
Math in Computer Graphics
is
… of central importance
3
Much of graphics is just translating math
-- Shirley
4
Outline
• Think geometry
– functions, vectors, points, coordinates
• Types of surface/curve
Representation
– Implicit
– parametric
• Linear interpolation
• *** Barycentric coordinates ***
5
Think geometrically!
Visualize math!
6
Why?
7
Write on board
• What is a bijective function?
If a function f: A Æ B is both 1-to-1 and onto then f is called a
bijective function or bijection
1-to-1: every point in A is mapped to a unique point in B
Onto: f-1(b) = a for every point in B and some a in A
• What is the difference between a vector and a point?
– A point is defined w.r.t. a specific coordinate system and
has a fixed location; a vector has a length and direction,
and does not necessarily start from the origin of a
coordinate system.
• Vector operations
– Addition and subtraction
– Dot product and Cross product
8
9
10
11
Coordinate systems
• Managing coordinate systems is one of the
CORE tasks of almost ANY graphics
program
– Cartesian coordinate system a.k.a
rectangular coordinate system with
orthogonal (perpendicular) basis vectors
– polar coordinates (2D),
– spherical coordinates (3D),
– cylindrical coordinates(3D)
12
How to construct an orthogonal bases
from a single vector a?
Such that a is one of the basis vectors
• No unique solution
• Think geometry: which vector is far away from
me?)
• If w = (1/2, -1/2, 0) …
13
How to construct an orthonormal basis
from a single vector a?
Such that a is one of the basis vectors
• No unique solution
• Think geometry: which vector is far away from
me?)
• If w = (1/2, -1/2, 0) …
14
Outline
• Think geometry
– functions, vectors, points, coordinates
• Types of surface/curve Representation
– Implicit
– Parametric
• Linear interpolation
• *** Barycentric coordinates ***
– area and matrix determinant
15
Implicit Representation
f(x,y) = 0
f(x,y,z) = 0
16
Representations of
Geometry Entities
• Implicit Representation
– f(x,y) = 0 denoting those points p = [x,y] where
f(x,y)=0
– A point p(x,y) of f(x,y)=0 is NOT explicitly
represented by f(x,y) but “buried” implicitly in
the equation f(x,y) = 0
17
Implicit Representation for
2D Lines
• Slope-intercept form of the line: y = mx +b
20
Implicit Representation for
2D Quadratic Curves
• Ellipses, parabolas,
• General form:
21
Think geometrically!
Visualize math!
22
How to express a circle that is
NOT centered at the origin?
(think geometrically -- Vector form)
origin
p
c
r
23
How to express a circle that is
NOT centered at the origin?
(think geometrically -- Vector form)
origin
|| p – chits
|| = r
p c: center point, p: curve
c points, r: distance
between p and c
r Clean and simple!
grazes 24
How to express a plane using
Vector form?
P38-39
25
Beyond Curve/Surface
• 2D curves: f(x,y) = 0
Ax2 + Bx + C = 0
where x is unknown (real number)
A, B and C are known constants hits
28
hits grazes
misses
-f(x,y)
x = f(t)
y = g(t)
z = h(t)
30
Representations of
Geometry Entities
• Parametric (explicit) Representation
– a point: x = g(t), y = h(t)
• E.g. x = r sin (θ), y = r cos (θ) where t = θ
– A parametric curve: p = f(t),
– Points on the curve/surface are explicitly
represented thus can be generated directly
(very useful for computer graphics)
BUT, how to define t?
31
Representations of Geometry
Entities (cont.)
• Parametric Representation
– 2D curves (lines, circles)
• p = f(t), where f: R -> R2
• lines: p(t) = p0 + t(p1 – p0) (vector form!)
– 3D curves (one parameter):
x=f(t), y=f(t), z=f(t)
– 3D surfaces (two parameters):
x = f(u,v)
y = g(u,v)
z = h(u,v) 32
Pros and Cons
Representations of Geometry Entities
• Implicit Representation
– pros: almost universally applicable
– cons: need to first find the solution of the
equations, and it’s Implicit!
• Parametric Representation
– Pros:
• Easy to implement on computer (!)
• Controlled by one or two parameters
– Cons:
• Not always easily defined
33
Outline
• Think geometry
– functions, vectors, points, coordinates
• Types of surface/curve Representation
– Implicit
– parametric
• *** Barycentric coordinates ***
34
Barycentric Coordinates
(basic idea)
35
Barycentric Coordinates
(basic idea)
36
Barycentric Coordinates
Triangles (2D and 3D) are fundamental modeling
primitives in graphics
p = a + β(b-a) + γ (c-a)
p (one zero)
p (all < 1)
p (two zeros)
39
Barycentric Coordinates
Summary
• non-orthogonal coordinates (!)
• extend almost transparently to 3D!
• the triplet coordinates sum up to 1
• geometric interpretation:
signed, scaled distances from the two
sides of the triangle: (b-a), (c-a)
40