Browse papers
A

Section A: Long Answer Questions

Attempt all / any as specified.

4 questions
1long12 marks

(a) Derive the decision parameter for Bresenham's line drawing algorithm for a line with slope 0<m<10 < m < 1, clearly stating the initial decision parameter and the incremental update rules. [8]

(b) Using Bresenham's line drawing algorithm, trace and tabulate all the intermediate pixel positions for a line segment from point A(2, 3) to point B(9, 8). [4]

(a) Derivation of Bresenham's decision parameter (0<m<10<m<1) [8]

Consider a line y=mx+cy = mx + c with slope m=dydxm = \dfrac{dy}{dx} where dy=y2y1dy = y_2-y_1, dx=x2x1dx = x_2-x_1 and 0<m<10<m<1. Since the slope is less than 1, xx is the fast (driving) axis: at every step we increment xx by 1 and decide whether yy stays the same or increases by 1.

Suppose pixel (xk,yk)(x_k, y_k) has just been plotted. At the next column xk+1=xk+1x_{k+1}=x_k+1 the true line is at y=m(xk+1)+cy = m(x_k+1)+c. The two candidate pixels are the lower (xk+1,  yk)(x_k+1,\;y_k) and the upper (xk+1,  yk+1)(x_k+1,\;y_k+1).

Let dlowerd_{lower} and dupperd_{upper} be the vertical distances from the true line to these candidates:

dlower=yyk=m(xk+1)+cykd_{lower} = y - y_k = m(x_k+1)+c - y_k dupper=(yk+1)y=yk+1m(xk+1)cd_{upper} = (y_k+1) - y = y_k+1 - m(x_k+1) - c

The difference decides the closer pixel:

dlowerdupper=2m(xk+1)2yk+2c1d_{lower}-d_{upper} = 2m(x_k+1) - 2y_k + 2c - 1

Substituting m=dy/dxm = dy/dx and multiplying by dx  (>0)dx\;(>0) so the test stays integer, define the decision parameter:

pk=dx(dlowerdupper)=2dyxk2dxyk+bp_k = dx\,(d_{lower}-d_{upper}) = 2\,dy\cdot x_k - 2\,dx\cdot y_k + b

where b=2dy+dx(2c1)b = 2\,dy + dx(2c-1) is constant. Because dx>0dx>0, the sign of pkp_k equals the sign of (dlowerdupper)(d_{lower}-d_{upper}):

  • If pk<0p_k < 0 → lower pixel is closer → choose (xk+1,  yk)(x_k+1,\;y_k).
  • If pk0p_k \ge 0 → upper pixel is closer → choose (xk+1,  yk+1)(x_k+1,\;y_k+1).

Incremental update. Writing pk+1pk=2dy(xk+1xk)2dx(yk+1yk)p_{k+1}-p_k = 2\,dy(x_{k+1}-x_k) - 2\,dx(y_{k+1}-y_k) and xk+1xk=1x_{k+1}-x_k=1:

pk+1=pk+2dy2dx(yk+1yk)p_{k+1} = p_k + 2\,dy - 2\,dx\,(y_{k+1}-y_k)
  • If pk<0p_k<0 (lower, yy unchanged): pk+1=pk+2dy\boxed{p_{k+1}=p_k+2\,dy}
  • If pk0p_k\ge 0 (upper, yy increases): pk+1=pk+2dy2dx\boxed{p_{k+1}=p_k+2\,dy-2\,dx}

Initial parameter. Starting at (x1,y1)(x_1,y_1) on the line (c=y1mx1c = y_1 - m x_1), substitution gives the simple integer start:

p0=2dydx\boxed{p_0 = 2\,dy - dx}

Only integer additions are used, which is why Bresenham's algorithm is fast.

(b) Trace from A(2,3)A(2,3) to B(9,8)B(9,8) [4]

dx=92=7,dy=83=5,m=5/7  (0<m<1).dx = 9-2 = 7,\quad dy = 8-3 = 5,\quad m=5/7\;(0<m<1).

