Two dimensional transformations, windowing and clipping — Unit 2 Notes (Computer Graphics and Multimedia)

BCS604 · Unit 2

Two dimensional transformations, windowing and clipping notes — Unit 2

Free unit-wise study notes on two dimensional transformations, windowing and clipping for Computer Graphics and Multimedia, Semester 6 of B.Tech — Computer Science & Engineering — key concepts, examples, important questions and a revision checklist for semester exams.

Two dimensional transformations, windowing and clipping

Notebook — 14 pages

Page 1

Wink Notes

B.Tech CSE — 6th Semester

Computer Graphics and Multimedia

Unit - 2

1. 2D Geometric Transformations

Operations that are applied to the geometric description of an object to change its position, orientation, or size are called geometric transformations. They are essential for modeling and viewing.

1.1 The Standard Transformations

  • Translation: Shifting an object along a straight line path.
  • Rotation: Repositioning an object along a circular path.
  • Scaling: Altering the size of an object.
  • Reflection: Creating a mirror image.
  • Shearing: Distorting the shape of an object.

Next — Translation

1 of 14

Page 2

Wink Notes

B.Tech CSE — 6th Semester

Computer Graphics and Multimedia

Unit - 2

2. Translation

A translation moves an object to a different position on the screen. You translate a 2D point by adding translation distances, `tx` and `ty`, to the original coordinate position `(x, y)` to move the point to a new position `(x', y')`.

2.1 The Equations

`x' = x + tx`

`y' = y + ty`

To translate a polygon, we simply apply the translation equation to every vertex in the polygon, and then redraw the lines between the new vertex positions. Translation is a rigid-body transformation; it moves objects without deformation.

Next — Rotation

2 of 14

Page 3

Wink Notes

B.Tech CSE — 6th Semester

Computer Graphics and Multimedia

Unit - 2

3. Rotation

A 2D rotation is applied to an object by repositioning it along a circular path in the xy plane.

3.1 Rotation Parameters

To rotate a point, you must specify a Rotation Angle `θ` and the position `(xr, yr)` of the Rotation Point (or pivot point). Positive angles indicate counter-clockwise rotation.

3.2 Equations (Rotating about Origin)

`x' = x cos(θ) - y sin(θ)`

`y' = x sin(θ) + y cos(θ)`

Next — Scaling

3 of 14

Page 4

Wink Notes

B.Tech CSE — 6th Semester

Computer Graphics and Multimedia

Unit - 2

4. Scaling

A scaling transformation alters the size of an object. This operation can be carried out for polygons by multiplying the coordinate values `(x,y)` of each vertex by scaling factors `sx` and `sy`.

4.1 The Equations

`x' = x * sx`

`y' = y * sy`

4.2 Uniform vs Differential Scaling

If `sx = sy`, the scaling is uniform (the object maintains its original proportions). If they are unequal, it is differential scaling, and the object's proportions will be distorted. Scaling factors `< 1` shrink the object; factors `> 1` enlarge it.

Next — Homogeneous Coordinates

4 of 14

Page 5

Wink Notes

B.Tech CSE — 6th Semester

Computer Graphics and Multimedia

Unit - 2

5. Homogeneous Coordinates

Notice that scaling and rotation use matrix multiplication, but translation uses matrix addition. This makes it impossible to combine all three operations into a single mathematical formula.

5.1 The Solution

To treat all transformations identically (as multiplications), we add a third coordinate to our 2D vectors, changing `[x, y]` to `[x, y, 1]`. This is called a Homogeneous Coordinate.

Now, our transformation matrices become 3x3 matrices instead of 2x2. Translation can now be represented entirely through matrix multiplication, unifying the math.

Next — Composite Transformations

5 of 14

Page 6

Wink Notes

B.Tech CSE — 6th Semester

Computer Graphics and Multimedia

Unit - 2

6. Composite Transformations

With homogeneous coordinates, we can set up a sequence of transformations as a series of matrix multiplications. We can multiply the transformation matrices together to form a single 'Composite Matrix'.

6.1 Efficiency

If a 10,000-vertex polygon needs to be scaled, rotated, and translated, we do NOT apply three separate math operations to all 10,000 vertices. We multiply the Scale, Rotate, and Translate matrices together ONCE to create a Composite Matrix. Then we multiply the vertices by this single matrix.

Note: Matrix multiplication is non-commutative. Order matters. Translate-then-Rotate yields a different result than Rotate-then-Translate.

Next — Pivot-Point Rotation

6 of 14

Page 7

Wink Notes

B.Tech CSE — 6th Semester

Computer Graphics and Multimedia

Unit - 2

7. General Pivot-Point Rotation

The standard rotation matrix only rotates an object around the origin `(0,0)`. What if we want to rotate a square around its own center point `(cx, cy)`?

