Affine Transformation - PowerPoint PPT Presentation

1 / 44
About This Presentation
Title:

Affine Transformation

Description:

A(BC) = (AB)C. Identity Matrix. Set of matrices that when they multiply another matrix ... Exercises. Find the transformed point Q caused by rotating P = ( 5, 8) ... – PowerPoint PPT presentation

Number of Views:774
Avg rating:3.0/5.0
Slides: 45
Provided by: Eza5
Category:

less

Transcript and Presenter's Notes

Title: Affine Transformation


1
Affine Transformation
  • Chapter 5 in Hill
  • Chapter 5 in Hearn
  • Chapter 4 in Angle

2
So far.
We have been discussing the basic elements of
geometric programming. We have discussed points,
vectors and their operations and coordinate
frames and how to change the representation of
points and vectors from one frame to
another. Next topic involves how to map points
from one place to another (transformation). i.e.
if we want to draw an animation of spinning
ball. How would we define the function that maps
each point on the ball to its position rotated
through some given angle?
3
Affine Transformation
  • In this topic, we will concentrate on one
    particular transformation
  • called affine transformations. Examples of affine
    transformations
  • are
  • translations
  • rotations
  • Uniform and nonuniform scalings
  • reflections (flipping objects about a line)
  • shearing ( which deform squares into
    parallelogram)

4
Affine Transformation (cont.)
Figure 1 Examples of affine transformation
5
Example
Figure 2 Transformation in 2-D and 3-D
6
Characteristics
  • These transformations all have a number of things
    in common.
  • They all map lines to lines ( parallel lines will
    still be parallel
  • after the transformations)
  • Translation, rotation and reflection preserve the
    lengths of
  • line segments and the angles between segments
  • Uniform scaling preserve angles but not length
  • Non-uniform scaling and shearing do not preserve
    angles or
  • lengths

7
Usage
Transformations are useful in a number of
situations 1. We can compose a scene out a
number of objects
8
Usage (cont.)

9
Usage (cont.)
2. Can design a single motif and manipulate the
motif to produce the whole shape of an object
especially if the object has certain symmetries.
Example of snowflake after reflections, rotations
and translations of the motif
10
Usage (cont.)
3. To view an object from a different angle
11
Usage (cont.)
4. To produce animation
12
Affine Transformation
  • The two special types of affine transformation
    are
  • Rigid transformation These transformations
    preserve both
  • angles and lengths (I.e. translations, rotations
    and reflections)
  • 2. Orthogonal transformation These
    transformations preserve
  • angles but not necessarily length.

13
Affine Transformation (why?)
  • The most common transformations used in computer
  • graphics.
  • They simplify operations to scale, rotate and
  • reposition objects.
  • Several affine transformations can be combined
    into a simple
  • overall affine transformation in terms of a
    compact matrix
  • representation

14
Transformation Matrix (2-D)
For a point P that map to Q after affine
transformation has a matrix representation as
shown
NB the third of the resultant matrix will always
be 1 for a point
15
Transformation Matrix (2-D)
For a vector V that maps to W after affine
transformation has the matrix representation as
shown
NB the third row of the resultant matrix will
always be 0 for a vector
16
Transformation Matrix
The scalar m that we have in the transformation
matrix will determine which affine transformation
that we want to perform.
17
OpenGL graphics pipeline
Normally in OpenGL, many transformation processes
occur before the final objects are displayed on
the screen. Basically the object that we define
in our world will go through the same Procedure.
18
Transformations
  • Transformations changes in size, shape and
    orientation that
  • alter the coordinate descriptions of objects.
  • Usually, transformations are represented and
    calculated using
  • matrices.
  • OpenGL also uses the same approach to perform
    transformations
  • Lets look in detail at each of the
    transformations listed earlier..