Constants: 2dy=10,2(dydx)=2(57)=4,p0=2dydx=107=3.2dy = 10,\quad 2(dy-dx)=2(5-7)=-4,\quad p_0 = 2dy-dx = 10-7 = 3.

Step kkpkp_kActionPixel (xk+1,yk+1)(x_{k+1},y_{k+1})
startplot start(2,3)(2,3)
03 (0\ge0)x+1,y+1x{+}1,\,y{+}1, p+(4)p{+}(-4)(3,4)(3,4)p=1p=-1
1-1 (<0<0)x+1x{+}1, p+10p{+}10(4,4)(4,4)p=9p=9
29 (0\ge0)x+1,y+1x{+}1,\,y{+}1, p4p{-}4(5,5)(5,5)p=5p=5
35 (0\ge0)x+1,y+1x{+}1,\,y{+}1, p4p{-}4(6,6)(6,6)p=1p=1
41 (0\ge0)x+1,y+1x{+}1,\,y{+}1, p4p{-}4(7,7)(7,7)p=3p=-3
5-3 (<0<0)x+1x{+}1, p+10p{+}10(8,7)(8,7)p=7p=7
67 (0\ge0)x+1,y+1x{+}1,\,y{+}1, p4p{-}4(9,8)(9,8) → end

Pixels plotted: (2,3),(3,4),(4,4),(5,5),(6,6),(7,7),(8,7),(9,8)(2,3),(3,4),(4,4),(5,5),(6,6),(7,7),(8,7),(9,8) — terminating correctly at B(9,8)B(9,8).

line-drawing-algorithmsscan-conversion
2long12 marks

(a) A triangle is defined by the vertices A(1,1)A(1, 1), B(4,1)B(4, 1) and C(2,3)C(2, 3). Perform a rotation of 9090^\circ counter-clockwise about the point P(2,2)P(2, 2) and find the coordinates of the transformed vertices using homogeneous coordinate matrices. Show the composite transformation matrix. [8]

(b) Explain why homogeneous coordinates are used to represent 2D transformations, and show how translation can be expressed in matrix form using them. [4]

(a) Rotation of 9090^\circ CCW about P(2,2)P(2,2) [8]

Rotation about an arbitrary point is a composite transformation: translate the pivot to the origin, rotate, then translate back:

M=T(2,2)R(90)T(2,2)M = T(2,2)\cdot R(90^\circ)\cdot T(-2,-2)

With θ=90\theta=90^\circ, cosθ=0,  sinθ=1\cos\theta=0,\;\sin\theta=1:

T(2,2)=[102012001],    R(90)=[010100001],    T(2,2)=[102012001]T(-2,-2)=\begin{bmatrix}1&0&-2\\0&1&-2\\0&0&1\end{bmatrix},\;\; R(90^\circ)=\begin{bmatrix}0&-1&0\\1&0&0\\0&0&1\end{bmatrix},\;\; T(2,2)=\begin{bmatrix}1&0&2\\0&1&2\\0&0&1\end{bmatrix}

Composite matrix:

M=[014100001]M = \begin{bmatrix}0&-1&4\\1&0&0\\0&0&1\end{bmatrix}

(giving x=y+4,  y=xx' = -y+4,\; y' = x). Applying to each vertex [xy1]T\begin{bmatrix}x&y&1\end{bmatrix}^T:

Vertexx=y+4x'=-y+4y=xy'=xResult
A(1,1)A(1,1)1+4=3-1+4=311A(3,1)A'(3,1)
B(4,1)B(4,1)1+4=3-1+4=344B(3,4)B'(3,4)
C(2,3)C(2,3)3+4=1-3+4=122C(1,2)C'(1,2)

Transformed triangle: A(3,1),  B(3,4),  C(1,2)A'(3,1),\;B'(3,4),\;C'(1,2).

(b) Why homogeneous coordinates [4]

