0% found this document useful (0 votes)
3K views31 pages

2D Translation in Computer Graphics

2D Translation in computer graphics involves moving an object from one position to another in a two-dimensional plane. The new coordinates of the translated object are calculated by adding the translation vector to the old coordinates. This translation can be represented using a homogeneous transformation matrix. Some example problems demonstrate translating shapes like circles and squares by applying the translation equations or matrix multiplication.

Uploaded by

leena
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3K views31 pages

2D Translation in Computer Graphics

2D Translation in computer graphics involves moving an object from one position to another in a two-dimensional plane. The new coordinates of the translated object are calculated by adding the translation vector to the old coordinates. This translation can be represented using a homogeneous transformation matrix. Some example problems demonstrate translating shapes like circles and squares by applying the translation equations or matrix multiplication.

Uploaded by

leena
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
  • 2D Translation in Computer Graphics
  • Practice Problems Based on 2D Translation
  • 2D Rotation in Computer Graphics
  • Practice Problems Based on 2D Rotation
  • 2D Scaling in Computer Graphics
  • Practice Problems Based on 2D Scaling
  • 3D Translation in Computer Graphics
  • Practice Problem Based on 3D Translation
  • 3D Shearing in Computer Graphics
  • Practice Problems Based on 3D Shearing
  • 3D Reflection in Computer Graphics
  • Practice Problems Based on 3D Reflection
  • Affine Transformations

2D Translation in Computer Graphics-

In Computer graphics,
2D Translation is a process of moving an object from one position to another in a two dimensional
plane.

 
 Consider a point object O has to be moved from one position to another in a 2D plane.
 
Let-

 Initial coordinates of the object O = (Xold, Yold)



 New coordinates of the object O after translation = (X new, Ynew)
 Translation vector or Shift vector = (T x, Ty)
 
Given a Translation vector (Tx, Ty)-

 Tx defines the distance the Xold coordinate has to be moved.


 Ty defines the distance the Yold coordinate has to be moved.
 

1
This translation is achieved by adding the translation coordinates to the old coordinates
of the object as-

 Xnew = Xold + Tx (This denotes translation towards X axis)


 Ynew = Yold + Ty (This denotes translation towards Y axis)
 
In Matrix form, the above translation equations may be represented as-
 

 The homogeneous coordinates representation of (X, Y) is (X, Y, 1).


 Through this representation, all the transformations can be performed using
matrix / vector multiplications.
 
The above translation matrix may be represented as a 3 x 3 matrix as-
 

2
PRACTICE PROBLEMS BASED ON 2D TRANSLATION IN
COMPUTER GRAPHICS-
 

Problem-01:
 
Given a circle C with radius 10 and center coordinates (1, 4). Apply the translation with
distance 5 towards X axis and 1 towards Y axis. Obtain the new coordinates of C without
changing its radius.

 Solution-

 Given-

 Old center coordinates of C = (Xold, Yold) = (1, 4)


 Translation vector = (Tx, Ty) = (5, 1)
 
Let the new center coordinates of C = (X new, Ynew).
 Applying the translation equations, we have-

 Xnew = Xold + Tx = 1 + 5 = 6


 Ynew = Yold + Ty = 4 + 1 = 5
 
Thus, New center coordinates of C = (6, 5).
 
Alternatively, In matrix form, the new center coordinates of C after translation may be
obtained as-

 
 

3
Thus, New center coordinates of C = (6, 5).
 

Problem-02:
 
Given a square with coordinate points A(0, 3), B(3, 3), C(3, 0), D(0, 0). Apply the
translation with distance 1 towards X axis and 1 towards Y axis. Obtain the new
coordinates of the square.

 Solution-

 Given-

 Old coordinates of the square = A (0, 3), B(3, 3), C(3, 0), D(0, 0)
 Translation vector = (Tx, Ty) = (1, 1)
 

For Coordinates A(0, 3)


 Let the new coordinates of corner A = (X new, Ynew).
 Applying the translation equations, we have-

 Xnew = Xold + Tx = 0 + 1 = 1


 Ynew = Yold + Ty = 3 + 1 = 4
 
