Unit 2 of 4 · M.Sc IT Sem 3

Unit 2: 2D transformations and viewing

Computer Graphics notes · PTU syllabus (PGCA1919)

3 min read5 topics10 exam questions
On this page
  1. Unit summary
  2. Window-to-viewport transformation
  3. Scaling, translation and rotation
  4. Reflection and shear
  5. Homogeneous coordinates
  6. Composite transformations
  7. Key terms
  8. Quick revision
  9. Important questions

Unit summary

Transformations move, resize and orient objects and map them from the world to the screen. This unit covers the window-to-viewport transformation, scaling, translation, rotation, reflection and shear, homogeneous coordinates and composite transformations.

After this unit you can

  • Map a window to a viewport
  • Apply basic transformations
  • Use homogeneous coordinates and matrices
  • Build composite transformations

PTU syllabus topics

  • Window-to-viewport transformation
  • scaling
  • translation
  • rotation
  • reflection
  • shear
  • homogeneous coordinates
  • composite transformations
Key formulas2D transformation matrices (homogeneous)
  • Translation

    [1 0 tx; 0 1 ty; 0 0 1]

  • Scaling

    [sx 0 0; 0 sy 0; 0 0 1]

  • Rotation

    [cosθ −sinθ 0; sinθ cosθ 0; 0 0 1]

  • Composite

    Multiply matrices right to left in order of application

1

Topic 1

Window-to-viewport transformation

  • Window: the region of the world (in world coordinates) chosen for display. Viewport: the area of the screen (device coordinates) where it is shown.
Key formulasWindow-to-viewport mapping
  • x-scale

    sx = (xvmax − xvmin) ÷ (xwmax − xwmin)

  • y-scale

    sy = (yvmax − yvmin) ÷ (ywmax − ywmin)

  • Mapping

    xv = xvmin + (xw − xwmin)·sx; yv = yvmin + (yw − ywmin)·sy

Process2D viewing pipeline
  1. 1Model coordinates
  2. 2World coordinates
  3. 3Clip to the window
  4. 4Normalised device coordinates
  5. 5Map to the viewport (device coordinates)

Example

Window (0, 0)–(100, 100) mapped to viewport (200, 100)–(400, 300): sx = sy = 2. Point (30, 50) → (200 + 30 × 2, 100 + 50 × 2) = (260, 200).

2

Topic 2

Scaling, translation and rotation

Key formulasBasic 2D transformations
  • Translation

    x′ = x + tx, y′ = y + ty

  • Scaling about the origin

    x′ = sx·x, y′ = sy·y

  • Rotation about the origin by θ (anticlockwise)

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

TransformationRow 1Row 2Row 3
Translation T1 0 tx0 1 ty0 0 1
Scaling Ssx 0 00 sy 00 0 1
Rotation Rcos θ −sin θ 0sin θ cos θ 00 0 1

Example

Rotate point (4, 2) by 90° about the origin: x′ = 4·0 − 2·1 = −2, y′ = 4·1 + 2·0 = 4 → (−2, 4).

3

Topic 3

Reflection and shear

Key termsReflection and shear
Reflection about the x-axis
(x, y) → (x, −y)
Reflection about the y-axis
(x, y) → (−x, y)
Reflection about the origin
(x, y) → (−x, −y)
Reflection about the line y = x
(x, y) → (y, x)
X-shear
x′ = x + shx·y, y′ = y
Y-shear
x′ = x, y′ = y + shy·x
4

Topic 4

Homogeneous coordinates

  • Cartesian coordinates (x, y) locate points relative to perpendicular axes.
  • Homogeneous coordinates write a 2D point as (x, y, 1), or (xh, yh, h) with x = xh ÷ h. This lets all transformations, including translation, be written as 3 × 3 matrix multiplications, so a sequence of transformations combines into one matrix.
5

Topic 5

Composite transformations

ProcessRotation about a fixed point (xr, yr)
  1. 1Translate the point to the origin: T(−xr, −yr)
  2. 2Rotate by θ: R(θ)
  3. 3Translate back: T(xr, yr)
  4. 4Composite matrix M = T(xr, yr) · R(θ) · T(−xr, −yr)

Example

Scale the square (2,2), (4,2), (4,4), (2,4) by 2 about its corner (2, 2): translate by (−2, −2), scale by 2, translate back → (2,2), (6,2), (6,6), (2,6).

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

Example

Reflect a point about the line y = x + 2: translate by (0, −2), reflect about y = x, translate by (0, 2). Point (1, 1) → (1, −1) → (−1, 1) → (−1, 3).

Key terms

Window
Region of the world chosen for display
Viewport
Screen region where the window appears
Homogeneous coordinates
(x, y, 1) form enabling matrix translation
Shear
Transformation slanting a shape
Composite transformation
Product of several transformation matrices

Quick revision

  • xv = xvmin + (xw − xwmin) × sx; same for y.
  • Translation, scaling, rotation equations and matrices.
  • Reflections about axes, origin and y = x; x- and y-shear.
  • 3 × 3 matrices; order of multiplication matters.
  • Fixed-point scaling and rotation; reflection about an arbitrary line.

Important exam questions

Practice questions written to the PTU exam pattern for this unit's syllabus: short answers (Section A style) and long answers (Sections B and C style).

Short-answer questions

  1. Q1.Distinguish a window and a viewport.
  2. Q2.Write the scaling matrix in homogeneous form.
  3. Q3.Rotate (2, 0) by 90° about the origin.
  4. Q4.What is an x-shear?
  5. Q5.Why are homogeneous coordinates used?
  6. Q6.Is matrix multiplication of transformations commutative?

Long-answer questions

  1. Q1.Explain the window-to-viewport transformation with an example.
  2. Q2.Explain the basic 2D transformations with matrices.
  3. Q3.Derive the matrix for rotation about an arbitrary point.
  4. Q4.Explain reflection about an arbitrary line using composite transformations.

Stuck on this unit?

Message SBS on WhatsApp for help with Computer Graphics, or to ask about studying M.Sc IT at Synetic.

WhatsApp us