Browse papers
A

Section A: Long Answer Questions

Attempt any TWO questions.

3 questions·10 marks each
1long10 marks

Explain the scan-line polygon fill algorithm and the boundary fill algorithm with examples.

Scan-Line Polygon Fill Algorithm

This is an image-space, area-filling technique that fills a polygon one horizontal scan line at a time, working from the top scan line to the bottom.

Working principle: For each scan line that crosses the polygon, find the intersection points of the scan line with all polygon edges, sort these x-coordinates in ascending order, pair them up (1st with 2nd, 3rd with 4th, ...) and fill the pixels between each pair. This relies on the fact that a closed polygon is crossed an even number of times by any horizontal line.

Steps:

  1. Find yminy_{min} and ymaxy_{max} of the polygon.
  2. For each scan line yy from yminy_{min} to ymaxy_{max}:
    • Compute the x-intersections of the scan line with each edge.
    • Sort the intersections by x.
    • Fill pixels between pairs of intersections.

Edge / vertex handling: Horizontal edges are ignored. If a scan line passes exactly through a vertex, count it once if the two edges meeting at that vertex lie on the same side, and twice if they lie on opposite sides (achieved in practice by shortening the upper edge by one scan line).

For efficiency an Edge Table (ET) and an Active Edge Table (AET) are used. Each AET entry stores (ymax,xintersection,1/m)(y_{max}, x_{intersection}, 1/m), and as yy increases by 1 the x value is incremented by 1/m1/m (coherence).

Example: For a triangle with vertices A(2,2),B(8,2),C(5,8)A(2,2), B(8,2), C(5,8), scan line y=5y=5 intersects edge ACAC at x=3.5x=3.5 and edge BCBC at x=6.5x=6.5. So pixels from x=4x=4 to x=6x=6 on row y=5y=5 are filled. Repeating for all rows fills the whole triangle.

Boundary Fill Algorithm

This is a seed-fill technique used when a region is defined by a boundary of a single specified color. Starting from an interior seed pixel, it recursively colours neighbouring pixels until the boundary color is reached.

4-connected version:

boundaryFill(x, y, fillColor, boundaryColor):
    current = getPixel(x, y)
    if current != boundaryColor and current != fillColor:
        setPixel(x, y, fillColor)
        boundaryFill(x+1, y, fillColor, boundaryColor)
        boundaryFill(x-1, y, fillColor, boundaryColor)
        boundaryFill(x, y+1, fillColor, boundaryColor)
        boundaryFill(x, y-1, fillColor, boundaryColor)
  • 4-connected: checks left, right, up, down neighbours. May fail to fill regions that are connected only diagonally.
  • 8-connected: also checks the four diagonal neighbours; fills more complex regions but can leak across thin boundaries.

Example: To fill a circle drawn in red (boundary color) with blue, pick an interior seed (e.g. the centre) and call boundaryFill(cx, cy, blue, red). The recursion spreads outward in all directions until every pixel until the red boundary is turned blue.

Comparison: The scan-line method works directly from the polygon's vertex list and is efficient/non-recursive, suited to rendering. Boundary fill works on an already-drawn region in the frame buffer (e.g. interactive paint tools) and is simple but memory-heavy due to recursion.

polygon-fill
2long10 marks

Explain Bezier curves and their properties. Derive the equation of a cubic Bezier curve with four control points.

Bezier Curves

A Bezier curve is a parametric polynomial curve defined by a set of n+1n+1 control points P0,P1,,PnP_0, P_1, \dots, P_n. For a parameter u[0,1]u \in [0,1] the curve is

P(u)=i=0nPiBi,n(u)P(u) = \sum_{i=0}^{n} P_i \, B_{i,n}(u)

where Bi,n(u)B_{i,n}(u) are the Bernstein basis polynomials

Bi,n(u)=(ni)ui(1u)ni.B_{i,n}(u) = \binom{n}{i} u^{i}(1-u)^{\,n-i}.

