Académique Documents
Professionnel Documents
Culture Documents
TO
COMPUTER
GRAPHICS
3D Coordinate geometry
Vectors in 2 space and 3 space
Dot product and cross product definitions and
uses
Vector and matrix notation and algebra
Properties (matrix associativity but NOT matrix
commutativity)
Matrix transpose and inverse definition, use,
and calculation
Homogenous coordinates
cs123 staff
Timeless
INTRODUCTION
TO
COMPUTER
GRAPHICS
store B (B & C)
Sum:
6
totalCost A 0.20 0.93 0.64 1.20
5
P( All ) = totalCost B = 0.65 0.95 0.75 1.40
1
totalCost C 0.95 1.10 0.90 3.50
2
cs123 staff
Timeless
INTRODUCTION
TO
COMPUTER
GRAPHICS
totalCost1 A
P ( All ) = totalCost1B
totalCost1C
3x4
4x2
6
totalCost 2 A 0.20 0.93 0.64 1.20
5
totalCost 2 B = 0.65 0.95 0.75 1.40
1
cs123 staff
Timeless
3
2
8
INTRODUCTION
TO
COMPUTER
GRAPHICS
5
4
3
2
1
R2
5
4
3
2
1
Point at (2, 3)
-5 -4 -3 -2 -1
-1
-2
-3
-4
-5
R3
1 2 3 4 5
-5 -4 -3 -2 -1
-1
-2
-3
-4
-5
1 2 3 4 5
Point at
Z
(4, -2, 3)
Real numbers: between any two real numbers on an axis
there exists another real number
Compare with the computer screen, a positive integer
coordinate system
1
1024
0
1
2
1024
cs123 staff
1024
1024
Timeless
INTRODUCTION
TO
COMPUTER
GRAPHICS
(8, 9)
(2, 4)
1 2 3
(10, 2)
4 5
6 7 8 9 10
cs123 staff
Timeless
INTRODUCTION
TO
COMPUTER
GRAPHICS
cs123 staff
Timeless
INTRODUCTION
TO
COMPUTER
GRAPHICS
Vector addition
Vector addition in 1
10
Vector addition in 2
2
v=
3
2 4 6
v + v' = + =
3 2 5
4
v' =
2
1 2 3 4 5
6 7 8 9 10
Timeless
INTRODUCTION
TO
COMPUTER
GRAPHICS
v + v
v
v
1 2 3 4 5
6 7 8 9 10
v + v
v
v
1 2 3 4 5
cs123 staff
6 7 8 9 10
Timeless
INTRODUCTION
TO
COMPUTER
GRAPHICS
2v = (v + v)
v
0
10
On also
2
Y
10
9
8
7
6
5
4
3
2
1
2 3 6
2v =
=
2 2 4
x 3
v= =
y 2
1 2 3
cs123 staff
4 5
6 7 8 9 10
Timeless
INTRODUCTION
TO
COMPUTER
GRAPHICS
v
2v
v
1 2 3
4 5
6 7 8 9 10
-v
cs123 staff
Timeless
INTRODUCTION
TO
COMPUTER
GRAPHICS
x
1
0
x
y
=
+
y
0
1
cs123 staff
Timeless
INTRODUCTION
TO
COMPUTER
GRAPHICS
1
0
0 and 1 are perpendicular. Is this necessary?
n
Questions rephrased: can we make any vector
from scalar multiples of random vectors
a
b
and
c
d
m
b
d = b + d
OK
cs123 staff
OK
not OK
Timeless
not OK
INTRODUCTION
TO
COMPUTER
GRAPHICS
cs123 staff
Timeless
INTRODUCTION
TO
COMPUTER
GRAPHICS
cs123 staff
Timeless
INTRODUCTION
TO
COMPUTER
GRAPHICS
cs123 staff
Timeless
INTRODUCTION
TO
COMPUTER
GRAPHICS
radius = ||v||
|v| sin()
|v| cos()
( -)
V`
Proof:
[ ]
v = [v v ] = v ' [cos sin ]
v = v x v y = v [cos sin ]
x y
cos
cos cos
cos
v v = v
v
v
v
sin
sin
sin sin
= v v (cos cos + sin sin )
so, v v = v v cos( )
cs123 staff
Timeless
INTRODUCTION
TO
COMPUTER
GRAPHICS
( -)
Example:
3
v' =
4
-5 -4 -3 -2 -1
cs123 staff
5
4
3
2
1
4
v=
3
and
3
v' =
4
4
v=
3
v v = xx + yy = (4 3) + (3 4) = 0
v v = v v cos = v v 0 = 0
2
1 2 3 4 5
Timeless
INTRODUCTION
TO
COMPUTER
GRAPHICS
Cross Product
Cross product of
defined as:
a1
a
2
a3
and
b1
b ,
2 written
b3
a1 b1
a b
2 2 is
a3 b3
a1 b1 a2b3 a3b2
a b = a b a b
2 2 3 1 1 3
a3 b3 a1b2 a2b1
v v
a b = det a1
b1
j
a2
b2
a3
b3
cs123 staff
Timeless
INTRODUCTION
TO
COMPUTER
GRAPHICS
Commutative (vector)
Associative (vector)
Additive identity
v + v' = v' +v
(v + v' ) + u = v + (v' +u )
There is a vector 0, such that for
all v,
(v + 0) = v = (0 + v )
Additive inverse
Distributive (vector)
Distributive (scalar)
Associative (scalar)
Multiplicative identity
cs123 staff
Timeless
r (v + v' ) = rv + rv'
(r + s )v = rv + sv
r (sv ) = (rs )v
For any v, 1 , 1 v = v
INTRODUCTION
TO
COMPUTER
GRAPHICS
there = (7, 6)
6
5
4
3
here = (2, 3)
2
1
0
1
10
cs123 staff
Timeless
INTRODUCTION
TO
COMPUTER
GRAPHICS
What is a Matrix?
cs123 staff
Timeless
INTRODUCTION
TO
COMPUTER
GRAPHICS
Translation
x
x'
dx
v = v + t where v = , v' = , t =
y
y '
dy
and
x = x + dx
y = y + dy
To move polygons: just translate vertices (vectors)
and then redraw lines between them
Preserves lengths (isometric)
Preserves angles (conformal)
Y
4
4
5
4
dx = 2
dy = 3
3
2
2
1
1
0
1
10
cs123 staff
Timeless
INTRODUCTION
TO
COMPUTER
GRAPHICS
Scaling
x
x'
v = , v' =
y
y '
and
sx 0
S=
0
s
y
x' = s x x
y' = s y y
6
5
sx = 3
sy = 2
3
2
2
1
6
2
3
1
9
2
0
1
10
X
Note: House shifts position relative to origin
NB: A scale of 1 in both directions, i.e. no scale at all, gives us the identity matrix, as it should
cs123 staff
Timeless
INTRODUCTION
TO
COMPUTER
GRAPHICS
Rotation
x
x'
v = , v' =
y
y '
v = R v where
cos sin
R =
sin cos
and
x = x cos y sin
y = x sin + y cos
4
3
2
1
0
1
10
cs123 staff
Timeless
INTRODUCTION
TO
COMPUTER
GRAPHICS
Digression: Types of
Transformations
Timeless
INTRODUCTION
TO
COMPUTER
GRAPHICS
For scaling
x' = sx x
y' = s y y
cs123 staff
Timeless
INTRODUCTION
TO
COMPUTER
GRAPHICS
Matrix-Vector Multiplication
(1/2)
x a b x ax + by
v = =
=
= Mv
y c d y cx + dy
a b
x
x
where M =
, v = y , v = y
c
d
cs123 staff
Timeless
INTRODUCTION
TO
COMPUTER
GRAPHICS
Matrix-Vector Multiplication
(2/2)
In general:
a1 a2
b b
2
1
c1 c2
L L
m1 m2
a3
b3
c3
L
L
L
L L
m3 L
L
L L
n
a
x
i i
a x
i =n1
a x b x
i i
MX =
=
i =1
L L
m x
n
mi xi
i =1
cs123 staff
Timeless
INTRODUCTION
TO
COMPUTER
GRAPHICS
A+ B = B + A
( A + B ) + C = A + (B + C )
There is a matrix 0, such
that, for all A,
( A + 0) = A = (0 + A)
Inverse
Distributive (matrix)
Distributive (scalar)
Properties of matrix multiplication
r ( A + B ) = rA + rB
(r + s )A = rA + sA
AB BA
( AB )C = A(BC )
(rs )A = r (sA)
A( v + v' ) = Av + Av'
NOT commutative
Associative (matrix)
Associative (scalar)
Distributive (vector)
Identity
AI = A = IA
AA1 = I = A1 A
cs123 staff
Timeless
INTRODUCTION
TO
COMPUTER
GRAPHICS
1 1 0 1
1 2 1 = 2
cs123 staff
Timeless
INTRODUCTION
TO
COMPUTER
GRAPHICS
cs123 staff
Timeless
INTRODUCTION
TO
COMPUTER
GRAPHICS
0
1
Timeless
INTRODUCTION
TO
COMPUTER
GRAPHICS
Matrix-Matrix Multiplication
(1/2)
rowM ,1 col N ,1
M
MN =
rowM ,m col N ,1
L
rowM ,i col N , j
O
L
L rowM ,m col N ,k
O
M
O
M
L rowM ,m col N ,k
cs123 staff
Timeless
INTRODUCTION
TO
COMPUTER
GRAPHICS
Matrix-Vector Multiplication
(2/2)
1 2
1 2
L L
1 2
cs123 staff
L
L
L
L
n
L
a1
a2
M
an
a
a
Timeless
b1
b2
M
bn
a
b
L
MN
INTRODUCTION
TO
COMPUTER
GRAPHICS
Combining Transformations
Translation induced by
scaling and rotation
Rotation followed by
non-uniform scale; next
same scale followed by
same rotation
cs123 staff
Timeless
INTRODUCTION
TO
COMPUTER
GRAPHICS
Matrix Composition
For M 1 =
f
and
h
x
v=
y
M 1 ( M 2 (v)) = ( M 1M 2 )(v)
a b e
c d g
f x a b ex + fy a(ex + fy ) + b( gx + hy
=
=
h y c d gx + hy c(ex + fy ) + d ( gx + hy )
cs123 staff
Timeless
INTRODUCTION
TO
COMPUTER
GRAPHICS
In 2D
Commutative
Translate, translate
Scale, scale
Rotate, rotate
Scale uniformly, rotate
Non-commutative
Non-uniform scale, rotate
Translate, scale
Rotate, translate
In 3D
Commutative
Translate, translate
Scale, scale
Scale uniformly, rotate
Non-commutative
Non-uniform scale, rotate
Translate, scale
Rotate, translate
Rotate, rotate
cs123 staff
Timeless
INTRODUCTION
TO
COMPUTER
GRAPHICS
Translation revisited
there =
(7, 6)
5
4
3
here = (2, 3)
2
1
0
10
or
x' = x + dx
y ' = y + dy
x' = 1* x + 0 * y + dx *1
y ' = 0 * x + 1* y + dy *1
1 = 0 * x + 0 * y + 1*1
x' 1 0 dx x
y ' = 0 1 dy * y
1 0 0 1 1
Timeless
INTRODUCTION
TO
COMPUTER
GRAPHICS
Matrix Inverse
cs123 staff
Timeless
INTRODUCTION
TO
COMPUTER
GRAPHICS
Rectangle(B)
cs123 staff
A-1*B
A*B
Timeless
A-1*A*B
INTRODUCTION
TO
COMPUTER
GRAPHICS
cs123 staff
Timeless
INTRODUCTION
TO
COMPUTER
GRAPHICS
cs123 staff
Timeless
INTRODUCTION
TO
COMPUTER
GRAPHICS
0 0 1
0 0 1
cs123 staff
Timeless
INTRODUCTION
TO
COMPUTER
GRAPHICS
cs123 staff
Timeless
INTRODUCTION
TO
COMPUTER
GRAPHICS
Step 1. Locate the leftmost column that does not consist entirely of
zeros.
Step 2. Interchange the top row with another row, if necessary, to
bring a nonzero entry to the top of the column found in Step 1.
Step 3. If the entry that is now at the top of the column found in
Step 1 is a, multiply the first row by 1/a in order to introduce a
leading 1.
Step 4. Add suitable multiples of the top row to the rows below so
that all entries below the leading 1 become zeros.
Step 5. Now cover the top row in the matrix and begin again with
Step 1 applied to the submatrix that remains. Continue in this way
until the entire matrix is in row-echelon form. (not reduced rowechelon form)
Step 6. Beginning with the last nonzero row and working upward,
add suitable multiples of each row to the rows above to introduce
zeros above the leading 1s.
cs123 staff
Timeless
INTRODUCTION
TO
COMPUTER
GRAPHICS
17 19
17 19 0 1
1
0
=
11 11
17 19 0 1
0
1 11
11
=
12
17
0
1
11
11
cs123 staff
Timeless
INTRODUCTION
TO
COMPUTER
GRAPHICS
0
1 11 11
=
17
11
0 1
12
12
1 0
12
[ I | A1 ] =
17
0 1
12
13
12
11
12
Therefore:
19
A1 = 12
17
12
cs123 staff
13
12
11
12
Timeless
INTRODUCTION
TO
COMPUTER
GRAPHICS
*
1
0
* L *
* L *
M O *
* * *
* L *
1 L *
M O *
0 0 1
to
to
1
0
cs123 staff
0 L 0
1 L 0
M O 0
0 0 1
Timeless
INTRODUCTION
TO
COMPUTER
GRAPHICS
b
e
h
c x
f y
i z
[x'
z]
y ' z '] = [x
a b
z ] d e
g h
c
f
i
cs123 staff
Timeless
INTRODUCTION
TO
COMPUTER
GRAPHICS
Notice that
[x
a b
z ] d e
g h
c
f = [ax + dy + gz bx + ey + hz cx + fy + iz ]
i
while
a
d
cs123 staff
b
e
h
c x ax + by + cz
f y = dx + ey + fz
i z gx + hy + iz
Timeless
INTRODUCTION
TO
COMPUTER
GRAPHICS
b
e
h
c
a
T
f , M = b
c
i
d
e
f
gx + hy + iz g h i z
g
h
i
+ iz
+]
gx hy
Timeless
INTRODUCTION
TO
COMPUTER
GRAPHICS
TRSv
Matrices applied right to left
vSTRTTT
Matrices applied left to right
cs123 staff
Timeless
INTRODUCTION
TO
COMPUTER
GRAPHICS
Summary
cs123 staff
Timeless