2D and 3D Geometric Transformations, Viewing and Rendering
The Viewing Pipeline, Window-to-Viewport, and Clipping
A scene is defined in WORLD coordinates, but a program picks a window — a rectangular region of world coordinates it wants to display — and maps it to a viewport — a rectangular region of the actual screen/device it appears in. The window-to-viewport transform is itself a composite transform: translate the window's corner to the origin, scale by the ratio of viewport size to window size, then translate to the viewport's actual screen position — the classic worked example of composing several basic transforms into one useful matrix. Clipping then discards whatever falls outside the window BEFORE this mapping (clipping in world/window coordinates is more efficient than clipping every pixel after mapping to the screen).
- Cohen-Sutherland line clipping: assigns each endpoint a 4-bit OUTCODE recording which of the window's four boundaries it lies beyond; a line is trivially ACCEPTED if both outcodes are 0000, trivially REJECTED if the bitwise AND of the two outcodes is non-zero (both endpoints share a violated boundary, so the whole segment must lie outside it), and otherwise clipped iteratively against one boundary at a time.
- Sutherland-Hodgman polygon clipping: clips a polygon against one window edge at a time, processing the polygon's vertices in order and outputting 0, 1 or 2 vertices per input vertex depending on whether it and its predecessor are inside/outside that edge — repeating for all four window edges in turn correctly clips even a concave polygon.
3D Object Representation: Polygon and Quadric Surfaces, Splines
- Polygon surfaces (meshes): a 3D solid is approximated by a mesh of flat polygonal faces (usually triangles), each stored as a list of vertex coordinates plus connectivity — the standard representation for arbitrary, irregular shapes and the format most rendering hardware is built around.
- Quadric surfaces: described by a single second-degree (quadratic) equation in x, y, z — spheres, ellipsoids, cylinders, cones and paraboloids are all quadrics, and being described by one compact equation rather than a mesh of many polygons is exactly what makes them cheap to represent and test exactly (no polygon-approximation error).
- Bezier curves: defined by n+1 control points via Bernstein polynomial blending; the curve passes through the FIRST and LAST control points only (interpolating them) while the interior control points merely INFLUENCE its shape (approximating it), and the whole curve lies within the convex hull of its control points — moving any one control point affects the ENTIRE curve's shape (no local control).
- B-spline curves: generalise Bezier curves with a KNOT VECTOR that gives each control point only LOCAL influence — moving one control point changes only a bounded neighbourhood of the curve, unlike a Bezier curve, which is the single most-tested distinction between the two in this sub-item.
Illumination Models, Polygon Rendering and Projections
A basic illumination (lighting) model sums three components: AMBIENT light (a constant approximation of indirect, scattered light with no direction), DIFFUSE reflection (depends on the angle between the surface normal and the light direction via Lambert's cosine law — brightest when the light is head-on, zero when it grazes the surface, but scattered equally in every viewing direction), and SPECULAR reflection (the bright highlight that depends additionally on the VIEWER's direction, tightest and brightest for a shiny surface and modelled by the Phong model as a high power of the cosine between the reflected-light direction and the viewer direction).
- Polygon rendering methods: CONSTANT (flat) shading colours a whole polygon face uniformly using one normal per face — fast, but visibly faceted; GOURAUD shading interpolates COLOUR values computed at each vertex across the face — smoother, but can miss a sharp specular highlight that falls between vertices; PHONG shading interpolates the surface NORMAL itself across the face and computes lighting per pixel — the most accurate and most expensive, capturing highlights the other two miss.
- Projection transforms: PARALLEL (orthographic) projection preserves relative proportions regardless of distance from the viewer (parallel lines stay parallel) and is used for technical/engineering drawing; PERSPECTIVE projection converges parallel lines toward vanishing points and makes distant objects appear smaller, matching how human vision and cameras actually work, at the cost of distorting exact measurements.
Key takeaways
- Homogeneous coordinates turn translation into a matrix multiply too, letting several transforms compose into one matrix — but composite order is not commutative.
- Window-to-viewport mapping is itself a composite transform; clipping (Cohen-Sutherland for lines via outcodes, Sutherland-Hodgman for polygons edge by edge) happens before this mapping.
- Bezier curves interpolate only their first/last control points with global influence; B-splines generalise this with local control via a knot vector.
- Illumination sums ambient, diffuse (Lambert, direction-independent for the viewer) and specular (Phong, viewer-direction-dependent) components.
- Flat shading is fastest but faceted; Gouraud interpolates vertex colours; Phong interpolates normals per pixel and is the most accurate but most expensive.
Practice questions (8)
Attempt each one before opening the answer. Every explanation names the tempting wrong option as well as the right one, because that is where marks are lost.
Homogeneous coordinates are introduced in 2D graphics chiefly because:
Show answer
Answer: A — Translation is affine, not linear, and cannot be expressed as a 2x2 matrix multiply on (x, y) alone
Adding a third coordinate lets translation, like scaling and rotation, be expressed as a matrix multiply, so a sequence of transforms can be composed into one matrix rather than applied as separate operations of different kinds.Rotating an off-origin object and then translating it, compared to translating it first and then rotating:
Show answer
Answer: A — Generally produces a different final result, since matrix multiplication does not commute
Rotating first spins the object about the origin before it moves; translating first moves it away from the origin so a subsequent rotation swings it through a different arc — the order genuinely changes the outcome.In Cohen-Sutherland line clipping, a line is trivially rejected when:
Show answer
Answer: A — The bitwise AND of the two endpoints' outcodes is non-zero
A non-zero AND means both endpoints lie beyond the same boundary, so the entire segment must lie on the outside of that boundary and can be discarded with no further clipping computation; a zero OR (both outcodes 0000) is instead the trivial-ACCEPT case.A quadric surface, such as a sphere or a cylinder, is best described as:
Show answer
Answer: A — A surface described by a single second-degree equation in x, y, z
Quadrics are compactly described by one quadratic equation, which is exactly what lets them be represented and rendered exactly rather than approximated by a polygon mesh with its attendant approximation error.The key difference between a Bezier curve and a B-spline curve is:
Show answer
Answer: A — A B-spline gives each control point only local influence, via a knot vector; moving a Bezier control point affects the whole curve
A Bezier curve's control points each influence the ENTIRE curve's shape (global control); a B-spline's knot vector restricts each control point's influence to a bounded neighbourhood (local control) — the single most commonly tested distinction between the two.Diffuse reflection in the basic illumination model depends on:
Show answer
Answer: A — The angle between the surface normal and the light source direction, but not the viewer's direction
Lambert's cosine law makes diffuse reflection depend only on the angle between the surface normal and the incoming light direction, scattering equally in every viewing direction — it is specular reflection, not diffuse, that additionally depends on the viewer's own direction.Which of the following are true of Phong shading compared to Gouraud shading? (More than one option may be correct.)
Show answer
Answer: A — Phong interpolates the surface normal per pixel; Gouraud interpolates colour values computed at the vertices; B — Phong is generally more computationally expensive; C — Phong can capture a sharp specular highlight that falls between vertices, which Gouraud may miss
Phong's per-pixel normal interpolation and lighting computation is more accurate and more expensive than Gouraud's per-vertex colour interpolation, and this accuracy is exactly what lets it capture highlights Gouraud's coarser colour interpolation smooths away.Name the type of projection that converges parallel lines toward vanishing points and makes distant objects appear smaller, matching how human vision actually works.
Numerical answer — type the value.
Show answer
Answer: perspective
Perspective projection distorts exact parallel/proportional relationships (unlike orthographic/parallel projection) in exchange for matching natural depth perception, which is why it is used for realistic rendering rather than technical drawing.