Properties

  1. Endpoint interpolation: the curve passes through the first and last control points, P(0)=P0P(0)=P_0 and P(1)=PnP(1)=P_n.
  2. Tangency: the curve is tangent to P0P1P_0P_1 at the start and to Pn1PnP_{n-1}P_n at the end.
  3. Convex-hull property: the curve lies entirely within the convex hull of its control points.
  4. Partition of unity: i=0nBi,n(u)=1\sum_{i=0}^{n} B_{i,n}(u) = 1, giving affine invariance (transform the curve by transforming control points).
  5. Degree: nn control points give a curve of degree n1n-1; it is non-local — moving any control point changes the whole curve.
  6. Symmetry: reversing the control points gives the same curve traced in the opposite direction.

Derivation: Cubic Bezier Curve (four control points)

For a cubic curve n=3n = 3, with control points P0,P1,P2,P3P_0, P_1, P_2, P_3. The Bernstein basis polynomials of degree 3 are:

B0,3(u)=(1u)3B_{0,3}(u) = (1-u)^3 B1,3(u)=3u(1u)2B_{1,3}(u) = 3u(1-u)^2 B2,3(u)=3u2(1u)B_{2,3}(u) = 3u^2(1-u) B3,3(u)=u3B_{3,3}(u) = u^3

Therefore

P(u)=(1u)3P0+3u(1u)2P1+3u2(1u)P2+u3P3,0u1.\boxed{P(u) = (1-u)^3 P_0 + 3u(1-u)^2 P_1 + 3u^2(1-u) P_2 + u^3 P_3}, \quad 0 \le u \le 1.

In matrix form:

P(u)=[u3u2u1][1331363033001000][P0P1P2P3].P(u) = \begin{bmatrix} u^3 & u^2 & u & 1 \end{bmatrix} \begin{bmatrix} -1 & 3 & -3 & 1 \\ 3 & -6 & 3 & 0 \\ -3 & 3 & 0 & 0 \\ 1 & 0 & 0 & 0 \end{bmatrix} \begin{bmatrix} P_0 \\ P_1 \\ P_2 \\ P_3 \end{bmatrix}.

Verification: P(0)=P0P(0)=P_0 and P(1)=P3P(1)=P_3, confirming endpoint interpolation. The derivative gives P(0)=3(P1P0)P'(0)=3(P_1-P_0) and P(1)=3(P3P2)P'(1)=3(P_3-P_2), confirming tangency to the first and last edges of the control polygon.

curves
3long10 marks

Explain Bresenham's line drawing algorithm. Using it, digitize a line from (20, 10) to (30, 18) showing all the computed pixel coordinates.

Bresenham's Line Drawing Algorithm

Bresenham's algorithm draws a line using only integer arithmetic (additions/subtractions and comparisons), avoiding the floating-point operations and rounding of DDA. At each step it chooses the pixel closest to the true line by tracking a decision parameter.

For a line with slope 0m10 \le m \le 1 from (x0,y0)(x_0,y_0) to (x1,y1)(x_1,y_1), let Δx=x1x0\Delta x = x_1-x_0, Δy=y1y0\Delta y = y_1-y_0.

Initial decision parameter: p0=2ΔyΔxp_0 = 2\Delta y - \Delta x

At each step, xx increments by 1, and:

  • If pk<0p_k < 0: choose (xk+1,yk)(x_k+1, y_k), and pk+1=pk+2Δyp_{k+1} = p_k + 2\Delta y.
  • If pk0p_k \ge 0: choose (xk+1,yk+1)(x_k+1, y_k+1), and pk+1=pk+2Δy2Δxp_{k+1} = p_k + 2\Delta y - 2\Delta x.

Digitizing the line from (20, 10) to (30, 18)

Δx=3020=10\Delta x = 30-20 = 10, Δy=1810=8\Delta y = 18-10 = 8. Slope m=8/10=0.8m = 8/10 = 0.8 (so 0<m<10<m<1, x is the driving axis).

  • 2Δy=162\Delta y = 16, 2Δy2Δx=1620=4\quad 2\Delta y - 2\Delta x = 16 - 20 = -4.
  • p0=2ΔyΔx=1610=6p_0 = 2\Delta y - \Delta x = 16 - 10 = 6.

Start by plotting (20,10)(20, 10).

kpkp_kSignNext pixel (x,y)(x,y)
060\ge 0(21, 11)
120\ge 0(22, 12)
2-2<0< 0(23, 12)
3140\ge 0(24, 13)
4100\ge 0(25, 14)
560\ge 0(26, 15)
620\ge 0(27, 16)
7-2<0< 0(28, 16)
8140\ge 0(29, 17)
9100\ge 0(30, 18)

