Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
27 views

Thursday September 1, 2009: CSE 458: Computer Graphics

This lecture covered relevant math concepts for computer graphics like vectors, points, coordinates and coordinate systems. It discussed implicit and parametric representations of curves and surfaces. Barycentric coordinates were introduced as a way to represent points within a triangle using coefficients based on distances from the triangle sides. Visualizing math geometrically and translating it directly into code is important in computer graphics.

Uploaded by

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

Thursday September 1, 2009: CSE 458: Computer Graphics

This lecture covered relevant math concepts for computer graphics like vectors, points, coordinates and coordinate systems. It discussed implicit and parametric representations of curves and surfaces. Barycentric coordinates were introduced as a way to represent points within a triangle using coefficients based on distances from the triangle sides. Visualizing math geometrically and translating it directly into code is important in computer graphics.

Uploaded by

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

CSE 458: Computer Graphics

Lecture 2
Thursday September 1, 2009

Professor Yanxi Liu


TA: Kyle Brocklehurst

1
Today’s Theme

A Review of some Relevant Math


with
a geometric perspective

2
Math in Computer Graphics

is

… of central importance

3
Much of graphics is just translating math

directly into code …

-- 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?

Clean, intuitive geometry Æ


clean, intuitive graphics code
easier debugging

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

• Implicit form: f(x,y) = y – mx –b = 0


• A more general form f(x,y) = Ax+By+C=0

• One interesting property of the implicit line


equation is that It can be used to find the
signed distance from a point to the line:
• For example, line x-y=0
18
19
Implicit Representation for
Planes
• Ax + By + Cz + D = 0

20
Implicit Representation for
2D Quadratic Curves
• Ellipses, parabolas,

• Special cases: hyperbolas, circles, lines

• General form:

Ax2 + Bxy + Cy2 + Dx +Ey + F = 0

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

• What if f > 0, f=0, f < 0 ?

Æ f(x,y) exists in 3D space !

e.g. Height map f = (x-xc)2 + (y-yc)2 – r2


26
2D Quadratic Equations (implicit)
Algebraically Geometrically

Ax2 + Bx + C = 0
where x is unknown (real number)
A, B and C are known constants hits

D = B2 – 4AC Æ discriminant of the


quadratic equation
grazes

D > 0: 2 roots Æ hits


D = 0: 1 root Æ grazes
27
D < 0: no real roots Æ misses misses
Visualize math

What happens in 3D?


Matlab 3D demonstration

28
hits grazes
misses

-f(x,y)

f(x,y) and -f(x,y) share


the same 2D circle at z=0
BUT opposite normal or
gradient vectors (uphill
direction - p33)!
29
Parametric
Representation

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

Given a triangle composed of three points a,b,c, any


point p can be expressed as

p = a + β(b-a) + γ (c-a)

setting up a Non-Orthogonal coordinate system


with origin a and basis vectors (b-a) and (c-a)
37
38
Barycentric Coordinates: signed
scaled distance from the lines
through the triangle sides.

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

You might also like