Thus, New coordinates of corner A = (1, 4).

 For Coordinates B(3, 3)

 Let the new coordinates of corner B = (X new, Ynew).


 Applying the translation equations, we have-

 Xnew = Xold + Tx = 3 + 1 = 4


 Ynew = Yold + Ty = 3 + 1 = 4
 

4
Thus, New coordinates of corner B = (4, 4).

For Coordinates C(3, 0)


 
Let the new coordinates of corner C = (Xnew, Ynew).
Applying the translation equations, we have-

 Xnew = Xold + Tx = 3 + 1 = 4


 Ynew = Yold + Ty = 0 + 1 = 1
 Thus, New coordinates of corner C = (4, 1).

 For Coordinates D(0, 0)

 Let the new coordinates of corner D = (Xnew, Ynew).


 Applying the translation equations, we have-

 Xnew = Xold + Tx = 0 + 1 = 1


 Ynew = Yold + Ty = 0 + 1 = 1
 
Thus, New coordinates of corner D = (1, 1).
Thus, New coordinates of the square = A (1, 4), B(4, 4), C(4, 1), D(1, 1).
 

2D Rotation in Computer Graphics-


In Computer graphics,
2D Rotation is a process of rotating an object with respect to an angle in a two dimensional plane.

 
 Consider a point object O has to be rotated from one angle to another in a 2D plane.
 Let-

 Initial coordinates of the object O = (Xold, Yold)


 Initial angle of the object O with respect to origin = Φ
 Rotation angle = θ

5
 New coordinates of the object O after rotation = (X new, Ynew)
 

 
This rotation is achieved by using the following rotation equations-

 Xnew = Xold x cosθ – Yold x sinθ


 Ynew = Xold x sinθ + Yold x cosθ
 
In Matrix form, the above rotation equations may be represented as-
 

 
For homogeneous coordinates, the above rotation matrix may be represented as a 3 x 3
matrix as-
 

6
 PRACTICE PROBLEMS BASED ON 2D ROTATION IN COMPUTER GRAPHICS-

 Problem-01:

 
Given a line segment with starting point as (0, 0) and ending point as (4, 4). Apply 30
degree rotation anticlockwise direction on the line segment and find out the new
coordinates of the line.
 

Solution-
 
We rotate a straight line by its end points with the same angle. Then, we re-draw a line
between the new end points.
 
Given-

 Old ending coordinates of the line = (Xold, Yold) = (4, 4)


 Rotation angle = θ = 30º
 
Let new ending coordinates of the line after rotation = (X new, Ynew).
 Applying the rotation equations, we have-
 
Xnew = Xold x cosθ – Yold x sinθ
= 4 x cos30º – 4 x sin30º
= 4 x (√3 / 2) – 4 x (1 / 2)
= 2√3 – 2
= 2(√3 – 1)

7
= 2(1.73 – 1)
= 1.46
 
Ynew = Xold x sinθ + Yold x cosθ
= 4 x sin30º + 4 x cos30º
= 4 x (1 / 2) + 4 x (√3 / 2)
= 2 + 2√3
= 2(1 + √3)
= 2(1 + 1.73)
= 5.46
 
Thus, New ending coordinates of the line after rotation = (1.46, 5.46).
 
Alternatively,
 
In matrix form, the new ending coordinates of the line after rotation may be obtained as-
 

 
Thus, New ending coordinates of the line after rotation = (1.46, 5.46).
 

8
 

Problem-02: Given a triangle with corner coordinates (0, 0), (1, 0) and (1, 1). Rotate
the triangle by 90 degree anticlockwise direction and find out the new
coordinates.
 

Solution-
 
We rotate a polygon by rotating each vertex of it with the same rotation angle.
 Given-

 Old corner coordinates of the triangle = A (0, 0), B(1, 0), C(1, 1)
 Rotation angle = θ = 90º
 

For Coordinates A(0, 0)


 Let the new coordinates of corner A after rotation = (X new, Ynew).
 Applying the rotation equations, we have-
 Xnew
= Xold x cosθ – Yold x sinθ
= 0 x cos90º – 0 x sin90º
=0
 
Ynew
= Xold x sinθ + Yold x cosθ
= 0 x sin90º + 0 x cos90º
=0
 
