Computer Graphics
Unit-3 2D,3D Transformation
and Projections
2D Transformation-
● Manipulation done on object.
● Translation - changing the position
tx- translation parameter with respect to x-axis
ty- translation parameter with respect to y-axis
● Scaling - Resizing the object
Sx - Scaling parameter with respect to x-axis
Sy - Scaling parameter with respect to y-axis
● Rotation - Rotate object
Rotate clockwise & anticlockwise
1) Translation- changing the position
P(x,y)-point before translation
P’(x’,y’)-point after translation
tx- translation parameter with respect to x-axis
ty- translation parameter with respect to y-axis
x’= x + tx
y’= y + ty
P’= P + T
Matrix Form- [x’ y’]=[x y]+[tx ty]
Exa. Consider square (0,0),(2,0), (0,2), (2,2) with tx=2, ty=3
(0,0)
x’=0 + 2 =2
y’=0 + 3=3
(0,0) →(2,3)
(2,0)
x’=2 + 2 =4
y’=0 + 3=3
(2,0) →(4,3)
(0,2)
x’=0 + 2 =2
y’=2 + 3=5
(0,2) →(2,5)
(2,2)
x’=2 + 2 =4
y’=2 + 3=5
(2,2) →(4,5)
2) Scaling-Resize the object
● Sx - Scaling parameter with respect to x-axis
● Sy - Scaling parameter with respect to y-axis
● Both if Sx & Sy in between 0 & 1
○ Point is closer to origin
○ Size decreases
● if Sx & Sy are greater than 1
○ Point is away from origin
○ Size increases
● If Sx & Sy are equal
Scaling will be done uniformly
x’=x.Sx
y’=y.Sy
Matrix form-
Exa 1). Consider square (0,0),(2,0), (0,2), (2,2) with Sx=2, Sy=3
(0,0)
x’=0 * 2 =0
y’=0 * 3=0
(0,0) →(0,0)
(2,0)
x’=2 * 2 =4
y’=0 * 3=0
(2,0) →(4,0)
(0,2)
x’=0 * 2 =0
y’=2 * 3=6
(0,2) →(0,6)
(2,2)
x’=2 * 2 =4
y’=2 * 3=6
(2,2) →(4,6)
Exa 2). Consider square (0,0),(2,0), (0,2), (2,2) with Sx=0.5, Sy=0.5
(0,0)
x’=0 * 0.5 =0
y’=0 * 0.5=0
(0,0) →(0,0)
(2,0)
x’=2 * 0.5 =1
y’=0 * 0.5=0
(2,0) →(1,0)
(0,2)
x’=0 * 0.5 =0
y’=2 * 0.5=1
(0,2) →(0,1)
(2,2)
x’=2 * 0.5 =1
y’=2 * 0.5=1
(2,2) →(1,1)
3) Rotation-
Example 1) Note-If not mention direction in exa. Consider Anticlockwise.
Example 2)
4) Shearing-
x-shear - y same only x distorted
y’=y
x’=x +Shx.y x shearing parameter
y-shear - x same only y distorted
x’=x
y’=y +Shy.x y shearing parameter
Exa 1). Consider square (0,0),(2,0), (0,2), (2,2) with Shx=2 units
(0,0)
x’=0 + 2.0 =0
y’=0
(0,0) →(0,0)
(0,2)
x’=0+2.2=4
y’= 2
(0,2) →(4,2)
(2,0)
x’=2 + 2.0 =2
y’=0
(2,0) →(2,0)
(2,2)
x’=2 +2.2=2+4 =6
y’=2
(2,2) →(6,2)
Exa 2). Consider square (0,0),(2,0), (0,2), (2,2) with Shy=2 units
(0,0)
x’= 0
y’=0 + 2.0=0
(0,0) →(0,0)
(0,2)
x’=0
y’= 2 + 2.0=2
(0,2) →(0,2)
(2,0)
x’=2
y’=0 + 2.2=4
(2,0) →(2,4)
(2,2)
x’=2
y’=2+2.2=2+4=6
(2,2) →(2,6)
Homogeneous Coordinates Representation-
● Homogeneous coordinates means 2D matrix converted into 3D matrix for
simplification. (x,y) → (xh,yh,h) where h- any non-zero for simplification,
consider h=1
1) Translation- Homogeneous matrix 2) Scaling-Homogeneous matrix
representation of Translation
representation of Scaling
Homogeneous Coordinates…
3) Rotation- Homogeneous matrix 2) Shearing-Homogeneous matrix
representation of Rotation
representation of Shearing
(anticlockwise)
Rotation about an arbitrary point-
● We have derived rotation matrices
with respect to origin but suppose
reference point of rotation is other
than origin we must follow 3 steps-
Step 1- Arbitrary point translate to
origin (0,0) tx=-xp, ty=-yp
Rotation about an arbitrary point…
Step 2- Rotate at angle
𝝷
Step 3- Translate back at same
Arbitrary position tx=xp, ty=yp
Rotation about an arbitrary point…
Now let us form a combined matrix
This is transformation matrix is overall transformation matrix for rotation about
arbitrary point (xp,yp) by an angle in anticlockwise direction.
𝝷
3D Transformation-
● Translation - changing the position/moving the object tx,ty,tz
● Scaling - Resizing the object/changing the size Sx,Sy,Sz
● Rotation - Rotate object with 𝝷
Rotate clockwise & anticlockwise
● Shearing - Tilting the object
x-shear, y-shear, z-shear
1) 3D Translation-
tx- translation parameter with respect to x-axis x’= x + tx
ty- translation parameter with respect to y-axis y’= y + ty
tz- translation parameter with respect to z-axis z’= y + tz
2) 3D Scaling-
Sx- Scaling parameter with respect to x-axis x’= x . Sx
Sy- Scaling parameter with respect to y-axis y’= y . Sy
Sz- Scaling parameter with respect to z-axis z’= y . Sz
3) 3D Rotation-
A. X-axis rotation
B. Y-axis rotation
C. Z-axis rotation
A. X-axis rotation
B. Y-axis rotation
C. Z-axis rotation
4) 3D Shearing-
A. Shearing in X-axis
B. Shearing in Y-axis
C. Shearing in Z-axis
A. Shearing in X-axis
B. Shearing in Y-axis
C. Shearing in Z-axis
3D Homogeneous Coordinates Representation-
1) Translation- 2) Scaling-
3) Rotation-anticlockwise 4) Shearing-
3D Rotation about an arbitrary point-
● If we want to rotate a point (x,y,z) by an angle which is in space and lying
𝝷
on an arbitrary axis then we have to follow 7 steps as follows:
Step 1- Translate the arbitrary axis so that it will pass through the origin. When we
translating axis, a point also gets translated.

