Professional Documents
Culture Documents
Lecture 5: Transformation: COMP 206: Computer Graphics
Lecture 5: Transformation: COMP 206: Computer Graphics
Lecture 5: Transformation
ENG:- Ibraheem alhejri 2013
Transformation
Definition
.
The operation of changing one configuration
or expression into another in accordance with
a mathematical rule .
Transformation
Scaling
.
The most basic transformation is a scale
.
This transformation can change length and
possibly the direction
(x , y)
Note what this does to a vector with
Cartesian components (x , y)
x = x * sx
y = y * sy
Transformation
2D Scaling
Y
sx 3
sy 2
6
5
Side effect:
House shifts
position
relative to
origin
4
3
2
2
1
6
2
3
1
9
2
0
1
v = Sv
where
x
x'
,
v
'
y '
y
v
and
sx 0
S
0
s
y
10
x' s x x
y' s y y
Transformation
Uniform Scaling
For example the matrix that shrinks
x and y uniformly by a factor of two
Sx=Sy
Transformation
Non-Uniform Scaling
A matrix which halves the
horizontal and increases to threehalves in the vertical
:-Note
scaling factor <1 minimizing
normal
scaling factor =1
scaling factor >1 enlarging
Transformation
2D Shearing
.
A shear is something that pushes
things sideways
Transformation
2D Shearing
The horizontal shear matrix is
x = x + hx*y
The vertical shear matrix is
y = y + hy*x
Transformation
2D Shearing
Transformation
2D Translation
Y
5
6
6
5
dx = 2
dy = 3
3
3
3
2
1
0
v = v + t
and
where
10
x
x'
dx
,
v
'
,
t
y '
dy
y
x = x + dx
y = y + dy
To move polygons: translate vertices (vectors)
and redraw lines between them
Transformation
2D Rotation
Side effect:
House shifts
position
relative to
origin
x an angle
x'
v = R v
where
,
v
'
y '
y
sin
sin
cos
cos
Transformation
2D Rotation
For example , a matrix that rotates
vectors by 45 counter clockwise is
represented as
Transformation
2D Rotation
A matrix rotates 30 in the clockwise
direction is represented as
Transformation
3D Rotation
Rotate around X-axis
y = y cos() - z sin()
z = y sin() + z cos()
x=x
Rotate around Y-axis
x = x cos() + z sin()
z = -x sin() + z cos()
y=y
OR
z = z cos() - x sin()
x = z sin() + x cos()
y=y
Rotate around Z-axis
x = x cos() - y sin()
y = x sin() + y cos()
z=z
Transformation
2D Reflection
We can also reflect a vector around
the x-axis using the following
3D Reflection
Transformation
2D Reflection
Similarly, reflecting about y-axis
3D Reflection
Transformation
2D Rotation and Scale are Relative to Origin
,
.
:
, .
Transformation
*Additional
3x3matrix
4x4 matrix
Transformation
*Additional
4x4 matrix