IT601 • Computer Graphics & Multimedia

Computer Graphics Unit 3 Notes

Complete RGPV exam-oriented notes on 2D and 3D transformations, homogeneous coordinates, window-viewport mapping and clipping algorithms.

1. Introduction to Geometric Transformations

A geometric transformation is an operation that changes the position, orientation, size or shape of a graphical object.

Computer graphics systems use transformations to move, rotate, resize, mirror and distort objects. Transformations are also used for animation, viewing and conversion between coordinate systems.

Major Types

  • Translation
  • Rotation
  • Scaling
  • Reflection
  • Shearing
  • Composite transformation
Original Object | v Transformation Matrix | v Transformed Object

2. Two-Dimensional Transformations

A two-dimensional point is written as P(x,y). After transformation, the new point becomes P′(x′,y′).

Matrix representation is preferred because it provides a systematic and efficient method for transforming multiple points.

3. Translation

Translation moves an object from one position to another without changing its size, shape or orientation.
x′ = x + Tx
y′ = y + Ty

Tx and Ty are translation distances along the x and y directions.

Homogeneous Matrix

| x′ | | 1 0 Tx | | x |
| y′ | = | 0 1 Ty | | y |
| 1 | | 0 0 1 | | 1 |

Example

If P(2,3) is translated by Tx=4 and Ty=2, then P′=(6,5).

4. Rotation

Rotation turns an object through an angle θ about a fixed point.

Rotation About Origin

x′ = x cosθ − y sinθ
y′ = x sinθ + y cosθ
| x′ | | cosθ −sinθ 0 | | x |
| y′ | = | sinθ cosθ 0 | | y |
| 1 | | 0 0 1 | | 1 |

Direction

  • Positive angle: anticlockwise rotation
  • Negative angle: clockwise rotation

Rotation About an Arbitrary Point

  1. Translate the fixed point to the origin.
  2. Rotate the object.
  3. Translate the fixed point back to its original position.

5. Scaling

Scaling changes the size of an object.
x′ = Sxx
y′ = Syy
| x′ | | Sx 0 0 | | x |
| y′ | = | 0 Sy 0 | | y |
| 1 | | 0 0 1 | | 1 |

Types

  • Uniform scaling: Sx = Sy
  • Differential scaling: Sx ≠ Sy
  • Enlargement: scaling factors greater than 1
  • Reduction: scaling factors between 0 and 1

6. Reflection

Reflection creates a mirror image of an object about a selected axis or line.
Reflection About Coordinate Change
x-axis (x,y) → (x,−y)
y-axis (x,y) → (−x,y)
Origin (x,y) → (−x,−y)
Line y=x (x,y) → (y,x)

7. Shearing

Shearing changes the shape of an object by shifting one coordinate in proportion to the other coordinate.

x-Shear

x′ = x + Shxy
y′ = y

y-Shear

x′ = x
y′ = y + Shyx

Shearing is used to produce slanted objects, italic text and perspective-like effects.

8. Homogeneous Coordinates

Homogeneous coordinates represent a 2D point (x,y) as (x,y,1).

Their main advantage is that all basic transformations, including translation, can be represented using matrix multiplication.

Advantages

  • Uniform matrix representation
  • Easy combination of transformations
  • Efficient hardware implementation
  • Useful for perspective projection

9. Composite Transformations

A composite transformation is obtained by multiplying the matrices of two or more basic transformations.

Matrix multiplication is not commutative. Therefore, the order of transformations matters.

M = M3 × M2 × M1

Example

To rotate an object about a fixed point:

  1. Translate the fixed point to the origin.
  2. Perform rotation.
  3. Translate back.
Important: Changing the multiplication order changes the final result.

10. Three-Dimensional Transformations

A 3D point is represented as P(x,y,z), or in homogeneous form as (x,y,z,1).

3D Translation

x′ = x + Tx
y′ = y + Ty
z′ = z + Tz

3D Scaling

x′ = Sxx
y′ = Syy
z′ = Szz

3D Rotation

Rotation may be performed about the x-axis, y-axis or z-axis.

Rotation About z-axis

x′ = x cosθ − y sinθ
y′ = x sinθ + y cosθ
z′ = z

Applications

  • 3D modeling
  • Animation
  • Games
  • Simulation
  • Virtual reality

11. Viewing Transformation

Viewing transformation converts objects from world coordinates to viewing or screen coordinates.

It determines which part of a scene is visible and how that part is mapped onto the display.

World Coordinates | v Viewing Transformation | v Normalized Coordinates | v Viewport Mapping | v Screen Coordinates

12. Window and Viewport Transformation

A window is the selected rectangular region in world coordinates, while a viewport is the rectangular area on the display where the window is shown.

Mapping Formula

xv = xvmin + (x - xwmin) (xvmax - xvmin) / (xwmax - xwmin)
yv = yvmin + (y - ywmin) (yvmax - yvmin) / (ywmax - ywmin)

Steps

  1. Translate the window origin to the coordinate origin.
  2. Scale the window to viewport dimensions.
  3. Translate the result to the viewport position.

13. Clipping

Clipping is the process of removing the portions of graphical objects that lie outside a selected clipping window.