Thus, New coordinates of corner A after rotation = (0, 0).

9
 

For Coordinates B(1, 0)


 Let the new coordinates of corner B after rotation = (X new, Ynew).
 Xnew
= Xold x cosθ – Yold x sinθ
= 1 x cos90º – 0 x sin90º
=0
 
Ynew
= Xold x sinθ + Yold x cosθ
= 1 x sin90º + 0 x cos90º
=1+0
=1
 
Thus, New coordinates of corner B after rotation = (0, 1).

 For Coordinates C(1, 1)

 Let the new coordinates of corner C after rotation = (X new, Ynew).


 Xnew
= Xold x cosθ – Yold x sinθ
= 1 x cos90º – 1 x sin90º
=0–1
= -1
 
Ynew
= Xold x sinθ + Yold x cosθ
= 1 x sin90º + 1 x cos90º
=1+0
=1
 
Thus, New coordinates of corner C after rotation = (-1, 1).
 

10
Thus, New coordinates of the triangle after rotation = A (0, 0), B(0, 1), C(-1, 1).
 

2D Scaling in Computer Graphics-


 

In computer graphics, scaling is a process of modifying or altering the size of objects.

 Scaling may be used to increase or reduce the size of object.


 Scaling subjects the coordinate points of the original object to change.
 Scaling factor determines whether the object size is to be increased or reduced.
 If scaling factor > 1, then the object size is increased.
 If scaling factor < 1, then the object size is reduced.
 
Consider a point object O has to be scaled in a 2D plane.
 
Let-

 Initial coordinates of the object O = (Xold, Yold)


 Scaling factor for X-axis = Sx
 Scaling factor for Y-axis = Sy
 New coordinates of the object O after scaling = (X new, Ynew)
 
This scaling is achieved by using the following scaling equations-

 Xnew = Xold x Sx
 Ynew = Yold x Sy
 
In Matrix form, the above scaling equations may be represented as-
 

11
 
For homogeneous coordinates, the above scaling matrix may be represented as a 3 x 3
matrix as-
 

PRACTICE PROBLEMS BASED ON 2D SCALING IN COMPUTER GRAPHICS-


 

Problem-01:
 Given a square object with coordinate points A(0, 3), B(3, 3), C(3, 0), D(0, 0). Apply the
scaling parameter 2 towards X axis and 3 towards Y axis and obtain the new
coordinates of the object.

 Solution-

 Given-

 Old corner coordinates of the square = A (0, 3), B(3, 3), C(3, 0), D(0, 0)
 Scaling factor along X axis = 2
 Scaling factor along Y axis = 3
 

For Coordinates A(0, 3)


 Let the new coordinates of corner A after scaling = (X new, Ynew).
 Applying the scaling equations, we have-

 Xnew = Xold x Sx = 0 x 2 = 0

12
 Ynew = Yold x Sy = 3 x 3 = 9
 
Thus, New coordinates of corner A after scaling = (0, 9).
 

For Coordinates B(3, 3)


 Let the new coordinates of corner B after scaling = (X new, Ynew).
 Applying the scaling equations, we have-

 Xnew = Xold x Sx = 3 x 2 = 6


 Ynew = Yold x Sy = 3 x 3 = 9
 
Thus, New coordinates of corner B after scaling = (6, 9).
 

For Coordinates C(3, 0)


 
Let the new coordinates of corner C after scaling = (X new, Ynew).
 Applying the scaling equations, we have-

 Xnew = Xold x Sx = 3 x 2 = 6


 Ynew = Yold x Sy = 0 x 3 = 0
 
Thus, New coordinates of corner C after scaling = (6, 0).
 

For Coordinates D(0, 0)


 Let the new coordinates of corner D after scaling = (X new, Ynew).
 Applying the scaling equations, we have-

 Xnew = Xold x Sx = 0 x 2 = 0


 Ynew = Yold x Sy = 0 x 3 = 0
 
Thus, New coordinates of corner D after scaling = (0, 0).
 Thus, New coordinates of the square after scaling = A (0, 9), B(6, 9), C(6, 0), D(0, 0).
 

13
 

3D Translation in Computer Graphics-


 