CG Unit-3 2D,3D Transformations and Projections.pptx

  • 1.
    Computer Graphics Unit-3 2D,3DTransformation and Projections
  • 2.
    2D Transformation- ● Manipulationdone on object. ● Translation - changing the position tx- translation parameter with respect to x-axis ty- translation parameter with respect to y-axis ● Scaling - Resizing the object Sx - Scaling parameter with respect to x-axis Sy - Scaling parameter with respect to y-axis ● Rotation - Rotate object Rotate clockwise & anticlockwise
  • 3.
    1) Translation- changingthe position P(x,y)-point before translation P’(x’,y’)-point after translation tx- translation parameter with respect to x-axis ty- translation parameter with respect to y-axis x’= x + tx y’= y + ty P’= P + T Matrix Form- [x’ y’]=[x y]+[tx ty]
  • 4.
    Exa. Consider square(0,0),(2,0), (0,2), (2,2) with tx=2, ty=3 (0,0) x’=0 + 2 =2 y’=0 + 3=3 (0,0) →(2,3) (2,0) x’=2 + 2 =4 y’=0 + 3=3 (2,0) →(4,3) (0,2) x’=0 + 2 =2 y’=2 + 3=5 (0,2) →(2,5) (2,2) x’=2 + 2 =4 y’=2 + 3=5 (2,2) →(4,5)
  • 5.
    2) Scaling-Resize theobject ● Sx - Scaling parameter with respect to x-axis ● Sy - Scaling parameter with respect to y-axis ● Both if Sx & Sy in between 0 & 1 ○ Point is closer to origin ○ Size decreases ● if Sx & Sy are greater than 1 ○ Point is away from origin ○ Size increases ● If Sx & Sy are equal Scaling will be done uniformly x’=x.Sx y’=y.Sy Matrix form-
  • 6.
    Exa 1). Considersquare (0,0),(2,0), (0,2), (2,2) with Sx=2, Sy=3 (0,0) x’=0 * 2 =0 y’=0 * 3=0 (0,0) →(0,0) (2,0) x’=2 * 2 =4 y’=0 * 3=0 (2,0) →(4,0) (0,2) x’=0 * 2 =0 y’=2 * 3=6 (0,2) →(0,6) (2,2) x’=2 * 2 =4 y’=2 * 3=6 (2,2) →(4,6)
  • 7.
    Exa 2). Considersquare (0,0),(2,0), (0,2), (2,2) with Sx=0.5, Sy=0.5 (0,0) x’=0 * 0.5 =0 y’=0 * 0.5=0 (0,0) →(0,0) (2,0) x’=2 * 0.5 =1 y’=0 * 0.5=0 (2,0) →(1,0) (0,2) x’=0 * 0.5 =0 y’=2 * 0.5=1 (0,2) →(0,1) (2,2) x’=2 * 0.5 =1 y’=2 * 0.5=1 (2,2) →(1,1)
  • 8.
  • 10.
    Example 1) Note-Ifnot mention direction in exa. Consider Anticlockwise.
  • 11.
  • 12.
    4) Shearing- x-shear -y same only x distorted y’=y x’=x +Shx.y x shearing parameter y-shear - x same only y distorted x’=x y’=y +Shy.x y shearing parameter
  • 14.
    Exa 1). Considersquare (0,0),(2,0), (0,2), (2,2) with Shx=2 units (0,0) x’=0 + 2.0 =0 y’=0 (0,0) →(0,0) (0,2) x’=0+2.2=4 y’= 2 (0,2) →(4,2) (2,0) x’=2 + 2.0 =2 y’=0 (2,0) →(2,0) (2,2) x’=2 +2.2=2+4 =6 y’=2 (2,2) →(6,2)
  • 15.
    Exa 2). Considersquare (0,0),(2,0), (0,2), (2,2) with Shy=2 units (0,0) x’= 0 y’=0 + 2.0=0 (0,0) →(0,0) (0,2) x’=0 y’= 2 + 2.0=2 (0,2) →(0,2) (2,0) x’=2 y’=0 + 2.2=4 (2,0) →(2,4) (2,2) x’=2 y’=2+2.2=2+4=6 (2,2) →(2,6)
  • 16.
    Homogeneous Coordinates Representation- ●Homogeneous coordinates means 2D matrix converted into 3D matrix for simplification. (x,y) → (xh,yh,h) where h- any non-zero for simplification, consider h=1 1) Translation- Homogeneous matrix 2) Scaling-Homogeneous matrix representation of Translation representation of Scaling
  • 17.
    Homogeneous Coordinates… 3) Rotation-Homogeneous matrix 2) Shearing-Homogeneous matrix representation of Rotation representation of Shearing (anticlockwise)
  • 18.
    Rotation about anarbitrary point- ● We have derived rotation matrices with respect to origin but suppose reference point of rotation is other than origin we must follow 3 steps- Step 1- Arbitrary point translate to origin (0,0) tx=-xp, ty=-yp
  • 19.
    Rotation about anarbitrary point… Step 2- Rotate at angle 𝝷 Step 3- Translate back at same Arbitrary position tx=xp, ty=yp
  • 20.
    Rotation about anarbitrary point… Now let us form a combined matrix This is transformation matrix is overall transformation matrix for rotation about arbitrary point (xp,yp) by an angle in anticlockwise direction. 𝝷
  • 21.
    3D Transformation- ● Translation- changing the position/moving the object tx,ty,tz ● Scaling - Resizing the object/changing the size Sx,Sy,Sz ● Rotation - Rotate object with 𝝷 Rotate clockwise & anticlockwise ● Shearing - Tilting the object x-shear, y-shear, z-shear
  • 22.
    1) 3D Translation- tx-translation parameter with respect to x-axis x’= x + tx ty- translation parameter with respect to y-axis y’= y + ty tz- translation parameter with respect to z-axis z’= y + tz
  • 23.
    2) 3D Scaling- Sx-Scaling parameter with respect to x-axis x’= x . Sx Sy- Scaling parameter with respect to y-axis y’= y . Sy Sz- Scaling parameter with respect to z-axis z’= y . Sz
  • 24.
    3) 3D Rotation- A.X-axis rotation B. Y-axis rotation C. Z-axis rotation
  • 25.
  • 26.
  • 27.
  • 28.
    4) 3D Shearing- A.Shearing in X-axis B. Shearing in Y-axis C. Shearing in Z-axis
  • 29.
  • 30.
  • 31.
  • 32.
    3D Homogeneous CoordinatesRepresentation- 1) Translation- 2) Scaling- 3) Rotation-anticlockwise 4) Shearing-
  • 33.
    3D Rotation aboutan arbitrary point- ● If we want to rotate a point (x,y,z) by an angle which is in space and lying 𝝷 on an arbitrary axis then we have to follow 7 steps as follows: Step 1- Translate the arbitrary axis so that it will pass through the origin. When we translating axis, a point also gets translated.