19
Sine and Cosine
Recall our algebra lesson!!
c
b
a
Sin b/c if c 1 then b sin Cos
a/c if c 1 then c cos
20
Sine and Cosine (cont.)
90
z
y
0
180
x
-
270
21
Sine and Cosine (cont.)
Cos x/z if z 1 then cos x Sin
y/z if z 1 then sin y Cos (- )
x/z cos Sin (- ) -y/z -sin Cos (
) cos cos - sin sin
Sin ( ) sin cos cos sin
22
Matrices
In graphics most of the time matrix operation
that we will deal with is matrix multiplication.
The formula for multiplication of matrix A with m
x p dimension and matrix B with p x n
dimension is
where
23
Example
24
Characteristics of Matrix
Multiplication of matrices is not
commutative AB ! BA Multiplication of several
matrices is associative A(BC) (AB)C
25
Identity Matrix
Set of matrices that when they multiply another
matrix which reproduce that matrix is called
identity matrices I.e
1D 2D 3D 4D
26
Object Transformation vs Coordinate Transformation
Object Transformation alters the coordinates of
each point on the object according to some rule.
No change of coordinate system Coordinate
Transformation defines a new coordinate system
in terms of the old one and then represents all
of the objects point in the new coordinate system
27
Translation
  • Reposition an object along a straight line path
    from one
  • coordinate location to another
  • 2D point is translated by adding translation
    distances to
  • the x and y coordinates
  • When translating (x,y) to (x,y) by value t
  • x x tx
  • y y ty

28
Translation (cont.)
The (tx,ty) is the translation distances called
TRANSLATION VECTOR In matrix form
Then point P P T
29
Translation (cont.)
For 2-D translation the transformation matrix T
has the following form
T
Where mx and my are the translation values in x
and y axis
30
Translation (cont.)
For 3-D translation the transformation matrix T
has the following form
T
Where mx, my and mz are the translation values in
x, y and z axis
31
Translation (cont.)
  • Translation is a rigid body transformation
  • the object is not being deformed
  • all points are moved in the same distance
  • How to translate?
  • straight lines based on end points
  • polygons - based on vertices
  • Circles - based on centre

32
Rotations
  • Reposition an object along a circular path in a
    specified
  • Plane
  • Rotations are specified by
  • a rotation angle
  • a rotation point (pivot point) at position (x,y)
  • Positive rotation angle means rotate
    counter-clockwise
  • negative rotation angle means rotate clockwise

33
Rotations (cont.)
(x,y)
r
(x,y)
r
The original point (x,y) can be represented in
polar coordinates form x r cos (1) y r
sin (2)
34
Rotations (cont.)
The new point (x,y) can be expressed as x r
cos ( ) y r sin ( )
These equation can be written as x r cos
cos - r sin sin y r cos sin r
sin cos
35
Rotations (cont.)
Substituting the equations with equation (1) and
(2), we get x x cos - y sin y
x sin y cos
Therefore, the rotation matrix R can be expressed
as
R
36
Rotations (cont.)
For 2-D rotation the transformation matrix R has
the following Form (in homogeneous coordinate
system)
NB for counter-clockwise rotation
37
Rotations (cont.)
In 3-D world, the rotation is more complex since
we have to Consider rotation about three
different axis x, y and z axis. Therefore we
have three different transformation matrices
in 3-D world.
Rz( )
Rotation about z-axis (ccw)
38
Rotations (cont.)
Rx( )
Rotation about x-axis (ccw)
Ry( )
Rotation about y-axis (ccw)
39
Rotations (cont.)
This rotation matrix is for case where the
rotation is at the origin. For a rotation at any
other points, we need to perform the following
transformations 1. Translating the object so
the rotation point is at the origin. 2.
Rotating the object around the origin 3.
Translating the object back to its original
position Recall that rotation is a rigid affine
transformation
40
Scaling
  • Scaling changes the size of an object
  • Scaling can also reposition the object but not
    always
  • Uniform scaling is performed relative to some
    central fixed
  • point (I.e at the origin). The scaling value
    (scale factor) for
  • uniform scaling must be both equal.
  • Non-uniform scaling has different scaling
    factors. Also refers
  • as differential scaling

41
Scaling (cont.)
  • The value of the scale factors (Sx, Sy, Sz)
    determine the
  • size of the scaled object.
  • if equal to 1 -gt no changes
  • if greater than 1 -gt increase in size
    (magnification)
  • if 0 lt scale factors lt 1 -gt decrease in size
  • (demagnification)
  • if negative value -gt reflection !!!

42
Scaling (cont.)
For 2-D scaling the transformation matrix S will
have the following form
S
43
Scaling (cont.)
For 3-D scaling the transformation matrix S has
the following form
S
44
Exercises
Find the transformed point Q caused by rotating P
( 5, 8) about the origin through an angle 60
degree (CCW) What is the transformed point Q of
the same point P if we rotate about point M
(1,2)? Given a vector v (2, 4, 6), find the
transformed vector w caused by scaling based on
these scale factors (2, 3, 5). Show that if
scale factors are negative, we get reflection.
Use any point and sketch the result in a
coordinate frame.
NB cos (60) 0.5 and sin (60) 0.866
Write a Comment
User Comments (0)
About PowerShow.com