In Computer graphics,
3D Translation is a process of moving an object from one position to another in a three dimensional
plane.

 
Consider a point object O has to be moved from one position to another in a 3D plane.
 
Let-

 Initial coordinates of the object O = (Xold, Yold, Zold)


 New coordinates of the object O after translation = (X new, Ynew, Zold)
 Translation vector or Shift vector = (T x, Ty, Tz)
 
Given a Translation vector (Tx, Ty, Tz)-

 Tx defines the distance the Xold coordinate has to be moved.


 Ty defines the distance the Yold coordinate has to be moved.
 Tz defines the distance the Zold coordinate has to be moved.
 

14
 
This translation is achieved by adding the translation coordinates to the old coordinates
of the object as-

 Xnew = Xold + Tx (This denotes translation towards X axis)


 Ynew = Yold + Ty (This denotes translation towards Y axis)
 Znew = Zold + Tz (This denotes translation towards Z axis)
 
In Matrix form, the above translation equations may be represented as-
 

 
Also Read- 2D Translation in Computer Graphics

15
 

PRACTICE PROBLEM BASED ON 3D TRANSLATION IN


COMPUTER GRAPHICS-
 

Problem-
 
Given a 3D object with coordinate points A(0, 3, 1), B(3, 3, 2), C(3, 0, 0), D(0, 0, 0).
Apply the translation with the distance 1 towards X axis, 1 towards Y axis and 2 towards
Z axis and obtain the new coordinates of the object.
 

Solution-
 
Given-

 Old coordinates of the object = A (0, 3, 1), B(3, 3, 2), C(3, 0, 0), D(0, 0, 0)
 Translation vector = (Tx, Ty, Tz) = (1, 1, 2)
 

For Coordinates A(0, 3, 1)


 
Let the new coordinates of A = (Xnew, Ynew, Znew).
 
Applying the translation equations, we have-

 Xnew = Xold + Tx = 0 + 1 = 1


 Ynew = Yold + Ty = 3 + 1 = 4
 Znew = Zold + Tz = 1 + 2 = 3
 
Thus, New coordinates of A = (1, 4, 3).
 

For Coordinates B(3, 3, 2)


 
Let the new coordinates of B = (Xnew, Ynew, Znew).
 
Applying the translation equations, we have-

 Xnew = Xold + Tx = 3 + 1 = 4

16
 Ynew = Yold + Ty = 3 + 1 = 4
 Znew = Zold + Tz = 2 + 2 = 4
 
Thus, New coordinates of B = (4, 4, 4).
 

For Coordinates C(3, 0, 0)


 
Let the new coordinates of C = (Xnew, Ynew, Znew).
 
Applying the translation equations, we have-

 Xnew = Xold + Tx = 3 + 1 = 4


 Ynew = Yold + Ty = 0 + 1 = 1
 Znew = Zold + Tz = 0 + 2 = 2
 
Thus, New coordinates of C = (4, 1, 2).
 

For Coordinates D(0, 0, 0)


 
Let the new coordinates of D = (Xnew, Ynew, Znew).
 
Applying the translation equations, we have-

 Xnew = Xold + Tx = 0 + 1 = 1


 Ynew = Yold + Ty = 0 + 1 = 1
 Znew = Zold + Tz = 0 + 2 = 2
 
Thus, New coordinates of D = (1, 1, 2).
Thus, New coordinates of the object = A (1, 4, 3), B(4, 4, 4), C(4, 1, 2), D(1, 1, 2).

17
3D Shearing in Computer Graphics-
 

In Computer graphics,
3D Shearing is an ideal technique to change the shape of an existing object in a three dimensional
plane.

 
In a three dimensional plane, the object size can be changed along X direction, Y
direction as well as Z direction.
So, there are three versions of shearing-
 

18
 
1. Shearing in X direction
2. Shearing in Y direction
3. Shearing in Z direction
 
Consider a point object O has to be sheared in a 3D plane.
 
Let-

 Initial coordinates of the object O = (Xold, Yold, Zold)


 Shearing parameter towards X direction = Shx
 Shearing parameter towards Y direction = Shy
 Shearing parameter towards Z direction = Shz
 New coordinates of the object O after shearing = (X new, Ynew, Znew)
 

