M3 Transformations
M3 Transformations
Transformations
Stuff
INTRODUCTION TO COMPUTER GRAPHIC S
What is 2D Transformation
in Computer Graphics?
• Transformation means a change in the object's
orientation, size, and shape. They position the object,
change its shape, and even change how something is
viewed.
• Transformation plays a major role in computer
graphics, repositioning the graphics on the screen and
changing their size or orientation.
• The basic geometrical 2D Transformation
in Computer Graphics are:
• Translation
• Rotation
• Scaling
• The derivedStuff
geometrical transformation is:
• Reflection
• Shearing
INTRODUCTION TO COMPUTER GRAPHIC S
ROBOT transformation
stanchion base
Stuff Scenegraph
(see Sceneview assignment)
INTRODUCTION TO COMPUTER GRAPHIC S
triangle square
rectangle
Circles
• Consist of all points equidistant from one
predetermined point (the center)
• (radius) r = c, where c is a constant
P1
r y
r
StuffP0 0 x
(Aligned) Ellipses
6 6
5 5
4 4
3 3
2 2
1 1
0 0
1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10
Stuff
Example: height, on y-axis, remains 3, while length, on
x-axis, changes from 3 to 6
INTRODUCTION TO COMPUTER GRAPHIC S
2D to 3D Object Definition
Vertices in motion (“Generative object description”)
• Line is drawn by tracing path of a point as it
moves (one dimensional entity)
Building 3D Primitives
Curves Patches
Stuff
Boundaries are
Polynomial curves
In 3D
INTRODUCTION TO COMPUTER GRAPHIC S
Stuff
INTRODUCTION TO COMPUTER GRAPHIC S
6
• Column vector for quantities, q:5
1
2
Stuff
store C (Store 24) [0.95 1.10 0.90 3.50]
INTRODUCTION TO COMPUTER GRAPHIC S
What do I pay?
totalCostA = PAiqi
i=1
• Store B:
4
• Store C:
Stuff 4
totalCostC = PCiqi = 5.7 + 5.5 + 0.9 + 7 = 19.1
i=1
INTRODUCTION TO COMPUTER GRAPHIC S
6
totalCost A 0.20 0.93 0.64 1.20
P( All ) = totalCost B = 0.65 0.95 0.75 1.40
5
1
totalCost C 0.95 1.10 0.90 3.50
2
Stuff x
y
a b c d = ax + by + cz + dw
z
w
INTRODUCTION TO COMPUTER GRAPHIC S
2D Translation
Y 6
Note: House
5 4 shifts position
4 relative to origin
4
dx = 2 3
dy = 3 2
2
1 1
0
1 2 3 4 5 6 7 8 9 10
X
2D Scaling
Y 6
Note: House
5 shifts position
sx = 3 4
relative to origin
sy = 2 3
2
6 9
1 2 3 2 2
1 1
0
1 2 3 4 5 6 7 8 9 10
X
sx 0 x' = s x x
and S=
Stuff0 s y y' = s y y
2D Rotation
Y 6
Note: House
5 =
6 shifts position
4
relative to origin
3
1
0
1 2 3 4 5 6 7 8 9 10
X
NB: A rotation by 0 angle, i.e. no rotation at all, gives us the identity matrix
Stuff
• Would like to compose successive
transformations…
INTRODUCTION TO COMPUTER GRAPHIC S
Homogenous Coordinates
• Translation, scaling and rotation are expressed
(non-homogeneously) as:
translation: v’ = v + t
scale: v’ = Sv
rotation: v’ = Rv
x
What is y
?
w
• P2d is intersection of line determined by Ph with
the w = 1 plane
Ph (x,y,w)
1
P2d (x/w,y/w,1)
Y
Stuff
INTRODUCTION TO COMPUTER GRAPHIC S
Stuff
2D Homogeneous Coordinate
Transformations
• For points written in homogeneous coordinates,
x
y ,
1
Stuff
INTRODUCTION TO COMPUTER GRAPHIC S
House ( H ) T (dx, dy) H R( )T (dx, dy) H T (−dx,−dy) R( )T (dx, dy) H
Stuff
• Remember: matrix multiplication is not
commutative! Hence order matters!
INTRODUCTION TO COMPUTER GRAPHIC S
0
1 2 3 4 5 6 7 8 9 10
X
Translation → Rotation
Y 6
3
Stuff
2
0
1 2 3 4 5 6 7 8 9 10
X
Rotation → Translation
INTRODUCTION TO COMPUTER GRAPHIC S
1 0 0 dx
1 0 dy
• Translation 0
0 0 1 dz
0 0 0 1
sx 0 0 0
Stuff 0 sy 0 0
• Scaling 0 0 sz 0
0 0 0 1
INTRODUCTION TO COMPUTER GRAPHIC S
• RotationStuff
about Z-axis
cos − sin 0 0
sin cos 0 0
0 0 1 0
0 0 0 1
INTRODUCTION TO COMPUTER GRAPHIC S
Skew/Shear/Translate (1/2)
Y 6
5
4 =
4
3
2
Stuff
1
0
1 2 3 4 5 6 7 8 9 10
X
NB: A skew of 0 angle, i.e. no skew at all, gives us the identity matrix, as it should
INTRODUCTION TO COMPUTER GRAPHIC S
Skew/Shear/Translate (2/2)
1 1 dx
• 1 tan
0 0 1
1
original y-axis
1 1
T =
0 1
Stuff
INTRODUCTION TO COMPUTER GRAPHIC S
Stuff
INTRODUCTION TO COMPUTER GRAPHIC S
ROBOT
4. Transform subgroups
2. We transform them
Cukup Sekian
Stuff