Professional Documents
Culture Documents
Affine Transformations
Affine Transformations
Required:
Geometric transformations will map points in one We can represent a point, p = (x,y), in the plane
space to points in another: (x',y',z') = f(x,y,z).
as a column vector
These tranformations can be very simple, such as ªxº
scaling each coordinate, or complex, such as non- «y»
linear twists and bends.
¬ ¼
as a row vector
We'll focus on transformations that can be >x y@
represented easily with matrix operations.
We can represent a 2-D transformation M by a Here's all you get with a 2 x 2 transformation matrix
matrix M:
ªa b º ª x 'º ªa b º ª x º
«c d » « y '» « c d » « y »
¬ ¼ ¬ ¼ ¬ ¼¬ ¼
p' pMT
ªa c º
>x' y '@ >x y@« »
¬b d ¼
Identity Scaling
Suppose we choose a=d=1, b=c=0: Suppose we set b=c=0, but let a and d take on any
positive value:
Gives the identity matrix:
Gives a scaling matrix:
ª1 0º ªa 0 º
«0 d »
« 0 1» ¬ ¼
¬ ¼
Provides differential (non-uniform) scaling in
Doesn't move the points at all x and y:
x ' ax
y ' dy
y y
ª2 0 º
«0 2 »
2 2 ¬ ¼
1 1
x x
1 2 1 2
y
ª1 2 0 º
« 0 2»
2 ¬ ¼
1
x
1 2
______________ ____________
Suppose we keep b=c=0, but let either a or d go Now let's leave a=d=1 and experiment b. . . .
negative.
The matrix
Examples: ª1 bº
« 0 1»
¬ ¼
gives:
ª 1 0 º ª1 0 º x' x by
« 0 1» «0 1» y' y
¬ ¼ ¬ ¼
y y
y y
x x ª 1 1º
1 1 «0 1»
¬ ¼
x x
1 1
:L
q
cu
iM
xfm
rl2
n
ag
w
o
t'sh
e Observe:
theu
nitsq
:
are
u
Origin invariant under M
M can be determined just by knowing how the
ªa b º corners (1,0) and (0,1) are mapped
« c d » >p q r s @ >p' q' r' s' @
¬ ¼ a and d give x- and y-scaling
b and c give x- and y-shearing
ªa b º ª0 1 1 0 º ª0 a a b b º
« c d » « 0 0 1 1» « 0 c c d d »
¬ ¼¬ ¼ ¬ ¼
y y
s r
1
p q x x
1
Rotation Linear transformations
From our observations of the effect on the unit The unit square observations also tell us the 2x2
square, it should be easy to write down a matrix for matrix transformation implies that we are
“rotation about the origin”: representing a point
p' inMapnew coordinate system:
ªa b º ª x º
y y «c d » « y »
¬ ¼¬ ¼
ªxº
>u v @ « »
1 ¬y¼
x u y v
x T x
1
ª 1º
« »o where u=[a c]T and v=[b d]T are vectors that define a
¬0 ¼ new basis for a linear space.
ª0 º The transformation to this new basis (a.k.a., change
« »o
¬ 1¼ of basis) is a linear transformation.
Thus,
ª º
M R(T ) «« »
»
«¬ »¼
A 2 x 2 linear transformation matrix allows In order to incorporate the idea that both the basis
and the origin can change, we augment the linear
Scaling space u, v with an origin t.
Rotation
Reflection We call u, v, and t (basis and origin) a frame for an
Shearing affine space.
Idea is to loft the problem up into 3-space, adding a Until now, we have only considered rotation about
third component to every point: the origin.
ª x'º ªxº ª1 0 t x º ª x º
« y ' » T (t) « y » «0 1 t » « y » θTTW
T
« » « » « y »« » q
¬«w ' ¼» ¬«1 ¼» ¬«0 0 1 »¼ «¬1 ¼» x x x x
y y
ª1 0 1 º
«0 1 1 2 » 1. Translate q to origin
1 1 « »
«¬0 0 1 »¼
2. Rotate
x x
1 1
3. Translate back
From now on, we can represent points as have an A set of points can be used to create an affine frame.
additional coordinate of w=1. Consider a triangle ABC and a point P:
p(t ) po tu
The coordinates (D, E, J) are called the barycentric
Q: What does this describe? coordinates of P relative to A, B, and C.
Computing barycentric coordinates Cross products
In the triangle example: Consider the cross-product of two vectors, u and v.
What is the geometric interpretation of this cross-
product?
n
Thus, we find:
¦
i 1
Di 1
SArea( PBC ) SArea( APC ) SArea( ABP )
D E J
SArea( ABC ) SArea( ABC ) SArea( ABC ) Note that if the Di ‘s are all positive, the result is more
specifically called a convex combination.
Where SArea(RST) is the signed area of a triangle,
which can be computed with cross-products. Q: Why is it called a convex combination?
Basic 3-D transformations: scaling Translation in 3D
y y
x x
x x z z
z z
Rotation in 3D Shearing in 3D
Rotation now has more possibilities in 3D: Shearing is also more complicated. Here is one
example:
ª x 'º ª1 b 0 0º ª x º
ª1 0 0 0º
« y '» «0
«0 cosT sinT 0» 1 0 0» « y »
R x (T ) « » « » « »« »
«0 sinT cosT 0» «z ' » «0 0 1 0» « z »
« » y « » « »« »
¬0 0 0 1¼
¬1 ¼ ¬0 0 0 1¼ ¬1 ¼
ª cosT 0 sinT 0º Ry
« 0 1 0 0»
R y (T ) « »
« sinT 0 cosT 0» x
« » y
¬ 0 0 0 1¼ Rx y
Rz
ªcosT sinT 0 0º z
« sinT cosT 0 0»
Rz (T ) « » Use right hand rule
« 0 0 1 0» x
« » x
¬ 0 0 0 1¼
z z
Summary