Shearing in X Axis-
 
Shearing in X axis is achieved by using the following shearing equations-

 Xnew = Xold
 Ynew = Yold + Shy x Xold
 Znew = Zold + Shz x Xold
 
In Matrix form, the above shearing equations may be represented as-
 

19
 

Shearing in Y Axis-
 
Shearing in Y axis is achieved by using the following shearing equations-

 Xnew = Xold + Shx x Yold


 Ynew = Yold
 Znew = Zold + Shz x Yold
 
In Matrix form, the above shearing equations may be represented as-
 

20
Shearing in Z Axis-
 
Shearing in Z axis is achieved by using the following shearing equations-

 Xnew = Xold + Shx x Zold


 Ynew = Yold + Shy x Zold
 Znew = Zold
 
In Matrix form, the above shearing equations may be represented as-
 

PRACTICE PROBLEMS BASED ON 3D SHEARING IN


COMPUTER GRAPHICS-
 

Problem-01:
 
Given a 3D triangle with points (0, 0, 0), (1, 1, 2) and (1, 1, 3). Apply shear parameter 2
on X axis, 2 on Y axis and 3 on Z axis and find out the new coordinates of the object.
 

Solution-
 
Given-

21
 Old corner coordinates of the triangle = A (0, 0, 0), B(1, 1, 2), C(1, 1, 3)
 Shearing parameter towards X direction (Shx) = 2
 Shearing parameter towards Y direction (Shy) = 2
 Shearing parameter towards Y direction (Shz) = 3
 

Shearing in X Axis-
 

For Coordinates A(0, 0, 0)


 
Let the new coordinates of corner A after shearing = (X new, Ynew, Znew).
 
Applying the shearing equations, we have-

 Xnew = Xold = 0
 Ynew = Yold + Shy x Xold = 0 + 2 x 0 = 0
 Znew = Zold + Shz x Xold = 0 + 3 x 0 = 0
 
Thus, New coordinates of corner A after shearing = (0, 0, 0).
 

For Coordinates B(1, 1, 2)


 
Let the new coordinates of corner B after shearing = (X new, Ynew, Znew).
 
Applying the shearing equations, we have-

 Xnew = Xold = 1
 Ynew = Yold + Shy x Xold = 1 + 2 x 1 = 3
 Znew = Zold + Shz x Xold = 2 + 3 x 1 = 5
 
Thus, New coordinates of corner B after shearing = (1, 3, 5).
 

For Coordinates C(1, 1, 3)


 
Let the new coordinates of corner C after shearing = (X new, Ynew, Znew).
 
Applying the shearing equations, we have-

22
 Xnew = Xold = 1
 Ynew = Yold + Shy x Xold = 1 + 2 x 1 = 3
 Znew = Zold + Shz x Xold = 3 + 3 x 1 = 6
 
Thus, New coordinates of corner C after shearing = (1, 3, 6).
Thus, New coordinates of the triangle after shearing in X axis = A (0, 0, 0), B(1, 3, 5),
C(1, 3, 6).
 

Shearing in Y Axis-
 

For Coordinates A(0, 0, 0)


 
Let the new coordinates of corner A after shearing = (X new, Ynew, Znew).
 
Applying the shearing equations, we have-

 Xnew = Xold + Shx x Yold = 0 + 2 x 0 = 0


 Ynew = Yold = 0
 Znew = Zold + Shz x Yold = 0 + 3 x 0 = 0
 
Thus, New coordinates of corner A after shearing = (0, 0, 0).
 

For Coordinates B(1, 1, 2)


 
Let the new coordinates of corner B after shearing = (X new, Ynew, Znew).
 
Applying the shearing equations, we have-

 Xnew = Xold + Shx x Yold = 1 + 2 x 1 = 3


 Ynew = Yold = 1
 Znew = Zold + Shz x Yold = 2 + 3 x 1 = 5
 
Thus, New coordinates of corner B after shearing = (3, 1, 5).
 

For Coordinates C(1, 1, 3)


 

23
Let the new coordinates of corner C after shearing = (X new, Ynew, Znew).
 
