Professional Documents
Culture Documents
Logistics
Required reading:
Watt, Section 1.1.
Further reading:
Foley, et al, Chapter 5.1-5.5.
David F. Rogers and J. Alan Adams, Mathematical
Elements for Computer Graphics, 2nd Ed., McGrawHill, New York, 1990, Chapter 2.
Logistics:
HW #1 handed out Monday
Project #1 due on Monday, artifact on following
Monday.
Geometric transformations
Geometric transformations will map points in one
space to points in another: (x',y',z') = f(x,y,z).
These transformations can be very simple, such as
scaling each coordinate, or complex, such as nonlinear twists and bends.
We'll focus on transformations that can be
represented easily with matrix operations.
We'll start in 2D...
Representation
We can represent a point, p = (x,y), in the plane
" x%
$ '
# y&
as a column vector
as a row vector
[x
y]
Representation, cont.
We can represent a 2-D transformation M by a matrix
"a b%
M =$
'
#c d&
If p is a column vector, M goes on the left: p" = Mp
#x "& #a b& #x&
!
% (=%
(% (
$y "' $c d' $y'
T
If p is a row vector, MT goes on the right: p" = pM
[ x"
y "] = [ x
#a c &
y] %
(
b
d
$
'
Two-dimensional transformations
Here's all you get with a 2 x 2 transformation
matrix M:
#x "& #a b& #x&
% (=%
(% (
"
$y ' $c d' $y'
So:
x " = ax + by
! y " = cx + dy
Identity
Suppose we choose a=d=1, b=c=0:
Gives the identity matrix:
"1 0%
$
'
#0 1&
Doesn't
! move the points at all
Scaling
Suppose b=c=0, but let a and d take on any positive value:
Gives a scaling matrix: "a 0%
$
'
#0 d&
Provides differential (non-uniform) scaling in x and y:
x " = ax
y " = dy
"2 0%
$
'
#0 2&
!
"1 2 0%
$
'
# 0 2&
!
University of Texas at Austin
Reflection
Suppose b=c=0, but let either a or d go negative.
Examples:
#1 0 &
%
(
$0 "1'
#"1 0&
%
(
$ 0 1'
!
University of Texas at Austin
Shear
Now leave a=d=1 and experiment with b
The matrix "1 b%
$
'
0
1
#
&
gives: x " = x + by
!
y" = y
"1 1%
$
'
#0 1&
!
University of Texas at Austin
10
11
12
Rotation
From our observations of the effect on the unit square, it
should be easy to write down a matrix for rotation about
the origin:
"1% "cos() )%
$ '($
'
0
sin(
)
)
#& #
&
"0% "*sin() )%
$ '($
'
1
cos(
)
)
#& #
&
Thus
13
Linear transformations
The unit square observations also tell us the 2x2 matrix transformation
implies that we are representing a point in a new coordinate system:
p" = Mp
#a b& #x&
=%
(% (
c
d
$
' $ y'
# x&
= [u v] % (
$ y'
= x)u+ y) v
where u=[a c]T and v=[b d]T are vectors that define a new basis for a
linear space.
The transformation to this new basis (a.k.a., change of basis) is a
!
linear transformation.
University of Texas at Austin
14
15
Affine transformations
In order to incorporate the idea that both the basis and the
origin can change, we augment the linear space u, v with
an origin t.
Note that while u and v are basis vectors, the origin t is a
point.
We call u, v, and t (basis and origin) a frame for an affine
space.
Then, we can represent a change of frame as:
p" = x # u + y # v + t
This change of frame is also known as an affine
transformation.
How do
! we write an affine transformation with matrices?
University of Texas at Austin
16
Homogeneous Coordinates
To represent transformations among affine frames, we can loft the
problem up into 3-space, adding a third component to every point:
p" = Mp
#a b
%
= %c d
%$0 0
t x & # x&
(% (
t y ( % y(
1 (' %$1('
# x&
% (
= [u v t ] %y(
%$1('
= x ) u + y ) v + 1) t
Note that [a c 0]T and [b d 0]T represent vectors and
[tx ty 1]T, [x y 1]T and [x' y' 1]T represent points.
17
Homogeneous coordinates
This allows us to perform translation as well as the linear
transformations as a matrix operation:
p" = M T p
#x "& #1 0 t x & # x&
% ( %
(% (
"
y
=
0
1
t
y ( % y(
% ( %
%$ 1 (' %$0 0 1 (' %$1('
x " = x + tx
y " = y + ty
"1 0 1 %
$
'
0
1
1
2
$
'
$#0 0 1 '&
!
University of Texas at Austin
18
1. Translate q to origin
2. Rotate
3. Translate back
Line up the matrices for these step in right to left order and multiply.
Note: Transformation order is important!!
University of Texas at Austin
19
p(t) = p0 + tv
Q: What !
does this describe?
20
Barycentric coordinates
A set of points can be used to create an affine frame. Consider a
triangle ABC and a point p:
A
p
B
We can form a frame with an origin C and the vectors from C to the
other vertices:
u = A"C v = B"C t = C
!
!
The coordinates (, , ) are called the barycentric coordinates of
p relative to A, B, and C.
University of Texas at Austin
21
By
1
*' * ' *
Cy * '# * = 'py *
1 *) '&$ *) '& 1 *)
Bx
By
1
Bx
By
Cx
Cy
1
Cx
Cy
Ax
Ay
1
#=
Ax
Ay
px
py
1
Bx
By
Cx
Cy
1
Cx
Cy
Ax
Ay
1
$=
Ax
Ay
Bx
By
1
Bx
By
px
py
1
Cx
Cy
22
Cross products
Consider the cross-product of two vectors, u and v. What is
the geometric interpretation of this cross-product?
A cross-product can be computed as:
i
u " v = ux
vx
j
uy
vy
k
uz
vz
What happens when u and v lie in the x-y plane? What is the
area of the triangle they span?
!
23
SArea(ApC)
#=
SArea(ABC)
SArea(ABp)
$=
SArea(ABC)
24
p = "1p1 + K + " n pn
!i = 1
"
i =1
!
Note that if the i s are all positive, the result is more specifically called a
convex combination.
Q: Why is it called a convex combination?
25
0
sy
0
0
0
0
sz
0
0& #x&
(% (
0( %y(
0( % z (
(% (
1' $1'
!
University of Texas at Austin
26
Translation in 3D
#x "& #1
% ( %
%y "( = %0
% z"( %0
% ( %
$ 1 ' $0
0 0 t x & # x&
(% (
1 0 t y ( % y(
0 1 tz ( % z(
(% (
0 0 1 ' $1'
27
Rotation in 3D
Rotation now has more possibilities in 3D:
$1
0
0
&
0 cos(" ) #sin(" )
Rx (" ) = &
&0 sin(" ) cos(" )
&
0
0
%0
$ cos(" )
&
0
&
Ry (" ) =
&#sin(" )
&
% 0
0 sin(" )
1
0
0 cos(" )
0
0
$cos(" ) #sin(" )
&
sin(" ) cos(" )
Rz (" ) = &
& 0
0
&
0
% 0
University of Texas at Austin
0
0
1
0
0'
)
0)
0)
)
1(
0'
)
0)
0)
)
1(
0'
)
0)
0)
)
1(
Ry
Rz
Rx
28
Shearing in 3D
Shearing is also more complicated. Here is one
example:
#x "& #1 b 0 0& #x&
% ( %
(% (
"
y
0
1
0
0
% (=%
( % y(
% z"( %0 0 1 0( % z (
% ( %
(% (
1
0
0
0
1
$ ' $
' $1'
29
!i = 1
"
i =1
# x&
#x "& #1 0 0 0& % (
% ( %
( % y(
%y "( = %0 1 0 0( % z (
%$ 1 (' %$0 0 0 1(' % (
$1'
This transformation, known as an orthographic projection, is an affine
transformation.
Well use this fact later
30
pq s p"q"
ratio =
= =
qr
t
q"r"
! - Computer Graphics
CS384G
31
Summary
What to take away from this lecture:
All the names in boldface.
How points and transformations are represented.
What all the elements of a 2 x 2 transformation matrix
do and how these generalize to 3 x 3 transformations.
What homogeneous coordinates are and how they work
for affine transformations.
How to concatenate transformations.
The rules for combining points and vectors
The mathematical properties of affine transformations.
32
33