Computed pixels: (20,10), (21,11), (22,12), (23,12), (24,13), (25,14), (26,15), (27,16), (28,16), (29,17), (30,18).

The end point (30,18)(30,18) is reached exactly, confirming the digitization is correct.

line-drawing
B

Section B: Short Answer Questions

Attempt any EIGHT questions.

9 questions·5 marks each
4short5 marks

Differentiate between object-space and image-space methods of hidden surface removal.

Hidden-surface removal methods are classified by the space in which the visibility comparison is performed.

AspectObject-space methodImage-space method
Domain of computationWorks in the world/object coordinate system on geometric primitives (polygons, surfaces)Works at the pixel level in screen/device coordinates
ComparisonCompares objects/parts of objects with each otherCompares depths at each pixel along the line of sight
PrecisionHigh (computed with object precision, resolution independent)Limited to display/pixel resolution
CostGrows rapidly with number of objects (O(n2)O(n^2) comparisons)Grows with number of pixels (resolution); good for many objects
OutputA precise list/ordering of visible surfacesA coloured pixel for each screen point
ExamplesBack-face detection, Roberts' algorithm, BSP-treeZ-buffer (depth-buffer), Scan-line, Painter's algorithm, Warnock's area-subdivision

In short, object-space methods determine visibility analytically among objects and are accurate but expensive for complex scenes, whereas image-space methods determine visibility for each pixel of the display and scale better with scene complexity but are limited to screen resolution.

hidden-surface
5short5 marks

What is a spline? Differentiate between interpolation and approximation splines.

Spline

A spline is a smooth piecewise-polynomial curve that passes through or near a set of given points called control points. The term originates from the flexible strip (also called a spline) draughtsmen used to draw smooth curves through pegs. Mathematically, a spline curve is constructed from polynomial sections joined at points called knots, with continuity conditions (C0C^0, C1C^1, C2C^2 — positional, tangent and curvature continuity) imposed at the joints so the overall curve is smooth.

Interpolation vs Approximation Splines

BasisInterpolation SplineApproximation Spline
Relation to control pointsThe curve passes through every control pointThe curve only approximates / is guided by the control points (need not pass through interior ones)
UseUsed to digitize/fit a curve to known data pointsUsed to design a smooth shape steered by a control polygon
ControlLess designer control; curve forced through points, may oscillateBetter control of smoothness; convex-hull bounded
ExampleNatural cubic spline, Hermite, Cardinal/Catmull-Rom splineBezier curve, B-spline

Summary: If the polynomial sections are fitted so the curve goes through each control point, it is an interpolation spline; if the control points only influence the shape (the curve is pulled toward but generally does not touch them), it is an approximation spline.

curvesspline
6short5 marks

Explain the key frame system in computer animation.

Key Frame System in Computer Animation

A key frame is a frame at a specific point in the animation sequence at which the animator explicitly defines the important positions, shapes or states of the objects (the "extremes" of a motion). A key frame system generates the complete animation from a relatively small set of these key frames.

Working principle:

  1. The animator (or lead artist) creates the key frames — e.g. frame 1 (start pose) and frame 30 (end pose).
  2. The system automatically generates all the in-between frames by interpolating between successive key frames. This automatic generation is called in-betweening or tweening.
  3. Interpolation may be linear (constant change per frame) or use non-linear/spline interpolation for smooth acceleration and deceleration (ease-in / ease-out).

Interpolation example: If an object is at position P1P_1 in key frame k1k_1 and P2P_2 in key frame k2k_2, an in-between frame at parameter t[0,1]t \in [0,1] is

P(t)=(1t)P1+tP2.P(t) = (1-t)P_1 + t\,P_2.

Morphing: When the two key frames have different shapes or different numbers of vertices, a transformation called morphing is used to add/adjust vertices so that one object smoothly transforms into the other across the in-between frames.

Advantages: Greatly reduces the animator's workload (only key poses are drawn), and produces smooth, controllable motion. It is the basis of most 2D and 3D animation packages.

animation
7short5 marks