Applying the shearing equations, we have-

 Xnew = Xold + Shx x Yold = 1 + 2 x 1 = 3


 Ynew = Yold = 1
 Znew = Zold + Shz x Yold = 3 + 3 x 1 = 6
 
Thus, New coordinates of corner C after shearing = (3, 1, 6).
Thus, New coordinates of the triangle after shearing in Y axis = A (0, 0, 0), B(3, 1, 5),
C(3, 1, 6).
 

Shearing in Z Axis-
 

For Coordinates A(0, 0, 0)


 
Let the new coordinates of corner A after shearing = (X new, Ynew, Znew).
 
Applying the shearing equations, we have-

 Xnew = Xold + Shx x Zold = 0 + 2 x 0 = 0


 Ynew = Yold + Shy x Zold = 0 + 2 x 0 = 0
 Znew = Zold = 0
 
Thus, New coordinates of corner A after shearing = (0, 0, 0).
 

For Coordinates B(1, 1, 2)


 
Let the new coordinates of corner B after shearing = (X new, Ynew, Znew).
 
Applying the shearing equations, we have-

 Xnew = Xold + Shx x Zold = 1 + 2 x 2 = 5


 Ynew = Yold + Shy x Zold = 1 + 2 x 2 = 5
 Znew = Zold = 2
 
Thus, New coordinates of corner B after shearing = (5, 5, 2).

24
 

For Coordinates C(1, 1, 3)


 
Let the new coordinates of corner C after shearing = (X new, Ynew, Znew).
 
Applying the shearing equations, we have-

 Xnew = Xold + Shx x Zold = 1 + 2 x 3 = 7


 Ynew = Yold + Shy x Zold = 1 + 2 x 3 = 7
 Znew = Zold = 3
 
Thus, New coordinates of corner C after shearing = (7, 7, 3).
Thus, New coordinates of the triangle after shearing in Z axis = A (0, 0, 0), B(5, 5, 2),
C(7, 7, 3).

3D Reflection in Computer Graphics-


 
 Reflection is a kind of rotation where the angle of rotation is 180 degree.
 The reflected object is always formed on the other side of mirror.
 The size of reflected object is same as the size of original object.
 
Consider a point object O has to be reflected in a 3D plane.
 
Let-

 Initial coordinates of the object O = (Xold, Yold, Zold)


 New coordinates of the reflected object O after reflection = (X new, Ynew,Znew)
 
In 3 dimensions, there are 3 possible types of reflection-
 

25
 

 Reflection relative to XY plane


 Reflection relative to YZ plane
 Reflection relative to XZ plane
 

Reflection Relative to XY Plane:


 
This reflection is achieved by using the following reflection equations-

 Xnew = Xold
 Ynew = Yold
 Znew = -Zold
 
In Matrix form, the above reflection equations may be represented as-
 

26
Reflection Relative to YZ Plane:
 
This reflection is achieved by using the following reflection equations-

 Xnew = -Xold
 Ynew = Yold
 Znew = Zold
 
In Matrix form, the above reflection equations may be represented as-
 

Reflection Relative to XZ Plane:


 
This reflection is achieved by using the following reflection equations-

 Xnew = Xold
 Ynew = -Yold
 Znew = Zold
 
In Matrix form, the above reflection equations may be represented as-
 

27
 

PRACTICE PROBLEMS BASED ON 3D REFLECTION IN


COMPUTER GRAPHICS-
 

Problem-01:
 
Given a 3D triangle with coordinate points A(3, 4, 1), B(6, 4, 2), C(5, 6, 3). Apply the
reflection on the XY plane and find out the new coordinates of the object.
 

Solution-
 
Given-

 Old corner coordinates of the triangle = A (3, 4, 1), B(6, 4, 2), C(5, 6, 3)
 Reflection has to be taken on the XY plane
 

For Coordinates A(3, 4, 1)


 
Let the new coordinates of corner A after reflection = (X new, Ynew, Znew).
 
Applying the reflection equations, we have-

 Xnew = Xold = 3

28
 Ynew = Yold = 4
 Znew = -Zold = -1
 
Thus, New coordinates of corner A after reflection = (3, 4, -1).
 

For Coordinates B(6, 4, 2)


 
Let the new coordinates of corner B after reflection = (X new, Ynew, Znew).
 