Types of Clipping

  • Point clipping
  • Line clipping
  • Polygon clipping
  • Curve clipping
  • Text clipping

Point Clipping Condition

xmin ≤ x ≤ xmax
ymin ≤ y ≤ ymax

14. Cohen-Sutherland Line Clipping Algorithm

Cohen-Sutherland algorithm divides the plane into nine regions and assigns a four-bit region code to every line endpoint.

Region Code

1001 | 1000 | 1010 -----+------+----- 0001 | 0000 | 0010 -----+------+----- 0101 | 0100 | 0110

The bits generally represent Top, Bottom, Right and Left.

Cases

  • If both endpoint codes are 0000, accept the line.
  • If bitwise AND of both codes is non-zero, reject the line.
  • Otherwise, calculate an intersection and repeat.
Step 1: Compute region codes for both endpoints. Step 2: If both codes are 0000, accept the line. Step 3: If logical AND is not 0000, reject the line. Step 4: Otherwise choose an endpoint outside the window. Step 5: Find its intersection with a window boundary. Step 6: Replace the endpoint and repeat.

Advantages

  • Simple and efficient for obvious acceptance or rejection.
  • Uses bit operations.
  • Suitable for rectangular clipping windows.

Disadvantages

  • May require repeated intersection calculations.
  • Less efficient for lines crossing many boundaries.

15. Liang-Barsky Line Clipping Algorithm

Liang-Barsky algorithm uses the parametric equation of a line and calculates the entering and leaving parameter values.
x = x₁ + u(x₂ − x₁)
y = y₁ + u(y₂ − y₁)
0 ≤ u ≤ 1

Four inequalities are formed for the clipping boundaries. Parameter values are classified as potentially entering or leaving.

Advantages

  • Requires fewer intersection calculations.
  • More efficient than Cohen-Sutherland for many cases.
  • Uses direct parameter range calculation.

Disadvantages

  • Mathematical derivation is more complex.
  • Less intuitive for beginners.

Cohen-Sutherland vs Liang-Barsky

Basis Cohen-Sutherland Liang-Barsky
Main concept Region codes Parametric line equation
Computation May calculate several intersections Calculates parameter limits
Ease Easy to understand More mathematical
Efficiency Good Generally better

16. Polygon Clipping

Polygon clipping removes the portions of a polygon that lie outside the clipping window.

Sutherland-Hodgman Polygon Clipping

The polygon is clipped successively against the left, right, bottom and top boundaries. For each polygon edge, four cases are considered.

Start Point End Point Output
Inside Inside Output endpoint
Inside Outside Output intersection
Outside Inside Output intersection and endpoint
Outside Outside No output

Advantages

  • Simple for convex clipping windows.
  • Processes one boundary at a time.
  • Easy to implement.

Limitation

It may not directly handle complex concave clipping windows.

Complete Unit Summary

  • Transformations modify object position, size, orientation and shape.
  • Translation moves an object.
  • Rotation changes orientation.
  • Scaling changes size.
  • Reflection creates a mirror image.
  • Shearing slants the object.
  • Homogeneous coordinates provide a uniform matrix form.
  • Composite transformation combines multiple operations.
  • Window-viewport transformation maps selected world coordinates to the display.
  • Clipping removes invisible portions of objects.
  • Cohen-Sutherland uses region codes.
  • Liang-Barsky uses parametric equations.
  • Sutherland-Hodgman clips polygons boundary by boundary.

Important RGPV Exam Questions

Long Answer Questions

  1. Explain translation, rotation and scaling with homogeneous transformation matrices.
  2. What are composite transformations? Explain rotation about an arbitrary point.
  3. Explain reflection and shearing transformations with matrices.
  4. Explain 3D translation, scaling and rotation.
  5. Explain window-to-viewport transformation with derivation.
  6. Explain Cohen-Sutherland line clipping algorithm with region codes.
  7. Explain Liang-Barsky line clipping algorithm and compare it with Cohen-Sutherland.
  8. Explain Sutherland-Hodgman polygon clipping algorithm.

Short Answer Questions

  1. Define homogeneous coordinates.
  2. What is composite transformation?
  3. Define window and viewport.
  4. What is clipping?
  5. Write the reflection matrix about x-axis.
  6. What is shearing?
  7. What is a region code?
  8. State one advantage of Liang-Barsky algorithm.
Common Exam Mistake: Always write matrices in the correct order. Composite transformations are order-dependent.

Exam Writing Strategy

For Transformation Questions: Write definition, coordinate equations, homogeneous matrix, one numerical example and applications.
For Clipping Questions: Draw the clipping window, explain all cases, write algorithm steps and include advantages and disadvantages.

Download Study Resources

Complete Hand Written Notes PDF

Unit 3 Notes.

Open Notes

Frequently Asked Questions

It is an operation that changes the position, size, orientation or shape of an object.
They allow translation and other transformations to be expressed using a common matrix multiplication form.
A window selects a region in world coordinates, while a viewport defines where that region is displayed on the screen.
Liang-Barsky is generally more efficient because it calculates parameter limits and usually requires fewer intersections.
Yes. The page saves the selected dark or light theme in browser localStorage.