Explain the working principle of a Raster scan display and a Random (vector) scan display.

Raster Scan Display

In a raster scan display, the electron beam sweeps across the screen one row (scan line) at a time, from top to bottom, covering the entire screen area.

  • The picture is stored as a set of intensity/color values for every pixel in a memory area called the frame buffer (refresh buffer).
  • As the beam moves along each scan line, its intensity is turned on/off (and colored) according to the corresponding pixel values in the frame buffer.
  • After completing the bottom line, the beam returns to the top-left (vertical retrace); after each line it returns to the start of the next line (horizontal retrace).
  • The whole screen is refreshed typically 60–80 times per second to avoid flicker.
  • Suited to displaying shaded, filled and realistic images (photographs); resolution and quality are limited by frame-buffer size, and lines can show a staircase / aliasing effect.

Random (Vector) Scan Display

In a random/vector scan display the electron beam is directed only to the parts of the screen where a picture is to be drawn, tracing the component lines directly (point-to-point), not pixel-by-pixel.

  • The picture is stored as a set of line-drawing commands in an area called the display file / display list, processed by the display processor.
  • The beam draws each line segment directly between its endpoints, so lines are smooth with no staircase effect and very high resolution.
  • Refresh rate depends on the number of lines (typically 30–60 times/sec); a complex picture with many lines may flicker.
  • Best for line drawings, wireframes, engineering and CAD diagrams, but it cannot easily display realistic shaded/filled images.

Key difference: Raster scan refreshes pixel-by-pixel from a frame buffer (good for solid/shaded images); vector scan draws line-by-line from a display list (good for crisp line art).

graphics-systems
8short5 marks

Explain the DDA line drawing algorithm with its advantages and disadvantages.

DDA (Digital Differential Analyzer) Line Drawing Algorithm

DDA is an incremental scan-conversion algorithm that calculates pixel positions along a line by sampling the line at unit intervals along the driving axis and computing the other coordinate using the slope.

For a line from (x0,y0)(x_0,y_0) to (x1,y1)(x_1,y_1), let Δx=x1x0\Delta x = x_1-x_0, Δy=y1y0\Delta y = y_1-y_0.

Steps:

  1. steps=max(Δx,Δy)steps = \max(|\Delta x|, |\Delta y|)
  2. xinc=Δx/stepsx_{inc} = \Delta x / steps, yinc=Δy/steps\quad y_{inc} = \Delta y / steps
  3. Start at (x,y)=(x0,y0)(x,y)=(x_0,y_0); plot round(x), round(y).
  4. Repeat steps times: x=x+xincx = x + x_{inc}, y=y+yincy = y + y_{inc}, plot round(x), round(y).

If m1|m|\le 1, xx increments by 1 and yy by mm; if m>1|m|>1, yy increments by 1 and xx by 1/m1/m.

Advantages:

  • Simpler and faster than the direct line equation y=mx+cy=mx+c, since it avoids a multiplication per pixel (uses only additions).
  • Easy to understand and implement.

Disadvantages:

  • Uses floating-point arithmetic and a round() operation at each step, which is slower than pure integer arithmetic.
  • Accumulation of round-off error over a long line can cause the plotted pixels to drift away from the true line.
  • Slower than Bresenham's algorithm, which uses only integer operations.
line-drawingdda
9short5 marks

Derive the transformation matrix for rotation about an arbitrary point in 2D.

Rotation about an Arbitrary Point in 2D

The basic rotation matrix rotates a point about the origin. To rotate about an arbitrary pivot point (xp,yp)(x_p, y_p) by angle θ\theta, we compose three transformations:

  1. Translate the pivot to the origin: T(xp,yp)T(-x_p, -y_p).
  2. Rotate about the origin by θ\theta: R(θ)R(\theta).
  3. Translate back to the original pivot: T(xp,yp)T(x_p, y_p).

Using homogeneous coordinates, the composite matrix is

M=T(xp,yp)R(θ)T(xp,yp).M = T(x_p, y_p)\cdot R(\theta)\cdot T(-x_p, -y_p).

With