7.1 The Three-Step Process

  • 1. Translate: Move the object so that the pivot point `(cx, cy)` is moved to the origin `(0,0)`. Apply translation matrix `T(-cx, -cy)`.
  • 2. Rotate: Now apply the standard rotation matrix `R(θ)`.
  • 3. Translate Back: Move the object back to its original location by applying translation matrix `T(cx, cy)`.

The composite matrix is `T(cx, cy) R(θ) T(-cx, -cy)`.

Next — Reflection and Shear

7 of 14

Page 8

Wink Notes

B.Tech CSE — 6th Semester

Computer Graphics and Multimedia

Unit - 2

8. Reflection and Shear

8.1 Reflection

Produces a mirror image. A reflection over the Y-axis reverses all X coordinates (`x' = -x`, `y' = y`). A reflection through the origin reverses both.

8.2 Shearing

Distorts the shape of an object such that the transformed shape appears as if the object were composed of internal layers that had been caused to slide over each other. It slants the shape.

An X-direction shear alters X values based on the Y coordinate: `x' = x + shx * y`. The Y values remain unchanged.

Next — Viewing Pipeline

8 of 14

Page 9

Wink Notes

B.Tech CSE — 6th Semester

Computer Graphics and Multimedia

Unit - 2

9. The 2D Viewing Pipeline

How do we get a mathematical model onto the physical monitor?

  • Modeling Coordinates (Local): The coordinate system used to design a single object (e.g., a chair).
  • World Coordinates: The unified space where all objects are assembled together into a scene.
  • Viewing Coordinates: The world as seen from the perspective of the camera.
  • Device Coordinates (Screen): The final physical pixels on the monitor.

Next — Window and Viewport

9 of 14

Page 10

Wink Notes

B.Tech CSE — 6th Semester

Computer Graphics and Multimedia

Unit - 2

10. Window-to-Viewport Coordinate Transformation

A Window defines what is to be viewed (a rectangular boundary in World Coordinates).

A Viewport defines where it is to be displayed (a rectangular boundary in Device Coordinates/Pixels on the screen).

10.1 The Mapping

The mapping process must preserve relative positions. If a point is exactly in the center of the Window, it must be mapped to exactly the center of the Viewport. This requires calculating scaling factors `sx = (vp_xmax - vp_xmin) / (w_xmax - w_xmin)`.

Next — Clipping Concepts

10 of 14

Page 11

Wink Notes

B.Tech CSE — 6th Semester

Computer Graphics and Multimedia

Unit - 2

11. Clipping Operations

Any procedure that identifies those portions of a picture that are either inside or outside of a specified region of space is referred to as a clipping algorithm. The region is called the clip window.

11.1 Types of Clipping

  • Point Clipping
  • Line Clipping
  • Area (Polygon) Clipping
  • Curve Clipping
  • Text Clipping

Next — Cohen-Sutherland

11 of 14

Page 12

Wink Notes

B.Tech CSE — 6th Semester

Computer Graphics and Multimedia

Unit - 2

12. Cohen-Sutherland Line Clipping

One of the oldest and most popular line-clipping algorithms. It works by rapidly discarding lines that clearly fall outside the window.

12.1 Region Codes

The algorithm divides the 2D space into 9 regions. Each region is assigned a 4-bit code. The central window is `0000`.

The bits represent `Top, Bottom, Right, Left`. (e.g., A point above and to the left of the window has the code `1001`).

Both endpoints of a line are assigned their region codes.

Next — Cohen-Sutherland Logic

12 of 14

Page 13

Wink Notes

B.Tech CSE — 6th Semester

Computer Graphics and Multimedia

Unit - 2

13. Cohen-Sutherland: The Logic

13.1 Trivial Acceptance and Rejection

  • Trivial Accept: If both endpoints have code `0000`, the entire line is inside the window. Draw it.
  • Trivial Reject: Perform a bitwise AND on the two endpoint codes. If the result is NOT `0000`, both endpoints share a common outside region (e.g., they are both above the top edge). The line is completely invisible. Discard it.

If neither case is met, the line crosses a window boundary. We mathematically calculate the intersection point, chop the line in half, assign a new region code to the intersection point, and run the test again.

Next — Sutherland-Hodgman

13 of 14

Page 14

Wink Notes

B.Tech CSE — 6th Semester

Computer Graphics and Multimedia

Unit - 2

14. Sutherland-Hodgman Polygon Clipping

A polygon is a closed shape. When clipped, the remaining visible portion must also be a closed shape.

14.1 The Pipeline

Instead of dealing with all 4 window edges simultaneously, the algorithm clips the entire polygon against ONE window edge at a time.

It traverses the vertices of the polygon. For each edge of the polygon, it looks at the two vertices. Are we moving from the Inside to the Outside of the clip edge? Or Outside to Inside? Based on this, it outputs a new list of vertices.

This new list of vertices is passed to the next clip edge (e.g., Left -> Right -> Bottom -> Top).

14 of 14

Continue in this subject