Unit - III 2D-Transformation
Unit - III 2D-Transformation
Unit - III 2D-Transformation
2D- Transformation
Transformations
What ? :
The geometrical changes of an object from a current state to modified state.
Why ?
To manipulate the initially created object and to display the modified object
without having to redraw it.
Types of Transformation:
1. Basic Transformation
- Translation
- Scaling
- Rotation
2. Other Transformation
- Reflection
- - Shearing
Basic 2D Transformations
Translation:
• A translation moves all points in
an object along the same
?
straight-line path to new
positions.
• The path is represented by a ty=4
vector, called the translation or
shift vector. (2, 2) tx = 6
• We can write the components:
p'x = px + tx
p'y = py + ty x’ x t
= + x
• or in matrix form: y’ y ty
P' = P + T
Basic Transformation
If Sx Sy differential
scaling Change in size and
shape P(1, 2)
Rotation:
• A rotation repositions
P’
all points in an object
along a circular path in
the plane centered at
the pivot point. P
P’(x’, y’)
=> cos (+ ) = x’/r
• x’ = r. cos (+ )
• x’ = r.coscos -r.sinsin r
y’
• x’ = x.cos – y.sin P(x,y)
r y
=>sin (+ ) = y’/r
x
y’ = r. sin (+ ) x’
Identity of Trigonometry
• y’ = r.cossin + r.sincos
• y’ = x.sin + y.cos
Basic 2D Transformations
We can use the third column for translation terms, and all
transformation equations can be expressed as matrix multiplications
Homogeneous Coordinates
y y
w
x
x
The fact that all the points along each line can be
mapped back to the same point in 2D gives this
coordinate system its name – homogeneous
coordinates.
2D Transformations with Homogeneous
Coordinates
•2D Translation Matrix is as follows
.
Composite Transformation
.
Reflection
1 0 0
x-axis y-axis
0 1 0
0 0 1
1 0 0
0 1 0
0 0 1
Origin Line x = y
1 0 0
0 1 0
0 0 1
0 1 0
1 0 0
0 0 1
Shearing
(2,1) (3,1)
(0,1) (1,1)
• One for height(y), one for width(x) and the third(z) for the
depth.
• 3D
2D coordinates
y
y
x
x
z
y
z
Right-handed coordinate system: x
Equation of A Line
y-y1/ x-x1 = y2- y1/ x2-x1 and z- z1/ x-x1 = z2-z1/ x2-x1
3D Transformation
• Translation in 3D
• Scaling in 3D:
sx 0 0 0
0 sy 0 0
0 0 sz 0
0 0 0 1
3D Transformation
3D Transformation
x-axis rotation 1 0 0 0
y’=y cos θ - z sin θ 0 cos sin 0
z’=y sin θ + z cos θ
0 sin cos 0
x’=x
0 0 0 1
y-axis rotation
cos 0 sin 0
z’=z cos θ - x sin θ 0 1 0
0
x’=z sin θ + x cos θ
y’ = y sin 0 cos 0
0 0 0 1
3D Rotation about Arbitrary Axis
1. Translate the object so that the rotation axis passes through the coordinate
origin
2. Rotate the object so that the axis of rotation coincides with one of the
coordinate axes
4. Apply inverse rotations to bring the rotation axis back to its original position
5. Apply the inverse translation to bring the rotation axis back to its original
spatial position
Projections
Perspective Parallel
Orthographic Oblique
Isometric
Parallel Projection
• 2 Types:
1. Orthographic projection
2. Oblique projection.
• Orthographic :
– direction of projection = normal to the projection plane.
• Oblique :
– direction of projection != normal to the projection plane.
Parallel Projections
– The projection of a line perpendicular to the view plane has the same length
as the line itself in Cavalier projection. In a cavalier projection, the
foreshortening factors for all three principal directions are equal.
Parallel Projections
• Cabinet:
– The direction of the projection makes a 63.4 degree angle with the projection
plane. This results in foreshortening of the z axis, and provides a more “realistic”
view.