T(xp,yp)=[10xp01yp001],R(θ)=[cosθsinθ0sinθcosθ0001],T(xp,yp)=[10xp01yp001].T(-x_p,-y_p)=\begin{bmatrix}1&0&-x_p\\0&1&-y_p\\0&0&1\end{bmatrix},\quad R(\theta)=\begin{bmatrix}\cos\theta&-\sin\theta&0\\\sin\theta&\cos\theta&0\\0&0&1\end{bmatrix},\quad T(x_p,y_p)=\begin{bmatrix}1&0&x_p\\0&1&y_p\\0&0&1\end{bmatrix}.

Multiplying these gives

M=[cosθsinθxp(1cosθ)+ypsinθsinθcosθyp(1cosθ)xpsinθ001].\boxed{M=\begin{bmatrix}\cos\theta & -\sin\theta & x_p(1-\cos\theta)+y_p\sin\theta \\[4pt] \sin\theta & \cos\theta & y_p(1-\cos\theta)-x_p\sin\theta \\[4pt] 0 & 0 & 1\end{bmatrix}}.

Thus the rotated point is [xy1]=M[xy1]\begin{bmatrix}x' \\ y' \\ 1\end{bmatrix} = M \begin{bmatrix}x \\ y \\ 1\end{bmatrix}, i.e.

x=xp+(xxp)cosθ(yyp)sinθ,x' = x_p + (x-x_p)\cos\theta - (y-y_p)\sin\theta, y=yp+(xxp)sinθ+(yyp)cosθ.y' = y_p + (x-x_p)\sin\theta + (y-y_p)\cos\theta.
transformation2d
10short5 marks

Explain the Sutherland-Hodgman polygon clipping algorithm with an example.

Sutherland–Hodgman Polygon Clipping Algorithm

This algorithm clips a polygon against a convex clipping window by clipping the entire polygon successively against each of the four window edges (left, right, bottom, top), one edge at a time. The output polygon from one edge becomes the input to the next.

Procedure: For the current clip edge, process each polygon edge defined by consecutive vertices (SE)(S \to E) and apply these four cases (output kept vertices in order):

CaseS (start)E (end)Output
1insideinsideoutput E
2insideoutsideoutput intersection point
3outsideinsideoutput intersection, then E
4outsideoutsideoutput nothing

After processing all four window edges, the remaining vertex list is the clipped polygon.

Example: Clip a triangle with vertices A(1,1),B(5,3),C(2,6)A(1,1), B(5,3), C(2,6) against the rectangular window with xmin=0,xmax=4,ymin=0,ymax=4x_{min}=0, x_{max}=4, y_{min}=0, y_{max}=4.

  • Right edge (x4x \le 4): AA inside, BB outside \Rightarrow output intersection of ABAB with x=4x=4, which is (4,2.5)(4, 2.5). BB outside, CC inside \Rightarrow output intersection of BCBC with x=4x=4, (4,4)(4, 4)... after processing the new polygon is A(1,1),(4,2.5),(4,4)-region,C(2,6)A(1,1), (4,2.5), (4,4)\text{-region}, C(2,6).
  • Top edge (y4y \le 4): clip the result so that any vertex with y>4y>4 (e.g. C(2,6)C(2,6)) is replaced by the intersection points where the edges cross y=4y=4.

Clipping against the remaining edges (left x0x\ge0, bottom y0y\ge0) leaves those vertices unchanged here. The final clipped polygon is the part of the triangle lying inside the rectangle, bounded by the original interior edges and the window edges x=4x=4 and y=4y=4.

Limitation: Works correctly only for convex clipping windows; for a concave polygon being clipped it may produce extraneous connecting edges (handled better by Weiler–Atherton).

clippingpolygon
11short5 marks

Explain the RGB and CMY color models used in computer graphics.

RGB Color Model

The RGB model is an additive color model based on the three primary colors of light: Red, Green, Blue. Colors are produced by adding these primaries in varying intensities; it is represented as a unit cube in Cartesian coordinates.

  • Origin (0,0,0)(0,0,0) = black; the diagonally opposite corner (1,1,1)(1,1,1) = white.
  • The main diagonal from black to white represents shades of grey.
  • R+G+BR+G+B at full intensity gives white: Red+Green+Blue=White\text{Red}+\text{Green}+\text{Blue} = \text{White}. Also R+G=R+G= Yellow, G+B=G+B= Cyan, R+B=R+B= Magenta.
  • Used by emissive devices: CRT/LED monitors, TV screens, scanners, digital cameras.

