rotation, reflection, shear, scale, translation
TRANSCRIPT
![Page 1: Rotation, Reflection, Shear, Scale, Translation](https://reader031.vdocument.in/reader031/viewer/2022021307/62074fcb49d709492c302a4b/html5/thumbnails/1.jpg)
2D Geometrical TransformationsFoley & Van Dam, Chapter 5
![Page 2: Rotation, Reflection, Shear, Scale, Translation](https://reader031.vdocument.in/reader031/viewer/2022021307/62074fcb49d709492c302a4b/html5/thumbnails/2.jpg)
2D Geometrical Transformations
• Translation• Scaling• Rotation • Shear• Matrix notation• Compositions• Homogeneous coordinates
![Page 3: Rotation, Reflection, Shear, Scale, Translation](https://reader031.vdocument.in/reader031/viewer/2022021307/62074fcb49d709492c302a4b/html5/thumbnails/3.jpg)
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
![Page 4: Rotation, Reflection, Shear, Scale, Translation](https://reader031.vdocument.in/reader031/viewer/2022021307/62074fcb49d709492c302a4b/html5/thumbnails/4.jpg)
Translation
• Translate(a, b): (x, y) → (x+a, y+b)
Translate(2, 4)
![Page 5: Rotation, Reflection, Shear, Scale, Translation](https://reader031.vdocument.in/reader031/viewer/2022021307/62074fcb49d709492c302a4b/html5/thumbnails/5.jpg)
Scale
• Scale (a, b): (x, y) → (ax, by)
Scale (2, 3)
Scale (2, 3)
![Page 6: Rotation, Reflection, Shear, Scale, Translation](https://reader031.vdocument.in/reader031/viewer/2022021307/62074fcb49d709492c302a4b/html5/thumbnails/6.jpg)
Scale• How can we scale an object without moving its origin (lower left corner)?
Translate(-1,-1)
Translate(1,1) Scale(2,3)
![Page 7: Rotation, Reflection, Shear, Scale, Translation](https://reader031.vdocument.in/reader031/viewer/2022021307/62074fcb49d709492c302a4b/html5/thumbnails/7.jpg)
Reflection
• Special case of scale
Scale(-1,1)
Scale(1,-1)
![Page 8: Rotation, Reflection, Shear, Scale, Translation](https://reader031.vdocument.in/reader031/viewer/2022021307/62074fcb49d709492c302a4b/html5/thumbnails/8.jpg)
Rotation• Rotate(θ):(x, y) → (x cos(θ)+y sin(θ), -x sin(θ)+y cos(θ))
Rotate(90)
Rotate(90)
![Page 9: Rotation, Reflection, Shear, Scale, Translation](https://reader031.vdocument.in/reader031/viewer/2022021307/62074fcb49d709492c302a4b/html5/thumbnails/9.jpg)
Rotation• How can we rotate an object without moving its origin (lower left corner)?
Translate(-1,-1)
Translate(1,1)Rotate(90)
![Page 10: Rotation, Reflection, Shear, Scale, Translation](https://reader031.vdocument.in/reader031/viewer/2022021307/62074fcb49d709492c302a4b/html5/thumbnails/10.jpg)
Shear• Shear (a, b): (x, y) → (x+ay, y+bx)
Shear(1,0)
Shear(0,2)
![Page 11: Rotation, Reflection, Shear, Scale, Translation](https://reader031.vdocument.in/reader031/viewer/2022021307/62074fcb49d709492c302a4b/html5/thumbnails/11.jpg)
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 Rigid
Affine
Similarity
![Page 12: Rotation, Reflection, Shear, Scale, Translation](https://reader031.vdocument.in/reader031/viewer/2022021307/62074fcb49d709492c302a4b/html5/thumbnails/12.jpg)
Matrix Notation• Let’s treat a point (x, y) as a 2x1 matrix (column vector):
• What happens when this vector is multiplied by a 2x2 matrix?
yx
++
=
dycxbyax
yx
dcba
![Page 13: Rotation, Reflection, Shear, Scale, Translation](https://reader031.vdocument.in/reader031/viewer/2022021307/62074fcb49d709492c302a4b/html5/thumbnails/13.jpg)
2D Transformations• 2D object is represented by points and lines that join them
• Transformations can be applied only to the thepoints defining the lines
• A point (x, y) is represented by a 2x1 column vector, so we can represent 2D transformations by using 2x2 matrices:
=
yx
dcba
yx''
![Page 14: Rotation, Reflection, Shear, Scale, Translation](https://reader031.vdocument.in/reader031/viewer/2022021307/62074fcb49d709492c302a4b/html5/thumbnails/14.jpg)
Scale
• Scale (a, b): (x, y) → (ax, by)
•If a or b are negative, we get reflection
• Inverse: S-1(a,b) = S(1/a, 1/b)
=
byax
yx
ba0
0
![Page 15: Rotation, Reflection, Shear, Scale, Translation](https://reader031.vdocument.in/reader031/viewer/2022021307/62074fcb49d709492c302a4b/html5/thumbnails/15.jpg)
Reflection• Reflection through the y axis:
• Reflection through the x axis:
• Reflection through y = x:
• Reflection through y = -x:
−1001
− 1001
0110
−
−0110
![Page 16: Rotation, Reflection, Shear, Scale, Translation](https://reader031.vdocument.in/reader031/viewer/2022021307/62074fcb49d709492c302a4b/html5/thumbnails/16.jpg)
Shear• Shear (a, b): (x, y) → (x+ay, y+bx)
++
=
bxyayx
yx
ba1
1
![Page 17: Rotation, Reflection, Shear, Scale, Translation](https://reader031.vdocument.in/reader031/viewer/2022021307/62074fcb49d709492c302a4b/html5/thumbnails/17.jpg)
Rotation• Rotate(θ):(x, y) → (x cos(θ)+y sin(θ), -x sin(θ)+y cos(θ))
• Inverse: R-1(q) = RT(q) = R(-q)
+−+
=
− θθ
θθθθθθ
cossinsincos
cossinsincos
yxyx
yx
![Page 18: Rotation, Reflection, Shear, Scale, Translation](https://reader031.vdocument.in/reader031/viewer/2022021307/62074fcb49d709492c302a4b/html5/thumbnails/18.jpg)
Composition of Transformations• A sequence of transformations can be collapsed into a single matrix:
•Note: Order of transformations is important!
[ ][ ][ ] [ ]
=
yx
Dyx
CBA
translate rotate
rotate translate
![Page 19: Rotation, Reflection, Shear, Scale, Translation](https://reader031.vdocument.in/reader031/viewer/2022021307/62074fcb49d709492c302a4b/html5/thumbnails/19.jpg)
Translation
• Translation (a, b):
Problem: Cannot represent translation using 2x2 matrices
Solution:Homogeneous Coordinates
++
→
byax
yx
![Page 20: Rotation, Reflection, Shear, Scale, Translation](https://reader031.vdocument.in/reader031/viewer/2022021307/62074fcb49d709492c302a4b/html5/thumbnails/20.jpg)
Homogeneous CoordinatesIs a mapping from Rn to Rn+1:
Note: All triples (tx, ty, t) correspond to the same non-homogeneous point (x, y)Example (2, 3, 1) ≡ (6, 9, 3).
Inverse mapping:
),,(),,(),( ttytxWYXyx =→
→
WY
WXWYX ,),,(
![Page 21: Rotation, Reflection, Shear, Scale, Translation](https://reader031.vdocument.in/reader031/viewer/2022021307/62074fcb49d709492c302a4b/html5/thumbnails/21.jpg)
Translation
• Translate(a, b):
Inverse: T-1(a, b) = T(-a, -b)Affine transformations now have the following form:
++
=
111001001
byax
yx
ba
100fdceba
![Page 22: Rotation, Reflection, Shear, Scale, Translation](https://reader031.vdocument.in/reader031/viewer/2022021307/62074fcb49d709492c302a4b/html5/thumbnails/22.jpg)
Geometric InterpretationA 2D point is mapped to a line (ray) in 3D The non-homogeneous points are obtained by projecting the rays onto the plane Z=1
(X,Y,W)
yx
X
Y
W
1
(X,Y,1)
![Page 23: Rotation, Reflection, Shear, Scale, Translation](https://reader031.vdocument.in/reader031/viewer/2022021307/62074fcb49d709492c302a4b/html5/thumbnails/23.jpg)
ExampleRotation about an arbitrary point
1. Translate the coordinates so that the origin is at (x0,y0)2. Rotate by θ3. Translate back
(x0,y0)
θ
−−+−−
=
=
−−
−
1100sin)cos1(cossinsin)cos1(sincos
11001001
1000cossin0sincos
1001001
00
00
0
0
0
0
yx
xyyx
yx
yx
yx
θθθθθθθθ
θθθθ
![Page 24: Rotation, Reflection, Shear, Scale, Translation](https://reader031.vdocument.in/reader031/viewer/2022021307/62074fcb49d709492c302a4b/html5/thumbnails/24.jpg)
ExampleReflection about an arbitrary line
1.Translate the coordinates so that P1 is at the origin
2.Rotate so that L aligns with the x-axis3.Reflect about the x-axis4.Rotate back5.Translate back
p1
p2
L = p1 + t (p2-p1) = t p2 + (1-t) p1
![Page 25: Rotation, Reflection, Shear, Scale, Translation](https://reader031.vdocument.in/reader031/viewer/2022021307/62074fcb49d709492c302a4b/html5/thumbnails/25.jpg)
Change of CoordinatesIt is often required to transform the description of an object from one coordinate system to another
Rule: Transform one coordinate frame towards the other in the opposite direction of the representation change
x
y
x’y’Representation
Transformation
![Page 26: Rotation, Reflection, Shear, Scale, Translation](https://reader031.vdocument.in/reader031/viewer/2022021307/62074fcb49d709492c302a4b/html5/thumbnails/26.jpg)
Example• Change of coordinates: Represent P = (xp, yp, 1) in the (x’, y’) coordinate system
Where:
MPP ='
−−
−=
1001001
1000cossin0sincos
0
0
yx
M θθθθ
x
yx’y’
θ
(x0, y0)(xp, yp)
![Page 27: Rotation, Reflection, Shear, Scale, Translation](https://reader031.vdocument.in/reader031/viewer/2022021307/62074fcb49d709492c302a4b/html5/thumbnails/27.jpg)
Example• Change of coordinates:Alternative method: assume x’ = (ux, uy) and y’ = (vx, vy) in the (x, y) coordinate system
where MPP ='
−−
=
1001001
10000
0
0
yx
vvuu
M yx
yx
x
y x’y’
(x0, y0)(ux, uy)(vx, vy)
![Page 28: Rotation, Reflection, Shear, Scale, Translation](https://reader031.vdocument.in/reader031/viewer/2022021307/62074fcb49d709492c302a4b/html5/thumbnails/28.jpg)
ExampleReflection about an arbitrary line
Define a coordinate systems (u, v) parallel to P1P2:
p1
p2
L = p1 + t (p2-p1) = t p2 + (1-t) p1
≡
−−
=y
xuu
pppp
12
12u
=
−=
y
x
x
yvv
uuv
−−
−
=
1001001
10000
100010001
10000
1001001
1
1
1
1
y
x
y
x
pp
vvuu
vuvu
pp
M yx
yx
yy
xx
![Page 29: Rotation, Reflection, Shear, Scale, Translation](https://reader031.vdocument.in/reader031/viewer/2022021307/62074fcb49d709492c302a4b/html5/thumbnails/29.jpg)
3D Viewing Transformation Pipeline
Device Coordinates
Viewport
World Coordinates Object in World
Viewing coordinates
2D:2D mapping
3D:2D mapping
![Page 30: Rotation, Reflection, Shear, Scale, Translation](https://reader031.vdocument.in/reader031/viewer/2022021307/62074fcb49d709492c302a4b/html5/thumbnails/30.jpg)
World to Viewing CoordinatesIn order to define the viewing window we have to specify:
•Windowing-coordinate origin P0 = (x0,y0)•View vector up v = (vx,vy)
•Using v, we can find u: u = v x (0,0,1)
Transformation from world to viewing coordinates :
−−
=−
1001001
10000
0
0yx
vvuu
M yx
yx
vcwc
x world
y worldx view
y view
(x0,y0)
(vx,vy).
(ux,uy).
![Page 31: Rotation, Reflection, Shear, Scale, Translation](https://reader031.vdocument.in/reader031/viewer/2022021307/62074fcb49d709492c302a4b/html5/thumbnails/31.jpg)
Window to Viewport Coordinates
(xmin,ymin)
(xmax,ymax)
Window is Viewing Coordinates Window translated to origin
Window scaled to Normalized Viewport size
Window scaled and translated to Viewport location in device coordinates
(umin,vmin)
(umaxn,vmaxn)
Normalized Device Coordinates
−−
−
−
−
−
=−
1001001
100
010
001
1000000
1001001
min
min
minmax
minmax
minmax
minmax
min
min
yx
yy
xxvv
uuvu
M dcvc
![Page 32: Rotation, Reflection, Shear, Scale, Translation](https://reader031.vdocument.in/reader031/viewer/2022021307/62074fcb49d709492c302a4b/html5/thumbnails/32.jpg)
Efficiency ConsiderationsA 2D point transformation requires 9 multiplies and 6 adds
But since affine transformations have always the form:
The number of operations can be reduced to 4 multiplies and 4 adds
a b c x a x b y c zd e f y d x e y f zg h i z g x h y i z
+ + = + + + +
0 0 1 1 1
a b c x a x b y cd e f y d x e y f
+ + = + +
![Page 33: Rotation, Reflection, Shear, Scale, Translation](https://reader031.vdocument.in/reader031/viewer/2022021307/62074fcb49d709492c302a4b/html5/thumbnails/33.jpg)
Efficiency ConsiderationsThe rotation matrix is:
When rotating of small angles θ, we can use the fact that cos(θ) ≅ 1 and simplify
+−+
=
− θθ
θθθθθθ
cossinsincos
cossinsincos
yxyx
yx
1 sin sinsin 1 sin
x x yy x y
θ θθ θ
+ = − − +
![Page 34: Rotation, Reflection, Shear, Scale, Translation](https://reader031.vdocument.in/reader031/viewer/2022021307/62074fcb49d709492c302a4b/html5/thumbnails/34.jpg)
Determinant of a Matrix
If P is a polygon of area AP, transformed by a matrix M, the area of the transformed polygon is AP∗|M|
a bad bc
c d= −
a b cd e f aei bfg cdh ceg afh bdig h i
e f d f d ea b ch i g i g h
= + + − − −
= − +