computer graphics, chapter 4: 2d geometrical transformations
TRANSCRIPT
-
8/18/2019 Computer Graphics, Chapter 4: 2D Geometrical Transformations
1/29
COMPUTER GRAPHICS2D GEOMETRICAL TRANSFORMATIONS
Dr. Zeeshan Bhatti
BSIT-PIV
Chapter 4
Institute of Information and Communication TechnologyUniversity of Sindh, Jamshoro BY: DR. ZEE SHAN BHATT I 1Foley & Van Dam, Chapter 5
-
8/18/2019 Computer Graphics, Chapter 4: 2D Geometrical Transformations
2/29
2D GEOMETRICAL
TRANSFORMATIONS
• Translation
• Scaling
• Rotation
• Shear
• Matrix notation
• Compositions
• Homogeneous coordinates
-
8/18/2019 Computer Graphics, Chapter 4: 2D Geometrical Transformations
3/29
2D GEOMETRICAL
TRANSFORMATIONSAssumption: Objects consist of points and lines.
A point is represented by its Cartesian coordinates:
P = ( x, y)Geometrical Transformation:
Let (A, B) be a straight line segment between the points A and B.
Let T be a general 2D transformation.
T transforms (A, B) into another straight line segment
(A’, B’), where:
A’=TA and
B’=TB
-
8/18/2019 Computer Graphics, Chapter 4: 2D Geometrical Transformations
4/29
TRANSLATION
-
8/18/2019 Computer Graphics, Chapter 4: 2D Geometrical Transformations
5/29
SCALE
-
8/18/2019 Computer Graphics, Chapter 4: 2D Geometrical Transformations
6/29
SCALE
How can we scale an object without moving its origin (lower leftcorner)?
-
8/18/2019 Computer Graphics, Chapter 4: 2D Geometrical Transformations
7/29
REFLECTION
• Special case of scale
-
8/18/2019 Computer Graphics, Chapter 4: 2D Geometrical Transformations
8/29
ROTATION
• Rotate(θ): (x, y) → (x cos(θ)+y sin(θ), -x sin(θ)+y cos(θ))
-
8/18/2019 Computer Graphics, Chapter 4: 2D Geometrical Transformations
9/29
ROTATION
• How can we rotate an object without moving its origin (lower leftcorner)?
-
8/18/2019 Computer Graphics, Chapter 4: 2D Geometrical Transformations
10/29
SHEAR
• Shear (a, b): (x, y) → (x+ay, y+bx)
-
8/18/2019 Computer Graphics, Chapter 4: 2D Geometrical Transformations
11/29
CLASSES OF TRANSFORMATIONS
• Rigid transformation (distance preserving):
Translation + Rotation
• Similarity transformation (angle preserving):Translation + Rotation + Uniform Scale
• Affine transformation (parallelism preserving):
Translation + Rotation + Scale + Shear
All above transformations
are groups where
Rigid ⊂ Similarity ⊂ Affine
-
8/18/2019 Computer Graphics, Chapter 4: 2D Geometrical Transformations
12/29
MATRIX NOTATION
-
8/18/2019 Computer Graphics, Chapter 4: 2D Geometrical Transformations
13/29
2D TRANSFORMATIONS
• 2D object is represented by points and lines that jointhem
• Transformations can be applied only to the the pointsdefining the lines
• A point ( x, y) is represented by a 2x1 column vector, sowe can represent 2D transformations by using 2x2
matrices:
-
8/18/2019 Computer Graphics, Chapter 4: 2D Geometrical Transformations
14/29
TRANSLATIONTo translate a point with coordinate (x1, y1) to a new location usingdisplacements (dx, dy), following equations can be used:
x2 = x1 +dx and
y2 = y1+dy
Here (x2, y2) is the new coordinate of the point. The above equationcan be represented in matrix notation as:
22
=
+
11
This matric notation can be put as a vector addiction:
V2 = T +V1
Where
v1 =11
V2 =22
=
-
8/18/2019 Computer Graphics, Chapter 4: 2D Geometrical Transformations
15/29
PROBLEM: CONSIDER A POLYGON WITH FOLLOWINGVERTEX. TRANSLATE IT IN (5, 7)V1= (5,6), V2=(10, 6), V3=(7, 12) V4=(14, 15)
-
8/18/2019 Computer Graphics, Chapter 4: 2D Geometrical Transformations
16/29
SCALE
The size of an object can be changed by the scaling transformation.Objects can be scaled either the X or Y direction, or both of themsimultaneously, scaling by scale factors sx and sy along the X and Ydirections can be expressed mathematically as
x2 = sxx1 and
y2 = syy1
Here (x2, y2) is the new coordinate of the point. The above equation canbe represented in matrix notation as:
22
=
x11
This matric notation can be put as a vector addiction:
V2 = T x V1
Where
v1
=1
1V
2
=2
2 =
0
0
-
8/18/2019 Computer Graphics, Chapter 4: 2D Geometrical Transformations
17/29
Reflection < 0 > Decrease Size < 1 > Increase Size
(No Object/Size 0) (Same Size)
-
8/18/2019 Computer Graphics, Chapter 4: 2D Geometrical Transformations
18/29
Scale
• Scale (a, b): (x, y)
x
y
(ax,
by)
ax
by
a
0
0
b
•If a or b are negative, we get reflection
• Inverse: S-1(a,b) = S(1/a, 1/b)
-
8/18/2019 Computer Graphics, Chapter 4: 2D Geometrical Transformations
19/29
ROTATION
Rotation can be performed in ananticlockwise or a clockwise direction.
The axis of rotation may be X-axis or Y-axisor any arbitrary line on the X-Y plane.
Rotations are performed about some fixedpoint called pivot point or centre of rotationor anchor point.
Rotations are measured by angulardisplacements, we measure coordinate valuein term of the radius of rotation and angleof rotation, i.e. polar coordinates.
-
8/18/2019 Computer Graphics, Chapter 4: 2D Geometrical Transformations
20/29
Rotation• Rotate((x, y)
(x cos()+y
sin(), -x sin()+y cos())
cos sin
cos
x x cos y sin
x sin y cos sin y
• Inverse: R-1(q) = RT(q) = R(-q)
-
8/18/2019 Computer Graphics, Chapter 4: 2D Geometrical Transformations
21/29
Shear
• Shear (a, b): (x, y) (x+ay, y+bx)
1
b
a
1
x
y
x
y
ay
bx
-
8/18/2019 Computer Graphics, Chapter 4: 2D Geometrical Transformations
22/29
Reflection• Reflection through the
1
0
the
y axis:
01
through
• Reflection x axis:
10
01
• Reflection through
y = x :
1
0-x :
0 1 • Reflection through y =
1
0
0
1
-
8/18/2019 Computer Graphics, Chapter 4: 2D Geometrical Transformations
23/29
Composition of Transformations
• A sequence of transformationscollapsed into a single matrix:
can be
x
y
x
y
A B C
D
•Note: Order of transformations is important!
translate rotate
rotate translate
-
8/18/2019 Computer Graphics, Chapter 4: 2D Geometrical Transformations
24/29
Translation
• Translation (a, b):
x
y
x
y
a
b
Problem: Cannot represent translationusing 2x2 matrices
Solution:Homogeneous Coordinates
-
8/18/2019 Computer Graphics, Chapter 4: 2D Geometrical Transformations
25/29
Homogeneous Coordinates
Rn
, Y R
n+1
:Is a mapping from( X
to y ) ,W ) ( x , ( tx , ty , t )
Note:same
All triples (tx, ty, t ) correspond to the
non-homogeneous point ( x, y )
Example (2, 3, 1) (6, 9, 3).
Inverse mapping:
X Y ) ( X , Y , W ,
W W
-
8/18/2019 Computer Graphics, Chapter 4: 2D Geometrical Transformations
26/29
TRANSLATION
-
8/18/2019 Computer Graphics, Chapter 4: 2D Geometrical Transformations
27/29
-
8/18/2019 Computer Graphics, Chapter 4: 2D Geometrical Transformations
28/29
SHEAR
-
8/18/2019 Computer Graphics, Chapter 4: 2D Geometrical Transformations
29/29
THANKYOU
Q & A
BY: DR ZEE SHAN BHATT I 29
Referred Book
Computer Graphics: Principles and Practice in C,by J. D. Foley, A. Van Dam, S. K. Feiner, J. F. Hughes.Hardcover, 1200 pages, Addison-Wesley Pub Co; 2nd edition,
For Course Slides and Handouts
web page:https://sites.google.com/site/drzeeshanacademy/
Blog:http://zeeshanacademy.blogspot.com/
Facebook:https://www.facebook.com/drzeeshanacademy
https://sites.google.com/site/drzeeshanacademy/http://zeeshanacademy.blogspot.com/http://zeeshanacademy.blogspot.com/https://sites.google.com/site/drzeeshanacademy/