CMY Color Model

The CMY model is a subtractive color model based on Cyan, Magenta, Yellow — the complements (secondaries) of RGB. Colors are produced by subtracting light from white (e.g. by pigments/inks on paper that absorb certain wavelengths).

  • (0,0,0)(0,0,0) = white (no ink); (1,1,1)(1,1,1) = black (all inks).
  • C+M+YC+M+Y subtracts all light to give black.
  • Used by reflective devices: printers and hard-copy/plotting devices. (In practice CMYK adds a separate black ink K for richer blacks.)

Relationship

RGB and CMY are complementary. The conversion is simply:

[CMY]=[111][RGB],[RGB]=[111][CMY].\begin{bmatrix}C\\M\\Y\end{bmatrix}=\begin{bmatrix}1\\1\\1\end{bmatrix}-\begin{bmatrix}R\\G\\B\end{bmatrix},\qquad \begin{bmatrix}R\\G\\B\end{bmatrix}=\begin{bmatrix}1\\1\\1\end{bmatrix}-\begin{bmatrix}C\\M\\Y\end{bmatrix}.

In short: RGB is additive (light, displays, black at origin), CMY is subtractive (pigment, printing, white at origin).

color
12short5 marks

Write the transformation matrices for 3D translation, scaling and rotation about the x-axis.

3D Transformation Matrices (Homogeneous Coordinates)

A point is represented as [x y z 1]T[x\ y\ z\ 1]^T and transformed by a 4×44\times4 matrix.

1. Translation by (tx,ty,tz)(t_x, t_y, t_z)

T=[100tx010ty001tz0001]T = \begin{bmatrix}1&0&0&t_x\\0&1&0&t_y\\0&0&1&t_z\\0&0&0&1\end{bmatrix}

Gives x=x+tx, y=y+ty, z=z+tzx'=x+t_x,\ y'=y+t_y,\ z'=z+t_z.

2. Scaling by factors (sx,sy,sz)(s_x, s_y, s_z)

S=[sx0000sy0000sz00001]S = \begin{bmatrix}s_x&0&0&0\\0&s_y&0&0\\0&0&s_z&0\\0&0&0&1\end{bmatrix}

Gives x=sxx, y=syy, z=szzx'=s_x x,\ y'=s_y y,\ z'=s_z z (scaling is about the origin).

3. Rotation about the x-axis by angle θ\theta

The xx-coordinate is unchanged; the yy and zz coordinates rotate.

Rx(θ)=[10000cosθsinθ00sinθcosθ00001]R_x(\theta) = \begin{bmatrix}1&0&0&0\\0&\cos\theta&-\sin\theta&0\\0&\sin\theta&\cos\theta&0\\0&0&0&1\end{bmatrix}

Gives x=x,y=ycosθzsinθ,z=ysinθ+zcosθx'=x,\quad y'=y\cos\theta - z\sin\theta,\quad z'=y\sin\theta + z\cos\theta.

(Positive θ\theta follows the right-hand rule looking from +x+x toward the origin.)

3dtransformation

Frequently asked questions

Where can I find the BSc CSIT (TU) Computer Graphics (BSc CSIT, CSC209) question paper 2078?
The full BSc CSIT (TU) Computer Graphics (BSc CSIT, CSC209) 2078 (regular) question paper is available free on Kekkei. You can read every question online and attempt the paper under timed exam conditions.
Does the Computer Graphics (BSc CSIT, CSC209) 2078 paper come with solutions?
Yes. Every question on this Computer Graphics (BSc CSIT, CSC209) past paper includes a step-by-step solution, plus instant AI feedback when you attempt it on Kekkei.
How many marks is the BSc CSIT (TU) Computer Graphics (BSc CSIT, CSC209) 2078 paper?
The BSc CSIT (TU) Computer Graphics (BSc CSIT, CSC209) 2078 paper carries 60 full marks and is meant to be completed in 180 minutes, across 12 questions.
Is practising this Computer Graphics (BSc CSIT, CSC209) past paper free?
Yes — reading and attempting this Computer Graphics (BSc CSIT, CSC209) past paper on Kekkei is completely free.