Download Linear and affine transformations

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Linear and affine transformations
•
Linear Algebra Review
 Matrices
 Transformations
Affine transformations in Euclidean space
•
1

The linear transformation given by a matrix
Let A be an mn matrix. The function T defined by
T ( v)  Av
is a linear transformation from Rn into Rm.

Note:
R n vector
 a11
a
Av   21


 am 1
a12
a22
am 2
R m vector
a1n   v1   a11v1  a12v2 
a2 n   v2   a21v1  a22v2 

  
  
amn   vn   am 1v1  am 2v2 
 a1nvn 
 a2 nv n 


 amn vn 
T ( v)  Av
T : Rn 
 R m
6-2
1

Two representations of the linear transformation
T:R3→R3 :
(1)T ( x1 , x2 , x3 )  (2 x1  x2  x3 , x1  3x2  2 x3 ,3x2  4 x3 )
 2 1  1  x1 
(2)T (x)  Ax   1 3  2  x2 

 
 0 3 4   x3 

Three reasons for matrix representation of a linear
transformation:

It is simpler to write.

It is simpler to read.

It is more easily adapted for computer use.
Geometric transformations
•
•
•
•
Geometric transformations map points in one space to points in
another: (x',y',z') = f(x,y,z), i.e. in vector form X’ = f(X)
These transformations can be very simple, such as scaling each
coordinate, or complex, such as non-linear twists and bends.
We'll focus on transformations that can be represented easily with
matrix operations.
We'll start in 2D...
2
Representation of 2D linear map
• We can represent a 2-D transformation M by a matrix
a b
M  

c d
• If x is a column vector, M goes on the left: x '  Mx
 x  a b   x 
 y    c d   y 
  
  

• If x is a row vector, MT goes on the right: x  xM
 x
y    x
• We will use column vectors.
T
a c 
y 

b d 
Basic 2D Linear Transforms
Base vectors map to columns of matrix.
x '  Mx
x  M x
 a b   x   ax  by 
M x
   

 c d   y   cx  dy 
 a b  1   a 
 c d  0   c 

   
 x  a b   x 
 y    c d   y 
  
  
 a b   0  b 
 c d  1   d 

   
(1, 0)
6
3
x  M x
Scaling by 0.5
y
y
M
0.5 0 
 0 0.5


x
x
November 7, 2016
7
General Scaling
x  scale(sx , s y ) x
y
y
scale  s x , s y  
1
 sx
0

x
1
November 7, 2016
sy
0
s y 
x
sx
8
4
Rotation x  rot ( ) x
rot   
y
y
cos    sin   


 sin   cos   

x
x
November 7, 2016
9
Reflection in y-axis x  ref y x
y
ref y 
y
 1 0 
 0 1


x
November 7, 2016
x
10
5
Reflection in x-axis x  ref x x
y
y
ref x 
1 0 
0 1


x
x
November 7, 2016
Shear-x
11
x  M x
y
y
1 s 
 0 1


x
November 7, 2016
x
12
6
Shear-y
x  M x
y
y
1 0 
 s 1


x
x
November 7, 2016
13
Composing Linear Transformations
T1 ( v)  M1  v
• If T1 and T2 are transformations
T2 ( v)  M 2  v
 T2 T1(v) =def T2( T1(v))
• If T1 and T2 are represented by matrices M1 and M2
 T2 T1 is represented by M2 M1
 T2 T1(v) = T2( T1(v)) = (M2 M1)(v)
• Order is important!
reflect(x) (rot(O,𝛂)): A → A’ → A’’
rot(O,𝛂) (reflect(x)): A → A → A’
A '  Rot  A
A ''  Ref  A '
14
7
Composing Linear Transformations
• Order is important!
reflect(x) (rot(O,𝛂)): A → A’ → A’’
rot(O,𝛂) (reflect(x)): A → A → A’
A '  Rot  A
A ''  Ref  A '
 cos   sin  
1 0 
Rot  
;
Ref




 sin  cos  
 0 1
 cos  sin  
Rot*Ref  

 sin   cos  
 cos   sin  
Ref*Rot  

  sin   cos  
15
Decomposing Linear Transformations
•
Any 2D Linear Transformation can be decomposed into the product
of a rotation, a scale (or line reflection), and a rotation
M = R1SR2 .
•
Any 2D Linear Transformation can be decomposed into the product
of 3 line reflection at the most.
Isometry (congruent transformation)
•
•
•
Isometry preserves length, whereas direct isometry preserves
orientation and opposite does not preserve orientation
Direct Isometry |R| = 1 (Rotation)
Opposite Isometry |R| = -1 (Line Reflection)
November 7, 2016
16
8
Reflection About an
Arbitrary Line (through the origin)
y
y
x
x
November 7, 2016
17
Reflection as a Composition
xF  ref  x F new base xB = B  x  x = B -1  x B
y
B-1 xB = ref  B-1 xB
xB = B  ref  B-1 xB
B  e1 , e2
y
F  f1 ,f 2
f1
x
f2
x
9
Linear Transformations
•
•
•
•
Scale, Reflection, Rotation, and Shear are all linear transformations
They satisfy: T(au + bv) = aT(u) + bT(v)
 u and v are vectors
 a and b are scalars
If T is a linear transformation
 T((0, 0)) = (0, 0)
Q: What important operation does that leave out?
19
Rotation about
an Arbitrary Point
y
y


x
x
This is not a linear transformation. The origin moves.
November 7, 2016
20
10
Translation
(x, y)(x+a,y+b)
y
y
(a, b)
x
x
This is not a linear transformation. The origin moves.
November 7, 2016
21
2D Linear Transformations
as 3D Matrices
Any 2D linear transformation can be
represented by a 2x2 matrix
 a11 a12   x   a11 x  a12 y 
a
  y   a x  a y 
a
22 
 21 22     21
or a 3x3 matrix
 a11 a12
a
a
 21 22
0
 0
November 7, 2016
0  x   a11 x  a12 y 
0  y    a21 x  a22 y 
  

1  1  
1

22
11
2D Linear Translations
as 3D Matrices
Any 2D translation can be represented by a 3x3 matrix.
1 0 a   x   x  a 
0 1 b   y    y  b 

  

0 0 1   1   1 
With homogeneous coordinates, we can represent all 2D
affine transformations as 3D linear transformations.
We can then use matrix multiplication to transform objects.
23
2D Affine Transformations
• An affine transformation is any transformation
that preserves co-linearity (i.e., all points lying on
a line initially still lie on a line after
transformation) and ratios of distances (e.g., the
midpoint of a line segment remains the midpoint
after transformation).
24
12
Rotation about
an Arbitrary Point
T(cx, cy) R()T(-cx, -cy)
y
y


x
x
November 7, 2016
25
Windowing Transforms
(A,B)
(a,b)
translate
(A-a,B-b)
scale
(C,D)
(C-c,D-d)
translate (c,d)
November 7, 2016
26
13
3D Transformations
Remember:
 x
 x
 
 y   y
 
z
 z 
 
1
A 3D linear transformation can be represented by a
3x3 matrix.
 a11 a12
a
a
 21 22
 a31 a32
 a11 a12
a13 
a
a

a23   21 22

 a31 a32
a33 

0
0
a13
a22
a33
0
0
0

0

1
November 7, 2016
27
3D Affine Transformations
 sx
0
scale  sx , s y , sz   
0

0
1
0
translate  t x , t y , tz   
0

0
0
0
sy
0
0
sz
0
0
0
0

0

1
0 0 tx 
1 0 ty 

0 1 tz 

0 0 1
28
14
3D Rotations
0
0
1
0 cos    sin  
rotate x    
0 sin   cos  

0
0
0
cos    sin  

sin   cos  
rotatez    
 0
0

0
 0
0
0

0

1
 cos  

0
rotate y    
  sin  

 0
0 0

0 0
1 0

0 1
0 sin  
1
0
0 cos  
0
0
0

0
0

1
29
15
Related documents