A point (x,y)(x,y) is represented as (x,y,1)(x,y,1), i.e. a 2D point becomes a 3-component vector.

  • Reason: Rotation, scaling and shearing are linear and can be written as 2×22\times2 matrix multiplications, but translation is additive (x=x+txx'=x+t_x) and cannot be expressed as a 2×22\times2 multiplication. By adding a third coordinate, translation becomes a 3×33\times3 matrix multiplication, so all transformations are uniform 3×33\times3 matrices and can be composed by simple matrix multiplication.

  • Translation in matrix form:

[xy1]=[10tx01ty001][xy1]=[x+txy+ty1]\begin{bmatrix}x'\\y'\\1\end{bmatrix}=\begin{bmatrix}1&0&t_x\\0&1&t_y\\0&0&1\end{bmatrix}\begin{bmatrix}x\\y\\1\end{bmatrix}=\begin{bmatrix}x+t_x\\y+t_y\\1\end{bmatrix}
2d-transformationscomposite-transformation
3long12 marks

(a) Distinguish between parallel projection and perspective projection. Derive the transformation matrix for a perspective projection of a 3D point onto the z=0z = 0 plane with the centre of projection at distance dd along the negative z-axis. [8]

(b) Write the 4×44\times 4 homogeneous transformation matrix for scaling about an arbitrary fixed point (xf,yf,zf)(x_f, y_f, z_f) in 3D. [4]

(a) Parallel vs Perspective projection + perspective matrix [8]

AspectParallel projectionPerspective projection
ProjectorsParallel to each otherConverge at the centre of projection (COP)
Object sizePreserved (no foreshortening)Distant objects appear smaller (foreshortening)
RealismLess realistic; used in CAD/engineering drawingsMore realistic; matches human eye / camera
Parallel linesRemain parallelConverge to vanishing points
COPAt infinityAt a finite distance

Derivation (projection onto z=0z=0, COP at (0,0,d)(0,0,-d) on the negative z-axis).

Let a 3D point be P(x,y,z)P(x,y,z). The projector is the line joining the COP C(0,0,d)C(0,0,-d) to PP. We find where this line meets the plane z=0z=0. Parametrically a point on the line is

X=0+t(x0),Y=ty,Z=d+t(z+d).X = 0 + t(x-0),\quad Y = t\,y,\quad Z = -d + t(z+d).

Set Z=0Z=0:   t=dz+d\;t = \dfrac{d}{z+d}. Then

xp=dxz+d=x1+z/d,yp=dyz+d=y1+z/d.x_p = \frac{d\,x}{z+d}=\frac{x}{1+z/d},\qquad y_p = \frac{d\,y}{z+d}=\frac{y}{1+z/d}.

In homogeneous coordinates this division by (1+z/d)(1+z/d) is captured by:

[xhyhzhw]=[100001000000001d1][xyz1]=[xy0zd+1]\begin{bmatrix}x_h\\y_h\\z_h\\w\end{bmatrix}=\begin{bmatrix}1&0&0&0\\0&1&0&0\\0&0&0&0\\0&0&\tfrac{1}{d}&1\end{bmatrix}\begin{bmatrix}x\\y\\z\\1\end{bmatrix}=\begin{bmatrix}x\\y\\0\\\tfrac{z}{d}+1\end{bmatrix}

Dividing through by w=zd+1w = \tfrac{z}{d}+1 recovers xp=x1+z/dx_p = \dfrac{x}{1+z/d}, yp=y1+z/dy_p=\dfrac{y}{1+z/d}, zp=0z_p=0. The non-zero entry 1d\tfrac1d in the bottom row is what produces perspective foreshortening; if dd\to\infty that entry vanishes and the matrix degenerates to a parallel (orthographic) projection.

(b) Scaling about an arbitrary fixed point (xf,yf,zf)(x_f,y_f,z_f) in 3D [4]

M=T(xf,yf,zf)S(sx,sy,sz)T(xf,yf,zf)M = T(x_f,y_f,z_f)\cdot S(s_x,s_y,s_z)\cdot T(-x_f,-y_f,-z_f) M=[sx00xf(1sx)0sy0yf(1sy)00szzf(1sz)0001]M=\begin{bmatrix}s_x&0&0&x_f(1-s_x)\\0&s_y&0&y_f(1-s_y)\\0&0&s_z&z_f(1-s_z)\\0&0&0&1\end{bmatrix}
3d-transformationsprojections
4long12 marks

(a) Explain the Cohen–Sutherland line clipping algorithm using region (outcode) codes. With the help of the algorithm, clip the line segment from P1(40,15)P_1(40, 15) to P2(75,45)P_2(75, 45) against a rectangular clipping window with corners (xmin,ymin)=(50,10)(x_{min}, y_{min}) = (50, 10) and (xmax,ymax)=(80,40)(x_{max}, y_{max}) = (80, 40). [8]

(b) State the limitation of the Sutherland–Hodgeman polygon clipping algorithm when clipping a concave polygon. [4]

(a) Cohen–Sutherland line clipping [8]

The plane is divided into 9 regions by extending the window edges; each region has a 4-bit outcode b3b2b1b0=b_3b_2b_1b_0 = (Top, Bottom, Right, Left):

  • bit 0 (Left): set if x<xminx < x_{min}
  • bit 1 (Right): set if x>xmaxx > x_{max}
  • bit 2 (Bottom): set if y<yminy < y_{min}
  • bit 3 (Top): set if y>ymaxy > y_{max}

Algorithm: compute outcodes for both endpoints.

  1. If both codes are 00000000trivially accept (line wholly inside).
  2. If logical AND of the codes 0000\ne 0000trivially reject (both on same outside side).
  3. Otherwise pick an endpoint that is outside, find its intersection with the corresponding window edge, replace the endpoint with the intersection, recompute its outcode, and repeat until accept or reject.

Intersections use: for a vertical edge x=xex=x_e, y=y1+m(xex1)y = y_1 + m(x_e-x_1); for a horizontal edge y=yey=y_e, x=x1+(yey1)/mx = x_1 + (y_e-y_1)/m.

Given: P1(40,15)P_1(40,15), P2(75,45)P_2(75,45), window (50,10)(50,10)(80,40)(80,40). Slope m=45157540=3035=67m=\dfrac{45-15}{75-40}=\dfrac{30}{35}=\dfrac{6}{7}.

  • Outcode(P1P_1): x=40<50x=40<50 → Left = 0001.
  • Outcode(P2P_2): y=45>40y=45>40 → Top = 1000.
  • AND =0000=0000 → not trivially rejected; not both zero → clip.

Clip P1P_1 against left edge x=50x=50:

y=15+67(5040)=15+607=15+8.57=23.57.y = 15 + \tfrac{6}{7}(50-40)=15+\tfrac{60}{7}=15+8.57=23.57.

New P1=(50,23.57)P_1'=(50,\,23.57), outcode 00000000 (inside).

Clip P2P_2 against top edge y=40y=40:

x=40+40156/7=40+2576=40+29.17=69.17.x = 40 + \tfrac{40-15}{6/7}=40+\tfrac{25\cdot7}{6}=40+29.17=69.17.

New P2=(69.17,40)P_2'=(69.17,\,40), outcode 00000000.

Both endpoints now inside → accept.

Clipped segment: from (50,  23.57)(50,\;23.57) to (69.17,  40)(69.17,\;40).

(b) Limitation of Sutherland–Hodgeman with a concave polygon [4]

The Sutherland–Hodgeman algorithm clips the polygon successively against each window edge, treating the output as a single connected vertex list. For a concave polygon this can produce extraneous connecting edges: when the clipped result should split into two or more separate pieces, the algorithm instead joins them with a spurious line that runs along the window boundary, giving an incorrect filled region. The remedy is to split the concave polygon into convex pieces first, or to use the Weiler–Atherton algorithm, which handles concave polygons correctly.

clipping-algorithmspolygon-clipping
B

Section B: Short Answer Questions

Attempt all / any as specified.

8 questions
5short6 marks

Explain the midpoint circle drawing algorithm, deriving its decision parameter. Using the eight-way symmetry property, list the pixel positions generated in the first octant for a circle of radius r=8r = 8 centred at the origin.

Midpoint Circle Drawing Algorithm [6]

For a circle of radius rr centred at the origin the implicit function is

fcircle(x,y)=x2+y2r2,f_{circle}(x,y) = x^2 + y^2 - r^2,

which is <0<0 inside, =0=0 on, and >0>0 outside the circle. The algorithm works in the second octant (from (0,r)(0,r) to the 4545^\circ line), where xx is the driving axis. After plotting (xk,yk)(x_k,y_k) we test the midpoint M=(xk+1,  yk12)M=(x_k+1,\;y_k-\tfrac12) between the two candidate pixels E=(xk+1,yk)E=(x_k+1,y_k) and SE=(xk+1,yk1)SE=(x_k+1,y_k-1):

pk=fcircle ⁣(xk+1,  yk12)=(xk+1)2+(yk12)2r2.p_k = f_{circle}\!\left(x_k+1,\;y_k-\tfrac12\right) = (x_k+1)^2 + \left(y_k-\tfrac12\right)^2 - r^2.
  • If pk<0p_k<0 → midpoint inside → choose EE (yy unchanged).
  • If pk0p_k\ge0 → midpoint outside → choose SESE (yy decreases).

Incremental updates:

  • if pk<0p_k<0:   pk+1=pk+2xk+1+1\;p_{k+1}=p_k+2x_{k+1}+1
  • if pk0p_k\ge0:   pk+1=pk+2xk+1+12yk+1\;p_{k+1}=p_k+2x_{k+1}+1-2y_{k+1}

Initial value at (0,r)(0,r):   p0=54r1r\;p_0 = \tfrac54 - r \approx 1 - r.

Eight-way symmetry: each computed (x,y)(x,y) gives 8 pixels: (±x,±y)(\pm x,\pm y) and (±y,±x)(\pm y,\pm x), so only one octant need be computed.

Trace for r=8r=8 (first octant, p0=18=7p_0 = 1-8 = -7)

(x,y)(x,y)ppDecisionNext
(0,8)(0,8)7-7<0<0 → E(1,8)(1,8)
(1,8)(1,8)4-4<0<0 → E(2,8)(2,8)
(2,8)(2,8)110\ge0 → SE(3,7)(3,7)
(3,7)(3,7)6-6<0<0 → E(4,7)(4,7)
(4,7)(4,7)330\ge0 → SE(5,6)(5,6)
(5,6)(5,6)220\ge0 → SE(6,5)(6,5)
(6,5)(6,5)x>yx>y → stop

First-octant pixels: (0,8),(1,8),(2,8),(3,7),(4,7),(5,6),(6,5)(0,8),(1,8),(2,8),(3,7),(4,7),(5,6),(6,5) (computation stops when xyx\ge y).

circle-drawing-algorithmsscan-conversion
6short6 marks

Define a Bézier curve. Write the blending (Bernstein basis) function for a cubic Bézier curve, and list any three important properties of Bézier curves.

Bézier Curve [6]

Definition. A Bézier curve of degree nn is a parametric curve defined by n+1n+1 control points P0,P1,,PnP_0,P_1,\dots,P_n as a weighted blend of those points using Bernstein basis polynomials, for t[0,1]t\in[0,1]:

P(t)=i=0nPiBi,n(t),Bi,n(t)=(ni)ti(1t)ni.P(t)=\sum_{i=0}^{n} P_i\,B_{i,n}(t),\qquad B_{i,n}(t)=\binom{n}{i}t^{i}(1-t)^{n-i}.

Cubic Bézier (n=3n=3) blending functions:

B0,3(t)=(1t)3,B1,3(t)=3t(1t)2,B2,3(t)=3t2(1t),B3,3(t)=t3B_{0,3}(t)=(1-t)^3,\quad B_{1,3}(t)=3t(1-t)^2,\quad B_{2,3}(t)=3t^2(1-t),\quad B_{3,3}(t)=t^3

so that P(t)=(1t)3P0+3t(1t)2P1+3t2(1t)P2+t3P3.P(t)=(1-t)^3P_0+3t(1-t)^2P_1+3t^2(1-t)P_2+t^3P_3.

Three important properties:

  1. Endpoint interpolation – the curve passes exactly through the first and last control points: P(0)=P0P(0)=P_0, P(1)=P3P(1)=P_3.
  2. Convex-hull property – the curve lies entirely within the convex hull of its control points (since the Bernstein basis is non-negative and sums to 1).
  3. Tangency at endpoints – the curve is tangent to P0P1P_0P_1 at the start and to Pn1PnP_{n-1}P_n at the end, which makes smooth joining of segments easy. (Also: affine invariance and no local control.)
curves-and-surfacesbezier-curves
7short6 marks

Describe the Z-buffer (depth-buffer) algorithm for hidden surface removal. State its main advantages and disadvantages compared to a scan-line method.

Z-Buffer (Depth-Buffer) Algorithm [6]

The Z-buffer is an image-space hidden-surface removal method using two buffers of the same resolution as the frame buffer:

  • Frame (colour) buffer – stores the colour of each pixel.
  • Depth (Z) buffer – stores the zz (depth) of the nearest surface seen so far at each pixel.

Algorithm:

Initialise depth-buffer[x][y] = z_max (far)  for all pixels
Initialise frame-buffer[x][y] = background colour
for each polygon:
    for each pixel (x,y) it covers:
        compute depth z of the polygon at (x,y)   // by interpolation
        if z < depth-buffer[x][y]:                // nearer than stored
            depth-buffer[x][y] = z
            frame-buffer[x][y] = surface colour at (x,y)

The depth across a polygon is found incrementally: z=zacz' = z - \dfrac{a}{c} moving one pixel in xx (where ax+by+cz+d=0ax+by+cz+d=0 is the plane), so no per-pixel division is needed.

Advantages (vs scan-line):

  • Very simple to implement; handles any number of polygons in arbitrary order (no presorting).
  • Easily implemented in hardware → standard in GPUs.
  • Time is roughly linear in the number of polygons.

Disadvantages (vs scan-line):

  • Requires large extra memory for the depth buffer.
  • Finite depth precision causes z-fighting (aliasing of close/coplanar surfaces).
  • Wastes work rendering pixels later overwritten; does not handle transparency or anti-aliasing directly, whereas the scan-line method processes one scan line at a time using much less memory.
hidden-surface-removalz-buffer
8short6 marks

Explain the Phong illumination model, clearly describing the ambient, diffuse and specular components and the role of each term in the lighting equation.

Phong Illumination Model [6]

The Phong model computes the reflected intensity at a surface point as the sum of three components — ambient + diffuse + specular:

I=kaIaambient+kdIl(NL)diffuse+ksIl(RV)nspecularI = \underbrace{k_a I_a}_{\text{ambient}} + \underbrace{k_d I_l (\mathbf{N}\cdot\mathbf{L})}_{\text{diffuse}} + \underbrace{k_s I_l (\mathbf{R}\cdot\mathbf{V})^{n}}_{\text{specular}}

where N\mathbf N = surface normal, L\mathbf L = direction to light, R\mathbf R = mirror-reflection direction of L\mathbf L about N\mathbf N, V\mathbf V = direction to viewer (all unit vectors), and Ia,IlI_a,I_l are ambient and source intensities.

1. Ambient term (kaIak_a I_a). Models the uniform background light scattered many times in the scene. It is constant and independent of light/viewer direction, ensuring that surfaces facing away from the light are not completely black. kak_a is the ambient reflection coefficient.

2. Diffuse term (kdIl(NL)k_d I_l(\mathbf N\cdot\mathbf L)). Models Lambertian (matte) reflection scattered equally in all directions. Its brightness depends only on the angle between N\mathbf N and L\mathbf L (i.e. cosθ=NL\cos\theta=\mathbf N\cdot\mathbf L), being maximum when the light hits head-on and zero when grazing. It is view-independent; kdk_d is the diffuse coefficient (surface colour). If NL<0\mathbf N\cdot\mathbf L<0 the term is clamped to 0.

3. Specular term (ksIl(RV)nk_s I_l(\mathbf R\cdot\mathbf V)^n). Models the shiny highlight of glossy surfaces. It is strongest when the viewer looks along the reflection direction (RV\mathbf R\approx\mathbf V) and falls off with the shininess exponent nn — large nn gives a small, sharp highlight; small nn a broad, dull one. It is view-dependent; ksk_s is the specular coefficient.

For multiple lights the diffuse and specular contributions are summed over all sources.

illumination-and-shadingphong-model
9short6 marks

Differentiate between Gouraud shading and Phong shading. State which technique correctly renders specular highlights and explain why.

Gouraud vs Phong Shading [6]

AspectGouraud shadingPhong shading
What is interpolatedVertex colours (intensities) across the polygonVertex normals, then lighting computed per pixel
Where lighting is evaluatedOnly at the verticesAt every interior pixel
CostCheaper / fasterMore expensive (per-pixel normalisation + lighting)
SmoothnessRemoves Mach-band intensity discontinuities reasonablySmoother, more accurate shading
Specular highlightsOften rendered incorrectlyRendered correctly

Procedure (Gouraud): compute a normal at each vertex (average of adjacent face normals), apply the illumination model to get a colour at each vertex, then bilinearly interpolate those colours along edges and scan lines.

Procedure (Phong): interpolate the normal vectors across the polygon (re-normalising each), and apply the full illumination model at each pixel.

Which renders specular highlights correctly → Phong shading.

Why: A specular highlight is a small, sharply varying bright spot. In Gouraud shading the highlight is sampled only at the vertices; if the highlight falls in the interior of a polygon (between vertices), the vertex intensities are low and linear colour interpolation simply averages them, so the highlight is missed or smeared. Phong shading interpolates the normals and recomputes the (RV)n(\mathbf R\cdot\mathbf V)^n term per pixel, so the peak of the highlight is captured wherever it occurs on the surface.

illumination-and-shadinggouraud-shading
10short6 marks

Explain boundary-fill and flood-fill area-filling algorithms. Distinguish between 4-connected and 8-connected approaches with the help of suitable diagrams.

Boundary-Fill and Flood-Fill [6]

Both are seed-fill algorithms: starting from an interior seed pixel they recursively spread the fill colour to neighbouring pixels.

Boundary-fill. Used when the region is defined by a specific boundary colour. Starting at a seed inside the region, set it to the fill colour and recurse to neighbours, stopping when a pixel is the boundary colour or already filled.

boundaryFill(x, y, fillColour, boundaryColour):
    c = getPixel(x, y)
    if c != boundaryColour and c != fillColour:
        setPixel(x, y, fillColour)
        // 4-connected neighbours
        boundaryFill(x+1, y, ...); boundaryFill(x-1, y, ...)
        boundaryFill(x, y+1, ...); boundaryFill(x, y-1, ...)

Flood-fill. Used when a region is defined by a single interior colour (no defined boundary). It replaces all connected pixels having the old interior colour with the new colour, stopping when a pixel no longer matches the old colour.

floodFill(x, y, oldColour, newColour):
    if getPixel(x, y) == oldColour:
        setPixel(x, y, newColour)
        floodFill on the 4 (or 8) neighbours

4-connected vs 8-connected:

  • 4-connected: recurse to the 4 edge neighbours only — right, left, up, down. Simpler, but it cannot pass through regions connected only diagonally, so thin diagonal gaps in a boundary leave parts unfilled.
  • 8-connected: recurse to all 8 neighbours — the 4 edge plus 4 diagonal (corner) pixels. It fills more completely and handles diagonally connected regions, but a single-pixel diagonal boundary may leak the fill outside the intended area.

Diagrams (described):

 4-connected:        8-connected:
      N                NW  N  NE
   W  P  E              W  P  E
      S                SW  S  SE

The centre pixel PP reaches only N/S/E/W in the 4-connected case, and additionally the four diagonal corners in the 8-connected case.

output-primitivesscan-conversion
11short6 marks

(a) Describe the Sutherland–Hodgeman polygon clipping algorithm and the four possible vertex-edge cases it handles. [4]

(b) Briefly explain the strategies used for text clipping. [2]

(a) Sutherland–Hodgeman polygon clipping [4]

The polygon is clipped against the four window edges one at a time (left, right, bottom, top); the output vertex list from one edge becomes the input to the next. For each edge, each polygon edge ViVi+1V_i \to V_{i+1} is examined and 0, 1 or 2 vertices are output according to four cases (in = inside the clip edge, out = outside):

CaseViV_iVi+1V_{i+1}Output
1ininoutput Vi+1V_{i+1}
2inoutoutput intersection point only
3outinoutput intersection point, then Vi+1V_{i+1}
4outoutoutput nothing

After all four edges are processed, the remaining vertex list is the clipped polygon. (It works correctly for convex polygons; concave ones may need splitting.)

(b) Text clipping strategies [2]

  • All-or-none string clipping: the whole string is kept only if its entire bounding box lies inside the window; otherwise the whole string is discarded.
  • All-or-none character clipping: each character is kept or rejected as a unit based on whether its bounding box is fully inside.
  • Character (component) clipping: individual characters are clipped at the boundary — outline (stroke) text is clipped like line/curve primitives, and bitmap text is clipped pixel by pixel, so partially visible characters appear cut off at the window edge.
clipping-algorithmstext-clipping
12short6 marks

What is meant by local control of a curve? Compare B-spline curves with Bézier curves with respect to local control and continuity.

Local Control of a Curve [6]

Local control means that moving (or editing) a single control point changes only a limited, nearby portion of the curve, leaving the rest of the curve unchanged. The opposite is global control, where every control point influences the entire curve.

B-spline vs Bézier

PropertyBézier curveB-spline curve
Local controlNo – each blending function Bi,n(t)B_{i,n}(t) is non-zero over all t[0,1]t\in[0,1], so moving any control point alters the whole curve.Yes – each B-spline basis function is non-zero only over a limited span (degree kk covers k+1k+1 knot intervals), so moving a control point affects only that local region.
Degree vs #control pointsDegree is fixed by the number of control points (nn points → degree n1n-1); more points ⇒ higher degree.Degree is independent of the number of control points, so many points can be used at low (e.g. cubic) degree.
ContinuityA single segment is CC^\infty; joining segments requires manually matching positions/tangents to get C1/C2C^1/C^2.A degree-kk B-spline (with simple knots) is automatically Ck1C^{k-1} continuous across its segments (e.g. a cubic B-spline is C2C^2).
Convex hullLies within the convex hull of all control points.Lies within the union of convex hulls of local groups of control points (tighter).

Summary: Bézier curves are simple and interpolate their endpoints but lack local control and give only manual continuity; B-spline curves provide local control and built-in higher-order continuity, making them better for complex, editable curves and surfaces.

curves-and-surfacesb-spline

Frequently asked questions

Where can I find the BE Computer Engineering (IOE, TU) Computer Graphics (IOE, CT 605 / ENCT 201) question paper 2079?
The full BE Computer Engineering (IOE, TU) Computer Graphics (IOE, CT 605 / ENCT 201) 2079 (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 (IOE, CT 605 / ENCT 201) 2079 paper come with solutions?
Yes. Every question on this Computer Graphics (IOE, CT 605 / ENCT 201) past paper includes a step-by-step solution, plus instant AI feedback when you attempt it on Kekkei.
How many marks is the BE Computer Engineering (IOE, TU) Computer Graphics (IOE, CT 605 / ENCT 201) 2079 paper?
The BE Computer Engineering (IOE, TU) Computer Graphics (IOE, CT 605 / ENCT 201) 2079 paper carries 80 full marks and is meant to be completed in 180 minutes, across 12 questions.
Is practising this Computer Graphics (IOE, CT 605 / ENCT 201) past paper free?
Yes — reading and attempting this Computer Graphics (IOE, CT 605 / ENCT 201) past paper on Kekkei is completely free.