Applying the reflection equations, we have-

 Xnew = Xold = 6
 Ynew = Yold = 4
 Znew = -Zold = -2
 
Thus, New coordinates of corner B after reflection = (6, 4, -2).
 

For Coordinates C(5, 6, 3)


 
Let the new coordinates of corner C after reflection = (X new, Ynew, Znew).
 
Applying the reflection equations, we have-

 Xnew = Xold = 5
 Ynew = Yold = 6
 Znew = -Zold = -3
 
Thus, New coordinates of corner C after reflection = (5, 6, -3).
Thus, New coordinates of the triangle after reflection = A (3, 4, -1), B(6, 4, -2), C(5, 6,
-3).
 

Problem-02:
 
Given a 3D triangle with coordinate points A(3, 4, 1), B(6, 4, 2), C(5, 6, 3). Apply the
reflection on the XZ plane and find out the new coordinates of the object.
 

29
Solution-
 
Given-

 Old corner coordinates of the triangle = A (3, 4, 1), B(6, 4, 2), C(5, 6, 3)
 Reflection has to be taken on the XZ plane
 

For Coordinates A(3, 4, 1)


 
Let the new coordinates of corner A after reflection = (X new, Ynew, Znew).
 
Applying the reflection equations, we have-

 Xnew = Xold = 3
 Ynew = -Yold = -4
 Znew = Zold = 1
 
Thus, New coordinates of corner A after reflection = (3, -4, 1).
 

For Coordinates B(6, 4, 2)


 
Let the new coordinates of corner B after reflection = (X new, Ynew, Znew).
 
Applying the reflection equations, we have-

 Xnew = Xold = 6
 Ynew = -Yold = -4
 Znew = Zold = 2
 
Thus, New coordinates of corner B after reflection = (6, -4, 2).
 

For Coordinates C(5, 6, 3)


 
Let the new coordinates of corner C after reflection = (X new, Ynew, Znew).
 
Applying the reflection equations, we have-

30
 Xnew = Xold = 5
 Ynew = -Yold = -6
 Znew = Zold = 3
 
Thus, New coordinates of corner C after reflection = (5, -6, 3).
Thus, New coordinates of the triangle after reflection = A (3, -4, 1), B(6, -4, 2), C(5, -6,
3).
Affine transformations
The most general transformation model is the affine transformation, where changes in
position, size and shape of a network are allowed. The scale factor of such a transformation
depends on the orientation but not on the position within the net. Hence the lengths of all
lines in a certain direction are multiplied by the same scalar.

3D affine transformations have been widely used in computer vision and particularly, in the
area of model-based object recognition, and they can have involved different number of
parameters involved:

31

Common questions

Powered by AI

Translation in computer graphics moves an object from one location to another within a coordinate space while preserving its shape and size; for instance, a 2D square when translated with a vector (1, 1) results in each vertex moving to new respective coordinates, maintaining its side lengths and angles. Conversely, shearing alters an object's shape by displacing points along a plane based on other axis dimensions, like when in a 3D context, applying shear parameters on a triangle's vertices along an axis results in the object's corners being skewed, distorting the original angles and potentially changing its visual appearance. Both transformations impact positioning and shape distinctly, with translation purely positional and shearing explicitly orientational .

In 2D translation, an object is moved within a two-dimensional plane using a translation vector (Tx, Ty), where each coordinate of the object is adjusted as 'Xnew = Xold + Tx' and 'Ynew = Yold + Ty'. In matrix form, this is represented as a 3x3 transformation matrix applied to homogeneous coordinates. In contrast, 3D translation involves moving an object in three-dimensional space with a translation vector (Tx, Ty, Tz), and the coordinates are updated as 'Xnew = Xold + Tx', 'Ynew = Yold + Ty', and 'Znew = Zold + Tz'. This, too, is represented using a 4x4 transformation matrix for homogeneous coordinates. The main difference lies in the additional Z component in 3D translation, which allows movement along the depth axis .

Applying the translation vector (Tx, Ty, Tz) = (1, 1, 2) to the coordinates, the points move to A'(1, 4, 3), B'(4, 4, 4), C'(4, 1, 2), and D'(1, 1, 2) respectively. This translation highlights the cumulative effect of shifting all the object’s coordinates uniformly, resulting in the entire object maintaining its original shape and orientation while changing its position in 3D space. The cumulative effect is crucial as it effectively relocates the object without altering any intrinsic geometric properties .

2D rotation involves rotating an object around a point (typically the origin) within a two-dimensional plane using an angle θ. The transformation equations are 'Xnew = Xold * cosθ - Yold * sinθ' and 'Ynew = Xold * sinθ + Yold * cosθ', represented as a 3x3 matrix for homogeneous coordinates. In contrast, 3D rotation requires specifying an axis of rotation, and the matrix representation is more complex, often involving rotation matrices or quaternions depending on the axis around which rotation occurs. Both types of rotations are commonly used in computer graphics for animations and aligning objects; however, 3D rotations provide more degrees of freedom, such as yaw, pitch, and roll, which are not possible in 2D .

Using matrices for rotation transformations provides significant computational advantages, including the ability to combine multiple transformations into a single matrix operation. This consolidation simplifies computation, enhances processing speed, and ensures precision when applying successive transformations like scaling and translation alongside rotation. However, limitations may arise from floating-point inaccuracies, especially where compounded transformations are concerned, as well as the mathematical complexity when dealing with 3D rotations around arbitrary axes, which may necessitate more involved calculations such as Euler angles or quaternions .

Homogeneous coordinates introduce an additional coordinate – a '1' – which allows transformation matrices to be used in a consistent way for various geometric transformations, such as translation, rotation, and scaling. This simplifies the mathematics of transformations because all transformations, including translation which would normally require vector addition, can be expressed as matrix multiplications. In 2D, this means using a 3x3 matrix, and in 3D, a 4x4 matrix. By using homogeneous coordinates, it becomes possible to chain multiple transformations easily by composing their matrices, thereby simplifying the often complex task of transformation computations .

In 3D shearing, each axis affects the object differently: X-axis shearing moves point coordinates based on their Y and Z values, altering 'Ynew = Yold + Shy * Xold' and 'Znew = Zold + Shz * Xold', which skews the object along the Y and Z planes. Y-axis shearing changes 'Xnew = Xold + Shx * Yold' and 'Znew = Zold + Shz * Yold', skewing it along the X and Z planes. Lastly, Z-axis shearing modifies 'Xnew = Xold + Shx * Zold' and 'Ynew = Yold + Shy * Zold', affecting the X and Y planes. These transformations change the object’s shape by skewing it in specified directions, thereby affecting its visual orientation and dimensions without altering the actual size .

When applying a 30-degree rotation to a line segment, it's crucial to consider both the pivot point (origin here) and the trigonometric transformation formulas. Each endpoint undergoes rotation independently: using 'Xnew = Xold * cosθ - Yold * sinθ' and 'Ynew = Xold * sinθ + Yold * cosθ'. For the point (4, 4), the new coordinates are approximately (1.46, 5.46) post-rotation. The rotation affects coordinates by re-orienting them relative to the pivot, effectively altering the segment's slope and endpoint positions, while maintaining linearity of the transformed object .

Reflection in computer graphics can be considered akin to a 180-degree rotation; however, it is specifically about mirroring the object across a line or plane. For a 3D reflection relative to the XY plane, the object's new coordinates are calculated as 'Xnew = Xold', 'Ynew = Yold', and 'Znew = -Zold'. Mathematically, reflection is achieved using a matrix that inverts the Z-axis, similar to a 180-degree rotation about the XY plane, thus flipping the object's depth and producing a mirrored effect without altering its size or shape .

To determine the rotation angle θ from a 3x3 rotation matrix in homogeneous coordinates, we use the properties of the matrix elements. Typically, the elements at positions (1,1) and (2,2) correspond to 'cosθ', and the off-diagonal elements at (1,2) and (2,1) correspond to '-sinθ' and 'sinθ', respectively. By taking the arccosine of the value at (1,1), we can find θ, keeping in mind any trigonometric function ambiguities, such as potential quadrant issues. A practical challenge includes numerical imprecision from floating-point arithmetic that can lead to incorrect angle interpretation, especially in cases of small angles or near-zero determinants .

You might also like