Skip to main content

Chapter 3

Computer Graphics

TU BSc CSIT past exam questions

Past questions and answers

84 questions set from this chapter. Most repeated first.

  • 2079 · 5 marks

Reflect a line segment having endpoints (9,3) and (12,10) about a line Y=7. Draw initial and final result graph as well.

Similar questions: Reflect a line segment having end points (2080)

Answer

Reflection about the horizontal line y=7y = 7 is done by a composite transformation:

  1. Translate so the line coincides with the x-axis: T(0,−7)T(0,-7).
  2. Reflect about the x-axis: FxF_x.
  3. Translate back: T(0,7)T(0,7).

M=T(0,7)⋅Fx⋅T(0,−7)=[100017001][1000−10001][10001−7001]=[1000−114001]M = T(0,7)\cdot F_x \cdot T(0,-7) = \begin{bmatrix}1&0&0\\0&1&7\\0&0&1\end{bmatrix}\begin{bmatrix}1&0&0\\0&-1&0\\0&0&1\end{bmatrix}\begin{bmatrix}1&0&0\\0&1&-7\\0&0&1\end{bmatrix} = \begin{bmatrix}1&0&0\\0&-1&14\\0&0&1\end{bmatrix}

So x′=xx' = x, y′=14−yy' = 14 - y.

For A(9,3)A(9,3):

[1000−114001][931]=[9111]\begin{bmatrix}1&0&0\\0&-1&14\\0&0&1\end{bmatrix}\begin{bmatrix}9\\3\\1\end{bmatrix} = \begin{bmatrix}9\\11\\1\end{bmatrix}

so A′=(9,11)A' = (9, 11).

For B(12,10)B(12,10):

[1000−114001][12101]=[1241]\begin{bmatrix}1&0&0\\0&-1&14\\0&0&1\end{bmatrix}\begin{bmatrix}12\\10\\1\end{bmatrix} = \begin{bmatrix}12\\4\\1\end{bmatrix}

so B′=(12,4)B' = (12, 4).

Graph (each point is the same distance from y=7y = 7 on the opposite side: AA is 4 below, A′A' is 4 above; BB is 3 above, B′B' is 3 below):

 y
11 |  A'(9,11)
10 |                B(12,10)
 7 |------------------------------  mirror line y = 7
 4 |                B'(12,4)
 3 |  A(9,3)
   +--------------------------- x
      9            12

The initial line joins A(9,3)A(9,3) to B(12,10)B(12,10) (rising); the final line joins A′(9,11)A'(9,11) to B′(12,4)B'(12,4) (falling). The two lines cross at y=7y = 7, where x=9+3⋅47≈10.71x = 9 + 3\cdot\frac{4}{7} \approx 10.71, on the mirror line, and the length of the segment is unchanged.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2079 · 5 marks

Calculate the total memory required to store a 8 minute video in a SVGA system with 24 bit true color and 25 fps.

Similar questions: Calculate the total memory required to store (2080)

Answer

SVGA resolution is taken as 800×600800 \times 600 pixels. True colour with 24 bits needs 24/8=324/8 = 3 bytes per pixel.

Memory per frame

800×600×3=1,440,000 bytes800 \times 600 \times 3 = 1{,}440{,}000 \text{ bytes}

Number of frames. Duration is 8×60=4808 \times 60 = 480 s, at 25 frames per second:

480×25=12,000 frames480 \times 25 = 12{,}000 \text{ frames}

Total memory

1,440,000×12,000=17,280,000,000 bytes1{,}440{,}000 \times 12{,}000 = 17{,}280{,}000{,}000 \text{ bytes}

In binary units:

17,280,000,00010242≈16,479.5 MB≈16.09 GB\frac{17{,}280{,}000{,}000}{1024^2} \approx 16{,}479.5 \text{ MB} \approx 16.09 \text{ GB}

So about 17.28 x 10^9 bytes (about 16.1 GB) is needed for the uncompressed video.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2080 · 5 marks

Reflect a line segment having end points (9,3) and (12,10) about a line X=7. Draw initial and final result graph as well.

Similar questions: Reflect a line segment having endpoints (9,3) (2079)

Answer

Reflection about the vertical line x=7x = 7 is a composite transformation:

  1. Translate the line to the y-axis: T(−7,0)T(-7, 0).
  2. Reflect about the y-axis: FyF_y.
  3. Translate back: T(7,0)T(7, 0).

M=T(7,0)⋅Fy⋅T(−7,0)=[107010001][−100010001][10−7010001]=[−1014010001]M = T(7,0)\cdot F_y\cdot T(-7,0) = \begin{bmatrix}1&0&7\\0&1&0\\0&0&1\end{bmatrix}\begin{bmatrix}-1&0&0\\0&1&0\\0&0&1\end{bmatrix}\begin{bmatrix}1&0&-7\\0&1&0\\0&0&1\end{bmatrix} = \begin{bmatrix}-1&0&14\\0&1&0\\0&0&1\end{bmatrix}

So x′=14−xx' = 14 - x, y′=yy' = y.

For A(9,3)A(9,3):

[−1014010001][931]=[531]\begin{bmatrix}-1&0&14\\0&1&0\\0&0&1\end{bmatrix}\begin{bmatrix}9\\3\\1\end{bmatrix} = \begin{bmatrix}5\\3\\1\end{bmatrix}

so A′=(5,3)A' = (5,3).

For B(12,10)B(12,10):

[−1014010001][12101]=[2101]\begin{bmatrix}-1&0&14\\0&1&0\\0&0&1\end{bmatrix}\begin{bmatrix}12\\10\\1\end{bmatrix} = \begin{bmatrix}2\\10\\1\end{bmatrix}

so B′=(2,10)B' = (2,10).

Graph

 y
10 |  B'(2,10)         |            B(12,10)
   |                   |
   |                   |
 3 |  A'(5,3)          |   A(9,3)
   +-------------------+-------------------- x
                      x = 7  (mirror line)

The original segment joins A(9,3)A(9,3) and B(12,10)B(12,10) to the right of the mirror line x=7x = 7; the reflected segment joins A′(5,3)A'(5,3) and B′(2,10)B'(2,10) to the left. Each point and its image are at equal distances from the line (AA: 2 units right, A′A': 2 units left; BB: 5 units right, B′B': 5 units left), and the length of the segment is unchanged.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2080 · 5 marks

Calculate the total memory required to store a 5 minute video in SVGA system with 24 bit true color and 30 fps.

Similar questions: Calculate the total memory required to store (2079)

Answer

SVGA resolution is taken as 800×600800 \times 600 pixels. 24-bit true colour needs 24/8=324/8 = 3 bytes per pixel.

Memory per frame

800×600×3=1,440,000 bytes800 \times 600 \times 3 = 1{,}440{,}000 \text{ bytes}

Number of frames. Duration is 5×60=3005 \times 60 = 300 s, at 30 frames per second:

300×30=9,000 frames300 \times 30 = 9{,}000 \text{ frames}

Total memory

1,440,000×9,000=12,960,000,000 bytes1{,}440{,}000 \times 9{,}000 = 12{,}960{,}000{,}000 \text{ bytes}

In binary units:

12,960,000,00010242≈12,359.6 MB≈12.07 GB\frac{12{,}960{,}000{,}000}{1024^2} \approx 12{,}359.6 \text{ MB} \approx 12.07 \text{ GB}

So about 12.96 x 10^9 bytes (about 12.07 GB) is needed for the uncompressed video.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2075 · 10 marks

Define window, viewport and viewing transformation. Let ABCD be the regular window with A(20, 20), B(90, 20), C(90, 70),and D(20, 70). Find the region codes for end points and use Cohen Sutherland algorithm to clip the lines P(10, 30) Q(80, 90).

Answer

Window. A window is a rectangular area of the world-coordinate scene that is selected for display. Only what lies inside the window is shown.

Viewport. A viewport is the rectangular area of the display device (screen) in device/normalised coordinates into which the contents of the window are mapped.

Viewing transformation (window-to-viewport transformation). It is the mapping of world-coordinate points of the window to the viewport, keeping the relative position of every point. For a point (xw,yw)(x_w, y_w) in a window [xwmin,xwmax]×[ywmin,ywmax][xw_{min}, xw_{max}] \times [yw_{min}, yw_{max}] and viewport [xvmin,xvmax]×[yvmin,yvmax][xv_{min}, xv_{max}] \times [yv_{min}, yv_{max}]:

xv=xvmin+(xw−xwmin) sx,yv=yvmin+(yw−ywmin) syx_v = xv_{min} + (x_w - xw_{min})\,s_x,\quad y_v = yv_{min} + (y_w - yw_{min})\,s_y

sx=xvmax−xvminxwmax−xwmin,sy=yvmax−yvminywmax−ywmins_x = \frac{xv_{max} - xv_{min}}{xw_{max} - xw_{min}},\quad s_y = \frac{yv_{max} - yv_{min}}{yw_{max} - yw_{min}}

It is carried out by translating the window to the origin, scaling to the viewport size, and translating to the viewport position.

Cohen-Sutherland clipping. The window has xmin=20x_{min} = 20, xmax=90x_{max} = 90, ymin=20y_{min} = 20, ymax=70y_{max} = 70 (from A(20,20), B(90,20), C(90,70), D(20,70)).

The 4-bit region code is b4b3b2b1b_4b_3b_2b_1 = Top, Bottom, Right, Left: bit 1 = 1 if x<xminx < x_{min}, bit 2 = 1 if x>xmaxx > x_{max}, bit 3 = 1 if y<yminy < y_{min}, bit 4 = 1 if y>ymaxy > y_{max}.

Region codes.

  • P(10,30)P(10, 30): x=10<20x = 10 < 20 so Left = 1; y=30y = 30 is between 20 and 70. Code =0001= 0001.
  • Q(80,90)Q(80, 90): x=80x = 80 is inside; y=90>70y = 90 > 70 so Top = 1. Code =1000= 1000.

Logical AND of the codes =0001 & 1000=0000= 0001 \,\&\, 1000 = 0000, and the codes are not both 0000, so the line is neither trivially accepted nor rejected. It must be clipped.

Slope: m=90−3080−10=6070=67m = \dfrac{90 - 30}{80 - 10} = \dfrac{60}{70} = \dfrac{6}{7}.

Clip P (left boundary, x=20x = 20):

y=yP+m(20−xP)=30+67(10)=38.57y = y_P + m(20 - x_P) = 30 + \frac{6}{7}(10) = 38.57

New point P′(20,38.57)P'(20, 38.57). Its code is 00000000 (inside).

Clip Q (top boundary, y=70y = 70):

x=xQ+1m(70−yQ)=80+76(70−90)=80−23.33=56.67x = x_Q + \frac{1}{m}(70 - y_Q) = 80 + \frac{7}{6}(70 - 90) = 80 - 23.33 = 56.67

New point Q′(56.67,70)Q'(56.67, 70). Its code is 00000000.

Both end points now have code 0000, so the clipped line segment to be displayed is from P′(20,38.57)P'(20, 38.57) to Q′(56.67,70)Q'(56.67, 70).

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2075 · 10 marks

List any two disadvantages of BSP tree method in visible surface detection. Make a comparision between Painter’s algorithm and A- Buffer algorithm.

Answer

Two disadvantages of the BSP tree method.

  1. Constructing the BSP tree is expensive (preprocessing), and it needs to be rebuilt when objects move, so it is not suited to dynamic scenes.
  2. Splitting polygons that cross a partitioning plane increases the number of polygons (and the size of the tree), and the tree can become unbalanced; the number of fragments is hard to predict.

(Also: the tree depends on the choice of splitting planes, and the memory use is high.)

Painter's algorithm vs A-buffer algorithm.

BasisPainter's algorithm (depth sort)A-buffer algorithm
TypeObject-space methodImage-space method (extension of the depth buffer)
PrincipleSort polygons by decreasing depth and paint from farthest to nearest, so nearer surfaces overwrite farther onesEach pixel position holds a linked list of surface data (depth, colour, opacity, coverage)
Data structureSorted list of polygonsAccumulation buffer with a linked list per pixel
TransparencyCannot handle transparent surfaces wellHandles transparent and translucent surfaces, and anti-aliasing
Overlap/cyclic problemsCyclic overlap and intersecting polygons need splittingHandled because depth is stored per pixel (no sorting)
MemoryLowHigh (a list of surfaces per pixel)
SortingRequiredNot required
SpeedSlower for large scenes due to sorting and overlap testsSlower than the plain z-buffer because of the lists, but robust
Anti-aliasingNoYes (sub-pixel area coverage)

Both are hidden surface methods. The painter's algorithm is simple and uses little memory, while the A-buffer gives more accurate results, with transparency and anti-aliasing, at a higher memory cost.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2075 · 10 marks

Describe the architecture of raster scan display. Explain about sweep, octree and boundary representations for solid modeling.

Answer

Architecture of a raster scan display. In a raster scan system the screen is a matrix of pixels. The picture is stored in a frame buffer (refresh buffer) as intensity values for each pixel, and the beam sweeps the screen row by row (scan line by scan line) from top to bottom, refreshing the display about 60 times a second.

Components:

  • CPU and system memory: run the application program and the graphics package, and place the picture definition in system memory.
  • Video controller (display controller): reads the frame buffer, computing the x and y addresses using registers, and controls the horizontal and vertical deflection of the electron beam through the x register (for the column) and y register (for the scan line).
  • Frame buffer: a memory area (often a dedicated video RAM) which stores colour/intensity values for every pixel; for nn bits per pixel it can display 2n2^n colours, with memory size =width×height×n= \text{width} \times \text{height} \times n bits.
  • Display processor (graphics controller): an optional processor that does scan conversion of graphics primitives, fill and other operations, relieving the CPU.
  • Look-up table (colour LUT) and digital-to-analog converters: convert pixel values to analog voltages for the guns of the monitor.
  • Monitor (CRT/LCD) shows the image, with the beam sweeping each line left to right with horizontal retrace after each line and vertical retrace after each frame.
 CPU <--> System memory <--> Frame buffer <--> Video controller --> Monitor
                  |                                ^
                  +---- Display processor ---------+

Solid-modeling representations.

1. Sweep representation. A solid is built by moving a 2D shape (profile) along a path.

  • Translational sweep: a 2D shape swept along a straight line gives a prism or cylinder (extrusion).
  • Rotational sweep: a 2D shape rotated about an axis gives a solid of revolution (sphere, cone, vase).
  • General sweeps follow a curved path with a changing cross-section. It is simple and easy for symmetric shapes but cannot describe all objects.

2. Octree representation. A cube enclosing the object is recursively subdivided into eight octants. Each octant is marked full (inside the object), empty (outside), or partially filled, and the partial ones are subdivided further until a resolution limit. The data is stored as a tree where each node has eight children. It is a space-partitioning method suited for volume data, medical imaging, and set operations (union, intersection) are easy, but it needs much memory for high resolution and it is approximate.

3. Boundary representation (B-rep). A solid is described by its bounding surfaces: faces, edges and vertices, with the topology (which faces share which edges and vertices) and geometry (equations of surfaces and curves). Polygon meshes are an example. It supports rendering directly and gives exact surface information, and obeys Euler's formula V−E+F=2V - E + F = 2 for simple polyhedra. It uses more storage, and checking validity is complex.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2075 · 5 marks

Give some basic color model. Give the basic command to draw the pixel and polygon in OpenGL.

Answer

Basic colour models.

  1. RGB (additive model): colours are produced by mixing Red, Green and Blue light; (0,0,0) is black and (1,1,1) is white. Used by monitors, TVs and cameras.
  2. CMY / CMYK (subtractive model): Cyan, Magenta, Yellow (plus Black K) pigments subtract light from white; C=1−RC = 1 - R, M=1−GM = 1 - G, Y=1−BY = 1 - B. Used in printing.
  3. HSV (HSB): Hue, Saturation, Value (brightness); intuitive for the user choosing colours.
  4. HLS (HSL): Hue, Lightness, Saturation.
  5. YIQ: luminance (Y) and chrominance (I, Q) used in NTSC colour TV broadcasting, which keeps compatibility with black and white sets.
  6. CIE XYZ: device-independent standard model based on human vision.

OpenGL commands.

Drawing a pixel (point):

glColor3f(1.0, 0.0, 0.0);     // set colour red
glPointSize(4.0);             // size of the point
glBegin(GL_POINTS);
    glVertex2i(100, 50);      // pixel at (100, 50)
glEnd();

(A raw pixel block can also be drawn with glDrawPixels(width, height, GL_RGB, GL_UNSIGNED_BYTE, data).)

Drawing a polygon:

glColor3f(0.0, 1.0, 0.0);
glBegin(GL_POLYGON);
    glVertex2f(50.0, 50.0);
    glVertex2f(150.0, 50.0);
    glVertex2f(100.0, 120.0);
glEnd();

glBegin(mode) starts a primitive (GL_POINTS, GL_LINES, GL_LINE_LOOP, GL_POLYGON, GL_TRIANGLES, GL_QUADS), glVertex*() gives its vertices, and glEnd() ends it; glFlush() forces the drawing to be shown.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2075 · 5 marks

Trace the Bresenham’s Line drawing algorithm for the end points(1, 1) and (8, 5).

Answer

Bresenham's line algorithm for the end points (x1,y1)=(1,1)(x_1, y_1) = (1, 1) and (x2,y2)=(8,5)(x_2, y_2) = (8, 5).

Δx=8−1=7\Delta x = 8 - 1 = 7, Δy=5−1=4\Delta y = 5 - 1 = 4. Slope m=4/7<1m = 4/7 < 1, so xx is incremented by 1 at each step.

Initial decision parameter:

p0=2Δy−Δx=8−7=1p_0 = 2\Delta y - \Delta x = 8 - 7 = 1

Rules:

  • If pk<0p_k < 0: next point (xk+1,yk)(x_k + 1, y_k) and pk+1=pk+2Δy=pk+8p_{k+1} = p_k + 2\Delta y = p_k + 8.
  • If pk≥0p_k \ge 0: next point (xk+1,yk+1)(x_k + 1, y_k + 1) and pk+1=pk+2Δy−2Δx=pk−6p_{k+1} = p_k + 2\Delta y - 2\Delta x = p_k - 6.

Starting point (1,1)(1, 1).

kpkp_kNext point (xk+1,yk+1)(x_{k+1}, y_{k+1})
01(2, 2)
11−6=−51 - 6 = -5(3, 2)
2−5+8=3-5 + 8 = 3(4, 3)
33−6=−33 - 6 = -3(5, 3)
4−3+8=5-3 + 8 = 5(6, 4)
55−6=−15 - 6 = -1(7, 4)
6−1+8=7-1 + 8 = 7(8, 5)

Pixels plotted: (1,1),(2,2),(3,2),(4,3),(5,3),(6,4),(7,4),(8,5)(1,1), (2,2), (3,2), (4,3), (5,3), (6,4), (7,4), (8,5). The last point matches the end point (8,5)(8, 5), which confirms the trace.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2075 · 5 marks

Derive the relation for three- dimensional translation and rotation.

Answer

Use homogeneous coordinates, so a point P=(x,y,z)P = (x, y, z) is written (x,y,z,1)(x, y, z, 1) and each transformation is a 4×44 \times 4 matrix.

3D translation. Translating a point by (tx,ty,tz)(t_x, t_y, t_z) along the axes gives

x′=x+tx,y′=y+ty,z′=z+tzx' = x + t_x,\quad y' = y + t_y,\quad z' = z + t_z

In matrix form P′=T⋅PP' = T\cdot P:

[x′y′z′1]=[100tx010ty001tz0001][xyz1]\begin{bmatrix} x' \\ y' \\ z' \\ 1 \end{bmatrix} = \begin{bmatrix} 1 & 0 & 0 & t_x \\ 0 & 1 & 0 & t_y \\ 0 & 0 & 1 & t_z \\ 0 & 0 & 0 & 1 \end{bmatrix}\begin{bmatrix} x \\ y \\ z \\ 1 \end{bmatrix}

The inverse translation uses −tx,−ty,−tz-t_x, -t_y, -t_z.

3D rotation. The rotation is by angle θ\theta about a coordinate axis (positive angle is counter-clockwise looking from the positive axis towards the origin).

Rotation about the z-axis. The zz coordinate is unchanged, and x,yx, y rotate as in 2D. A point at radius rr and angle ϕ\phi: x=rcos⁡ϕx = r\cos\phi, y=rsin⁡ϕy = r\sin\phi. After rotating by θ\theta:

x′=rcos⁡(ϕ+θ)=rcos⁡ϕcos⁡θ−rsin⁡ϕsin⁡θ=xcos⁡θ−ysin⁡θx' = r\cos(\phi + \theta) = r\cos\phi\cos\theta - r\sin\phi\sin\theta = x\cos\theta - y\sin\theta

y′=rsin⁡(ϕ+θ)=rcos⁡ϕsin⁡θ+rsin⁡ϕcos⁡θ=xsin⁡θ+ycos⁡θy' = r\sin(\phi + \theta) = r\cos\phi\sin\theta + r\sin\phi\cos\theta = x\sin\theta + y\cos\theta

z′=zz' = z

Rz(θ)=[cos⁡θ−sin⁡θ00sin⁡θcos⁡θ0000100001]R_z(\theta) = \begin{bmatrix} \cos\theta & -\sin\theta & 0 & 0 \\ \sin\theta & \cos\theta & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \end{bmatrix}

Rotation about the x-axis. By cyclic permutation x→y→z→xx \to y \to z \to x of the z-axis result:

y′=ycos⁡θ−zsin⁡θ,z′=ysin⁡θ+zcos⁡θ,x′=xy' = y\cos\theta - z\sin\theta,\quad z' = y\sin\theta + z\cos\theta,\quad x' = x

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}

Rotation about the y-axis. Cyclic permutation again (z′=zcos⁡θ−xsin⁡θz' = z\cos\theta - x\sin\theta, x′=zsin⁡θ+xcos⁡θx' = z\sin\theta + x\cos\theta, y′=yy' = y):

Ry(θ)=[cos⁡θ0sin⁡θ00100−sin⁡θ0cos⁡θ00001]R_y(\theta) = \begin{bmatrix} \cos\theta & 0 & \sin\theta & 0 \\ 0 & 1 & 0 & 0 \\ -\sin\theta & 0 & \cos\theta & 0 \\ 0 & 0 & 0 & 1 \end{bmatrix}

The inverse of a rotation is its transpose, R−1(θ)=R(−θ)=RT(θ)R^{-1}(\theta) = R(-\theta) = R^T(\theta). For rotation about an axis parallel to a coordinate axis, translate the object so the axis passes through the origin, rotate, then translate back: T(p) R(θ) T(−p)T(p)\,R(\theta)\,T(-p).

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2075 · 5 marks

What is the purpose of wireframe representation? Describe about boundary and space partitioning.

Answer

Wireframe representation. In a wireframe model an object is represented only by its edges (lines and curves) and vertices, with no surface information. Purpose:

  • It is the simplest and fastest representation, with small storage, for quick display and previewing.
  • It lets the designer see the overall shape and the internal structure, since all edges (even hidden ones) are visible, so it is used in CAD for design interaction.
  • It is used for interactive manipulation such as rotation and checking positions, because it needs little computing.
  • It is a starting point for generating surface and solid models.

Its weakness is ambiguity (the same wireframe can be read as different solids), no hidden-line removal, and no volume or surface properties.

Boundary representation. The solid is described by its surface boundary, a set of surface elements (faces, edges and vertices) with their connectivity. The polygon mesh, with vertex, edge and face tables, is typical. The inside is implied by the surface. The representation is exact for polyhedra and renders quickly, but needs a lot of storage for curved objects, and the geometry and topology must be consistent (Euler's formula V−E+F=2V - E + F = 2).

Space partitioning representation. The 3D space containing the object is divided into non-overlapping solid cells, usually cubes, and the object is described by the cells it occupies. Methods:

  • Octree: the cube is recursively divided into 8 octants until each is full, empty, or at the resolution limit.
  • BSP tree: space is recursively split by planes into two half-spaces.
  • Voxel (uniform grid) / cell decomposition.

It makes volume-related operations, such as union, intersection and mass properties, easy and suits medical imaging, but it is approximate, and needs much memory for fine detail.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2075 · 5 marks

Plot the ellipse centered at (0, 0) with radius r_x = 8 and r_y = 6, using mid point ellipse drawing algorithm.

Answer

Midpoint ellipse algorithm with centre (0,0)(0, 0), rx=8r_x = 8, ry=6r_y = 6. rx2=64r_x^2 = 64, ry2=36r_y^2 = 36, 2ry2=722r_y^2 = 72, 2rx2=1282r_x^2 = 128. Only the first quadrant is computed; the other quadrants follow by symmetry.

Region 1 (slope magnitude < 1). Start at (x0,y0)=(0,ry)=(0,6)(x_0, y_0) = (0, r_y) = (0, 6).

p10=ry2−rx2ry+14rx2=36−384+16=−332p1_0 = r_y^2 - r_x^2 r_y + \tfrac{1}{4}r_x^2 = 36 - 384 + 16 = -332

Steps: if p1k<0p1_k < 0, next point (xk+1,yk)(x_k + 1, y_k) and p1k+1=p1k+2ry2xk+1+ry2p1_{k+1} = p1_k + 2r_y^2 x_{k+1} + r_y^2. Otherwise next point (xk+1,yk−1)(x_k + 1, y_k - 1) and p1k+1=p1k+2ry2xk+1−2rx2yk+1+ry2p1_{k+1} = p1_k + 2r_y^2 x_{k+1} - 2r_x^2 y_{k+1} + r_y^2. Continue while 2ry2x<2rx2y2r_y^2 x < 2r_x^2 y.

kp1kp1_k(xk+1,yk+1)(x_{k+1}, y_{k+1})2ry2xk+12r_y^2x_{k+1}2rx2yk+12r_x^2y_{k+1}
0-332(1, 6)72768
1−332+72+36=−224-332 + 72 + 36 = -224(2, 6)144768
2−224+144+36=−44-224 + 144 + 36 = -44(3, 6)216768
3−44+216+36=208-44 + 216 + 36 = 208(4, 5)288640
4208+288−640+36=−108208 + 288 - 640 + 36 = -108(5, 5)360640
5−108+360+36=288-108 + 360 + 36 = 288(6, 4)432512
6288+432−512+36=244288 + 432 - 512 + 36 = 244(7, 3)504384

At (7,3)(7, 3): 504≥384504 \ge 384, so move to region 2.

Region 2. Start from the last point (7,3)(7, 3):

p20=ry2(x0+12)2+rx2(y0−1)2−rx2ry2=36(56.25)+64(4)−2304=2025+256−2304=−23p2_0 = r_y^2\left(x_0 + \tfrac12\right)^2 + r_x^2(y_0 - 1)^2 - r_x^2r_y^2 = 36(56.25) + 64(4) - 2304 = 2025 + 256 - 2304 = -23

Steps: if p2k>0p2_k > 0, next point (xk,yk−1)(x_k, y_k - 1) and p2k+1=p2k−2rx2yk+1+rx2p2_{k+1} = p2_k - 2r_x^2 y_{k+1} + r_x^2. Otherwise next point (xk+1,yk−1)(x_k + 1, y_k - 1) and p2k+1=p2k+2ry2xk+1−2rx2yk+1+rx2p2_{k+1} = p2_k + 2r_y^2 x_{k+1} - 2r_x^2 y_{k+1} + r_x^2. Continue until y=0y = 0.

kp2kp2_k(xk+1,yk+1)(x_{k+1}, y_{k+1})
0-23(8, 2)
1−23+576−256+64=361-23 + 576 - 256 + 64 = 361(8, 1)
2361−128+64=297361 - 128 + 64 = 297(8, 0)

Points in the first quadrant: (0,6),(1,6),(2,6),(3,6),(4,5),(5,5),(6,4),(7,3),(8,2),(8,1),(8,0)(0,6), (1,6), (2,6), (3,6), (4,5), (5,5), (6,4), (7,3), (8,2), (8,1), (8,0).

The points in the other quadrants are (±x,±y)(\pm x, \pm y). The plot is a smooth ellipse passing through (0,±6)(0, \pm 6) and (±8,0)(\pm 8, 0).

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2075 · 5 marks

Define clipping. Discuss about cubic spline Interpolation.

Answer

Clipping is the process of identifying the portions of a picture that lie inside (or outside) a specified region, called the clip window, and discarding the rest before display. It is applied to points, lines, polygons, curves and text, and saves the time of scan-converting objects that will never be seen.

Cubic spline interpolation

A spline is a piecewise polynomial curve. A cubic spline passes through a given set of control points (it interpolates them) and is built from cubic segments

Pk(u)=aku3+bku2+cku+dk,0≤u≤1P_k(u) = a_k u^3 + b_k u^2 + c_k u + d_k, \quad 0 \le u \le 1

For n+1n+1 control points there are nn segments, so 4n4n unknown coefficients are needed. The conditions are:

  • Each segment passes through its two end points (2n2n conditions).
  • First-derivative (tangent) continuity at the n−1n-1 interior joints, Pk′(1)=Pk+1′(0)P_k'(1)=P_{k+1}'(0) (n−1n-1 conditions).
  • Second-derivative (curvature) continuity at the interior joints, Pk′′(1)=Pk+1′′(0)P_k''(1)=P_{k+1}''(0) (n−1n-1 conditions).

This gives 4n−24n-2 equations. The two remaining conditions are supplied by boundary conditions, for example:

  • Natural spline: the second derivative is zero at both end points.
  • Clamped spline: the end tangents are specified.

Properties:

  • The curve is C2C^2 continuous, so it looks very smooth.
  • It passes exactly through all control points.
  • It has global control: changing one control point changes the whole curve, since the equations form one linear system.
  • Used in animation paths, curve fitting and font design. Related forms are the Hermite, cardinal and Kochanek-Bartels splines, which give local control.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2075 · 5 marks

How can we detect shadows in computer graphics? List the challenged in computing light model.

Answer

Shadow detection in computer graphics

A point is in shadow if it cannot "see" the light source, so shadow detection is a visibility problem solved from the light's point of view. Common methods are:

  1. Shadow rays (ray tracing): from each visible surface point, cast a ray toward every light source. If the ray hits any opaque object before reaching the light, the point is in shadow and that light's diffuse and specular contribution is omitted. This is simple and accurate but costly.
  2. Shadow mapping (z-buffer method): render the scene from the light's position and store the depth in a shadow map. While rendering from the camera, transform each point into light space and compare its depth with the stored value. If the point is farther than the stored depth, it is in shadow.
  3. Shadow volumes: each occluder and light define a volume of space that lies in shadow. Counting entries and exits of these volumes (stencil buffer) along the view ray tells whether a point is inside a shadow.
  4. Projected (planar) shadows: polygons are projected onto a ground plane from the light position and drawn in a dark colour.

Challenges in computing a light model

  • Real light interaction (inter-reflection, refraction, scattering) is very complex, so models use approximations.
  • Global illumination is computationally expensive; the cost grows with the number of lights and objects.
  • Accurate material properties (reflectance, transparency, roughness) are hard to measure and represent.
  • Soft shadows (penumbra) from area lights are hard to compute, whereas point lights give only hard shadows.
  • Aliasing artefacts appear in shadow maps because of limited resolution.
  • Real-time rendering demands a trade-off between realism and speed.
  • Colour and intensity representation is limited by the display's range of intensities.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2075 · 5 marks

List some applications of VR. What might be the possible navigation techniques and manipulating interfaces in virtual reality? Justify.

Answer

Applications of virtual reality (VR)

  • Games and entertainment (immersive games, virtual theatre)
  • Education and training (flight simulators, surgery simulation, military training)
  • Medicine (therapy, rehabilitation, tele-surgery)
  • Architecture and engineering (virtual walk-through of a building, product design)
  • Scientific visualisation (molecules, astronomy)
  • Virtual tourism, museums and heritage sites
  • Marketing and virtual shopping

Navigation techniques

Navigation is how the user moves through the virtual world.

  • Physical movement (tracking): the user's real walking or head movement, tracked by sensors, is mapped to movement in the virtual world. It is the most natural, but limited by the size of the tracked space.
  • Steering (gaze or hand directed): the user points or looks in a direction and moves that way using a controller or joystick. It is simple and covers large spaces.
  • Teleportation: the user selects a target point and is instantly moved there. It reduces motion sickness.
  • Walking in place, treadmills: simulate walking while the user stays in one location.
  • Map or world-in-miniature: the user picks a location on a small map and is transported there.

Manipulation interfaces

Manipulation means selecting, grabbing, moving and rotating virtual objects.

  • Data gloves and hand tracking: direct, natural grasping with the fingers, which gives intuitive control.
  • 3D mouse, wand or controllers: a ray is cast from the controller to select an object, which is then moved with a button. Useful for distant objects.
  • Haptic devices: provide force feedback so the user feels the object.
  • Voice and gesture commands: hands-free interaction.

Justification: the best technique depends on the task. Natural techniques give a greater sense of presence but suffer from limited tracking space and hardware cost, while indirect techniques (teleport, ray-casting) cover large environments with less fatigue and reduce motion sickness. Most systems therefore combine them.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2075 · 5 marks

Mention any two color command in OpenGL. Explain about Hermite curve.

Answer

Two colour commands in OpenGL

  1. glColor3f(r, g, b) sets the current drawing colour, with each component in the range 0.0 to 1.0. Example: glColor3f(1.0, 0.0, 0.0); selects red. The variant glColor4f also takes an alpha value.
  2. glClearColor(r, g, b, a) sets the colour used to clear the colour buffer (the background), used with glClear(GL_COLOR_BUFFER_BIT). Example: glClearColor(0.0, 0.0, 0.0, 1.0);.

Hermite curve

A Hermite curve is a cubic polynomial curve defined by its two end points and the tangent vectors at those end points. Given P0P_0, P1P_1 (end points) and R0R_0, R1R_1 (tangents at P0P_0 and P1P_1), the curve is

P(u)=au3+bu2+cu+d,0≤u≤1P(u) = a u^3 + b u^2 + c u + d, \quad 0 \le u \le 1

with the conditions P(0)=P0P(0)=P_0, P(1)=P1P(1)=P_1, P′(0)=R0P'(0)=R_0, P′(1)=R1P'(1)=R_1. Solving for the coefficients gives

P(u)=(2u3−3u2+1)P0+(−2u3+3u2)P1+(u3−2u2+u)R0+(u3−u2)R1P(u) = (2u^3-3u^2+1)P_0 + (-2u^3+3u^2)P_1 + (u^3-2u^2+u)R_0 + (u^3-u^2)R_1

In matrix form,

P(u)=[u3u2u1][2−211−33−2−100101000][P0P1R0R1]P(u) = \begin{bmatrix}u^3 & u^2 & u & 1\end{bmatrix}\begin{bmatrix}2 & -2 & 1 & 1\\ -3 & 3 & -2 & -1\\ 0 & 0 & 1 & 0\\ 1 & 0 & 0 & 0\end{bmatrix}\begin{bmatrix}P_0\\P_1\\R_0\\R_1\end{bmatrix}

The four polynomials are the Hermite blending functions. Properties:

  • The curve passes through P0P_0 and P1P_1.
  • The direction and length of the tangent vectors control the shape: a longer tangent makes the curve follow its direction for longer.
  • Adjacent segments are C1C^1 continuous if the end tangent of one equals the start tangent of the next.
  • It gives local control, and is used in animation and font design.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2077 · 10 marks

List the major differences between DDA and Bradenham’s Line drawing algorithm. Illustrate the DDA algorithm to the line width end points (2, 2) and (9, 2).

Answer

Differences between DDA and Bresenham's line algorithm

DDABresenham's
Uses floating-point arithmeticUses only integer arithmetic
Uses multiplication/division to compute the slope and rounding at each stepUses only addition, subtraction and shifts, via a decision parameter
Rounding is needed at every step, so errors accumulate and the line may driftNo accumulated error; always picks the pixel nearest to the true line
SlowerFaster and more efficient
Simple to implementSomewhat more complex
Less accurate for long linesMore accurate

DDA algorithm for end points (2, 2) and (9, 2)

Algorithm:

  1. dx=x2−x1dx = x_2-x_1, dy=y2−y1dy = y_2-y_1.
  2. steps=max⁡(∣dx∣,∣dy∣)steps = \max(|dx|,|dy|).
  3. xinc=dx/stepsx_{inc} = dx/steps, yinc=dy/stepsy_{inc} = dy/steps.
  4. Starting at (x1,y1)(x_1,y_1), repeat stepssteps times: x←x+xincx \leftarrow x + x_{inc}, y←y+yincy \leftarrow y + y_{inc}, and plot (round(x),round(y))(\text{round}(x),\text{round}(y)).

Here dx=9−2=7dx = 9-2 = 7, dy=2−2=0dy = 2-2 = 0, so steps=7steps = 7, xinc=1x_{inc} = 1, yinc=0y_{inc} = 0 (a horizontal line).

kxyPlotted pixel
022(2, 2)
132(3, 2)
242(4, 2)
352(5, 2)
462(6, 2)
572(7, 2)
682(8, 2)
792(9, 2)

The line is drawn through the pixels (2,2), (3,2), (4,2), (5,2), (6,2), (7,2), (8,2), (9,2).

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2077 · 10 marks

How polygon table is used in representing polygons? Explain the representations of any three curves.

Answer

Polygon tables

A 3D object is described by a set of polygon surfaces (a polygon mesh). The data are organised in polygon tables, in two groups:

  • Geometric tables store the geometry:
    • Vertex table: coordinates of every vertex.
    • Edge table: for each edge, pointers to its two end vertices.
    • Surface (polygon) table: for each polygon, pointers to the edges forming it.
  • Attribute tables store properties such as colour, transparency, reflectivity and texture.

Example: the vertex table holds V1(x1,y1,z1),…V_1(x_1,y_1,z_1),\dots; the edge table holds E1:V1,V2E_1: V_1,V_2; E2:V2,V3E_2: V_2,V_3; and the surface table holds S1:E1,E2,E3S_1: E_1,E_2,E_3. This avoids duplicating shared vertices, makes consistency checks easy (every edge belongs to at least one polygon), and gives quick access for rendering. The plane equation Ax+By+Cz+D=0Ax+By+Cz+D=0 of each polygon is also stored; the normal (A,B,C)(A,B,C) is used for shading and visibility tests.

Representations of curves

  1. Bezier curve: defined by n+1n+1 control points PiP_i:

P(u)=∑i=0nPi(ni)ui(1−u)n−i,0≤u≤1P(u)=\sum_{i=0}^{n} P_i \binom{n}{i} u^i (1-u)^{n-i}, \quad 0\le u\le1

It interpolates the first and last control points only, lies inside the convex hull of the control polygon, and has global control. A cubic Bezier (n=3n=3) is widely used.

  1. B-spline curve: a piecewise polynomial of degree dd:

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

The blending functions Bi,dB_{i,d} are non-zero only over a limited range, giving local control, and the degree is independent of the number of control points.

  1. Hermite curve: a cubic defined by two end points and the tangents at them; it gives C1C^1 continuity between segments.

  2. Cubic spline (interpolating): a piecewise cubic through all the given points with C2C^2 continuity.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2077 · 10 marks

Define realism in human perception. What is the significance difference between rendering and image synthesis in creating computer generated 3D image? Describe any two polygon rendering methods.

Answer

Realism in human perception

Realism is the degree to which a computer-generated image appears to the viewer as a real scene. It depends on how well the image reproduces the cues the human visual system uses to perceive the world: perspective (size shrinking with distance), hidden surface removal, shading and light-surface interaction, shadows, texture, colour, transparency and reflection, motion parallax and stereo depth. The more of these cues that are modelled, the more realistic the image feels.

Rendering and image synthesis

  • Image synthesis is the overall process of creating a 2D image from a description of a 3D scene (models, materials, lights, camera). It includes modelling, viewing transformation, hidden surface removal, lighting and final display.
  • Rendering is the specific stage of that process that computes the colour of each pixel: visibility determination, illumination and shading, texturing, and so on.

So image synthesis is the broader pipeline from scene description to picture, and rendering is its computational core that produces the final shaded pixels.

Polygon rendering methods

  1. Constant (flat) shading: one intensity is computed for the entire polygon using its normal and a single illumination calculation, and the whole polygon is filled with that intensity. It is fast, but the individual facets are visible and the surface looks faceted. It is acceptable only for small polygons or distant light sources.

  2. Gouraud shading (intensity interpolation):

    • Compute the unit normal at each vertex by averaging the normals of the polygons sharing it.
    • Apply the illumination model at each vertex to get vertex intensities.
    • Linearly interpolate the intensities along the edges, then along each scan line across the polygon.

    It removes the intensity discontinuities between facets and gives a smooth look, but can miss specular highlights and produce Mach bands.

  3. Phong shading (normal interpolation): interpolate the vertex normals across the polygon and evaluate the illumination model at every pixel. It gives accurate highlights and smoother shading than Gouraud, at a higher computational cost.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2077 · 5 marks

Differentiate between vector and raster graphics.

Answer

Vector and raster graphics

Vector graphicsRaster graphics
Image is stored as mathematical descriptions of geometric primitives (points, lines, curves, polygons)Image is stored as a grid (matrix) of pixels, each with a colour value
Resolution independent; scales without loss of qualityResolution dependent; enlarging causes pixelation (jagged edges)
File size depends on the complexity of the drawing and is usually smallFile size depends on resolution and colour depth and is usually large
Best for logos, line art, technical drawings, fontsBest for photographs and images with continuous tone
Editing individual objects is easyEditing is done at pixel level
Displayed on plotters or vector displays, or converted to pixels when shownNatural for monitors, printers and scanners
Formats: SVG, EPS, AI, PDFFormats: JPEG, PNG, BMP, GIF
Hard to represent photorealistic imagesCan represent photorealistic images and subtle shading

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2077 · 5 marks

Translate a triangle ABC with co-ordinates A(0, 0), B(5, 0) and C(5, 5) by 2 units in x-direction and 3 units in y-directions.

Answer

Translation moves every point by (tx,ty)(t_x, t_y):

x′=x+tx,y′=y+tyx' = x + t_x, \quad y' = y + t_y

Here tx=2t_x = 2, ty=3t_y = 3. In homogeneous coordinates,

[x′y′1]=[102013001][xy1]\begin{bmatrix}x'\\y'\\1\end{bmatrix} = \begin{bmatrix}1&0&2\\0&1&3\\0&0&1\end{bmatrix}\begin{bmatrix}x\\y\\1\end{bmatrix}

  • A(0,0)→A′(0+2, 0+3)=A′(2,3)A(0,0) \to A'(0+2,\,0+3) = A'(2,3)
  • B(5,0)→B′(5+2, 0+3)=B′(7,3)B(5,0) \to B'(5+2,\,0+3) = B'(7,3)
  • C(5,5)→C′(5+2, 5+3)=C′(7,8)C(5,5) \to C'(5+2,\,5+3) = C'(7,8)

The translated triangle has vertices A′(2,3)A'(2,3), B′(7,3)B'(7,3), C′(7,8)C'(7,8). Its shape and size are unchanged; only its position has moved.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2077 · 5 marks

Differentiate between orthographies, parallel, and perspective projections.

Answer

Projection maps 3D points onto a 2D view plane. There are two main classes: parallel and perspective. Orthographic projection is a special case of parallel projection.

Parallel projection

Projectors (projection lines) are parallel to each other. Object size is preserved regardless of distance, and parallel lines stay parallel. It has two types:

  • Orthographic: the projectors are perpendicular to the view plane (front, top and side views). It gives true dimensions and is used in engineering drawing, but shows only one face at a time.
  • Oblique: the projectors are parallel but not perpendicular to the plane (cavalier, cabinet), showing the front face true-shaped along with some depth.

Perspective projection

Projectors converge at a single point, the centre of projection. Distant objects appear smaller (perspective foreshortening) and parallel lines not parallel to the view plane converge at vanishing points. It looks realistic, like a camera or the eye, but does not preserve sizes or angles.

BasisOrthographicParallel (general/oblique)Perspective
ProjectorsParallel, perpendicular to planeParallel, any angleConverge at a centre of projection
Size with distanceConstantConstantDecreases
RealismLowModerateHigh
MeasurementsTrueMostly preservedDistorted
UseEngineering drawingIllustrationsGames, animation, virtual reality

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2077 · 5 marks

Describe how a polygon can be represented using BSP tree with example.

Answer

BSP (Binary Space Partitioning) tree

A BSP tree represents a scene by recursively dividing space with planes (lines in 2D). Each polygon's supporting plane splits the remaining polygons into two sets: those in front of the plane and those behind it. Polygons crossing the plane are split into two pieces.

Construction:

  1. Pick a polygon and use its plane as the root partition.
  2. Classify every other polygon as in front, behind, or spanning (split the spanning ones along the plane).
  3. Recursively build the front subtree from the front set and the back subtree from the back set.
  4. Stop when a set holds one polygon or none.

Each node therefore holds a polygon (and its plane), with a front child and a back child.

Example (2D): let line segments AA, BB, CC be given with BB and CC in front of AA's line and DD behind it. Choose AA as the root. Its front set is {B,C}\{B, C\} and its back set is {D}\{D\}. Within the front set, choose BB as the node; if CC is in front of BB, then CC is the front child of BB.

        A
      /   \
     B     D
      \
       C

Use in display: to draw back to front for a viewpoint EE, traverse recursively. At each node, if EE is in front of the node's plane, draw the back subtree, then the node's polygon, then the front subtree; if EE is behind, reverse this. Once built, the tree can be traversed for any viewpoint, so it is useful in walk-throughs and games, and it supports hidden surface removal and visibility ordering without a z-buffer.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2077 · 5 marks

What is the role of ray tracing in visible surface detection? Explain How scan line algorithm is used for back face detection.

Answer

Role of ray tracing in visible surface detection

In ray tracing, a ray is cast from the viewpoint through each pixel of the view plane into the scene. The ray is intersected with all objects, and the intersection point nearest to the viewer (smallest positive tt) gives the visible surface for that pixel. This resolves visibility directly, and it works for curved surfaces too, not just polygons. The same method also traces secondary rays: reflection, refraction and shadow rays, so it gives realistic reflections, transparency and shadows along with hidden surface removal. Its drawbacks are the cost of testing every ray against every object and the need for acceleration structures.

Scan line algorithm and back-face detection

Back-face detection and the scan-line method are two different steps that work together:

  1. Back-face detection: a polygon with plane equation Ax+By+Cz+D=0Ax+By+Cz+D=0 and outward normal N=(A,B,C)N=(A,B,C) is a back face if N⋅V>0N\cdot V > 0, where VV is the viewing direction (from the viewer toward the object); with the viewer looking along −z-z, this is the test C<0C<0. Back faces are removed, which eliminates roughly half the polygons.
  2. Scan-line processing of the remaining (front-facing) polygons: for each scan line,
    • Maintain an edge table (all edges, sorted by yy) and an active edge list for the current scan line.
    • Find the spans where the scan line crosses polygons.
    • Where only one polygon covers a span, fill it with that polygon's colour.
    • Where several overlap, compare depths z=(−Ax−By−D)/Cz=(-Ax-By-D)/C at the span and display the nearest.
    • Move to the next scan line, updating xx and zz incrementally.

Thus removing back faces first reduces the polygons the scan-line algorithm must handle.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2077 · 5 marks

How virtual realities differ with our real world? Describe some components of VR system.

Answer

How virtual reality differs from the real world

  • VR is a computer-generated, simulated environment; the real world is physical.
  • In VR, the laws of physics, time and space can be changed or ignored (flying, scaling, teleporting). The real world follows fixed natural laws.
  • VR is experienced through devices such as headsets, gloves and trackers, whereas the real world is perceived directly with the senses.
  • VR is limited by the resolution, latency and field of view of the hardware, and sensory feedback (touch, smell) is incomplete.
  • VR is safe and repeatable (training for dangerous situations) and can be reset, but the real world is not.
  • VR requires hardware and software cost; reality is free.

Components of a VR system

  1. Input devices: trackers (head, hand, body), data gloves, controllers, 3D mouse, microphones. They capture the user's position and actions.
  2. Output / display devices: head-mounted display (HMD), CAVE projection systems, stereo displays for visuals; speakers/3D audio; haptic devices for touch and force feedback.
  3. Computer / graphics engine: the processing unit (CPU, GPU) which renders the scene in real time at a high frame rate, to avoid lag and motion sickness.
  4. VR software and database: the world model (3D objects, textures, physics, behaviour) and the software (VR engine, APIs) managing simulation, interaction and collision detection.
  5. User interaction interface: navigation and manipulation techniques linking the user to the virtual world.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2077 · 5 marks

Write a procedure to draw a line in OpenGL? Describe Painter’s algorithm.

Answer

Procedure to draw a line in OpenGL

#include <GL/glut.h>

void display(void)
{
    glClear(GL_COLOR_BUFFER_BIT);     // clear the window
    glColor3f(1.0, 0.0, 0.0);         // red colour
    glLineWidth(2.0);                 // line width
    glBegin(GL_LINES);
        glVertex2f(-0.5, -0.5);       // start point
        glVertex2f( 0.5,  0.5);       // end point
    glEnd();
    glFlush();
}

int main(int argc, char **argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
    glutInitWindowSize(400, 400);
    glutCreateWindow("Line");
    glClearColor(1.0, 1.0, 1.0, 1.0); // white background
    glutDisplayFunc(display);
    glutMainLoop();
    return 0;
}

glBegin(GL_LINES) treats each pair of glVertex calls as the end points of one line; GL_LINE_STRIP and GL_LINE_LOOP draw connected lines.

Painter's algorithm

This is a depth-sorting (object-space) hidden surface method that imitates a painter who paints the distant parts of a scene first and the nearer parts over them.

Steps:

  1. Sort all polygons in decreasing order of depth (greatest zz distance from the viewer first), usually by their farthest vertex or centroid.
  2. Resolve any ambiguities where depth ranges overlap (test whether polygons can be reordered, or split a polygon).
  3. Scan-convert (paint) the polygons in that order, so nearer polygons overwrite farther ones.

Advantages: simple, and no depth buffer is needed. Disadvantages: sorting takes time; it fails or needs polygon splitting for cyclically overlapping or intersecting polygons; and every polygon is painted even if hidden, which wastes work.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2077 · 5 marks

Let ABCD be the rectangle window with A(0, 0), B(10, 0), C(10, 10) and D(0, 10). Use Liang Barsky line clipping algorithm to clip the line XY where X(5, 3) and Y(15, 9)

Answer

Liang-Barsky line clipping

The line is written parametrically as x=x1+u Δxx = x_1 + u\,\Delta x, y=y1+u Δyy = y_1 + u\,\Delta y, 0≤u≤10\le u\le1, and the inside conditions xmin≤x≤xmaxx_{min}\le x\le x_{max}, ymin≤y≤ymaxy_{min}\le y\le y_{max} become pku≤qkp_k u \le q_k with

p1=−Δx, q1=x1−xmin;p2=Δx, q2=xmax−x1;p3=−Δy, q3=y1−ymin;p4=Δy, q4=ymax−y1p_1=-\Delta x,\ q_1=x_1-x_{min};\quad p_2=\Delta x,\ q_2=x_{max}-x_1;\quad p_3=-\Delta y,\ q_3=y_1-y_{min};\quad p_4=\Delta y,\ q_4=y_{max}-y_1

For pk<0p_k<0 the line enters the window at u=qk/pku=q_k/p_k; for pk>0p_k>0 it leaves at u=qk/pku=q_k/p_k. Then u1=max⁡(0,entering values)u_1=\max(0,\text{entering values}) and u2=min⁡(1,leaving values)u_2=\min(1,\text{leaving values}).

Given: window xmin=0x_{min}=0, xmax=10x_{max}=10, ymin=0y_{min}=0, ymax=10y_{max}=10; X(5,3)X(5,3), Y(15,9)Y(15,9).

Δx=15−5=10\Delta x = 15-5 = 10, Δy=9−3=6\Delta y = 9-3 = 6.

kpkp_kqkq_ku=qk/pku=q_k/p_kType
1 (left)−10-105−0=55-0=5−0.5-0.5entering
2 (right)101010−5=510-5=50.50.5leaving
3 (bottom)−6-63−0=33-0=3−0.5-0.5entering
4 (top)6610−3=710-3=71.1671.167leaving

u1=max⁡(0,−0.5,−0.5)=0u_1=\max(0,-0.5,-0.5)=0

u2=min⁡(1,0.5,1.167)=0.5u_2=\min(1,0.5,1.167)=0.5

Since u1<u2u_1<u_2, part of the line is visible.

New end points:

  • u1=0u_1=0: (5,3)(5,3)
  • u2=0.5u_2=0.5: x=5+0.5×10=10x=5+0.5\times10=10, y=3+0.5×6=6y=3+0.5\times6=6, giving (10,6)(10,6)

The clipped line runs from (5,3)(5,3) to (10,6)(10,6).

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2077 · 5 marks

Define blobby objects. Describe about basic illumination models.

Answer

Blobby objects

Blobby objects (metaballs, soft objects) are shapes that do not have a fixed, rigid surface but show a smooth, fluid distortion when they come near each other, like water droplets merging, molecular structures or muscle shapes. Each object is defined by a density (field) function that falls off with distance from its centre, for example the Gaussian

f(r)=b e−ar2f(r)=b\,e^{-a r^2}

and the total field is the sum over all the blobs. The surface is the set of points where the total field equals a threshold:

∑kbke−akrk2−T=0\sum_k b_k e^{-a_k r_k^2} - T = 0

When two blobs come close, their fields add and the surfaces blend smoothly into a single shape. Parameters aa, bb and TT control the size and smoothness.

Basic illumination models

An illumination model computes the intensity of light reflected from a surface point. The components are:

  1. Ambient light: constant background illumination from the environment, I=kaIaI = k_a I_a.
  2. Diffuse reflection (Lambert's cosine law): light scattered equally in all directions from a dull surface; it depends on the angle θ\theta between the surface normal NN and the light direction LL:

Idiff=kdIlcos⁡θ=kdIl(N⋅L)I_{diff}=k_d I_l \cos\theta = k_d I_l (N\cdot L)

  1. Specular reflection: the bright highlight on shiny surfaces, depending on the angle α\alpha between the reflected direction RR and the viewing direction VV (Phong model):

Ispec=ksIl(V⋅R)nsI_{spec}=k_s I_l (V\cdot R)^{n_s}

where nsn_s is the shininess exponent.

The Phong illumination model adds them:

I=kaIa+kdIl(N⋅L)+ksIl(V⋅R)nsI = k_a I_a + k_d I_l (N\cdot L) + k_s I_l (V\cdot R)^{n_s}

Other models include the Blinn-Phong model (uses the halfway vector HH) and the global models (ray tracing, radiosity).

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2078 · 10 marks

Define orthographic, parallel, and perspective projections. Consider a region defined by the position vector P = [1121212122211221]\begin{bmatrix}1 & 1 & 2 & 1\\ 2 & 1 & 2 & 1\\ 2 & 2 & 2 & 1\\ 1 & 2 & 2 & 1\end{bmatrix}, relative to global XYZ axis system. It is rotated by +30^0 about X-axis and passes through points (1.5, 1.5, 1.5).find the final position of the region.

Answer

Projections

Projection maps 3D points onto a 2D view plane along projection lines (projectors).

  • Parallel projection: the projectors are parallel to each other (centre of projection at infinity). Object sizes are preserved and parallel lines remain parallel. Its two types are orthographic and oblique.
  • Orthographic projection: a special parallel projection in which the projectors are perpendicular to the view plane (front, top, side views). It preserves true shape and dimensions, so it is used in engineering drawings. For projection on the z=0z=0 plane, x′=xx'=x, y′=yy'=y.
  • Perspective projection: the projectors converge at a centre of projection. Distant objects appear smaller and parallel lines converge at vanishing points, giving a realistic view. With the view plane at distance dd: x′=x dzx'=\dfrac{x\,d}{z}, y′=y dzy'=\dfrac{y\,d}{z}.

Numerical: rotation of 30 degrees about an axis parallel to X through (1.5, 1.5, 1.5)

The rotation axis is parallel to the X axis through the point (1.5,1.5,1.5)(1.5,1.5,1.5), so the transformation is: translate by (−1.5,−1.5,−1.5)(-1.5,-1.5,-1.5), rotate about X, then translate back:

M=T(1.5,1.5,1.5)  Rx(30∘)  T(−1.5,−1.5,−1.5)M = T(1.5,1.5,1.5)\;R_x(30^\circ)\;T(-1.5,-1.5,-1.5)

With cos⁡30∘=0.866\cos30^\circ=0.866, sin⁡30∘=0.5\sin30^\circ=0.5, the rotation about X (for a point (x,y,z)(x,y,z) relative to the axis) is

y′=ycos⁡θ−zsin⁡θ,z′=ysin⁡θ+zcos⁡θ,x′=xy' = y\cos\theta - z\sin\theta,\qquad z' = y\sin\theta + z\cos\theta,\qquad x'=x

For each point, with (y,z)(y,z) relative to the axis:

  • Point 1 (1,1,2)(1,1,2): relative (y,z)=(−0.5, 0.5)(y,z)=(-0.5,\,0.5). y′=−0.5(0.866)−0.5(0.5)=−0.683y' = -0.5(0.866)-0.5(0.5) = -0.683, z′=−0.5(0.5)+0.5(0.866)=0.183z' = -0.5(0.5)+0.5(0.866)=0.183. Back: y=−0.683+1.5=0.817y=-0.683+1.5=0.817, z=0.183+1.5=1.683z=0.183+1.5=1.683.
  • Point 2 (2,1,2)(2,1,2): relative (−0.5, 0.5)(-0.5,\,0.5), same result: y=0.817y=0.817, z=1.683z=1.683.
  • Point 3 (2,2,2)(2,2,2): relative (0.5, 0.5)(0.5,\,0.5). y′=0.5(0.866)−0.5(0.5)=0.183y'=0.5(0.866)-0.5(0.5)=0.183, z′=0.5(0.5)+0.5(0.866)=0.683z'=0.5(0.5)+0.5(0.866)=0.683. Back: y=1.683y=1.683, z=2.183z=2.183.
  • Point 4 (1,2,2)(1,2,2): relative (0.5, 0.5)(0.5,\,0.5), so y=1.683y=1.683, z=2.183z=2.183.

Final position:

P′=[10.8171.683120.8171.683121.6832.183111.6832.1831]P' = \begin{bmatrix}1 & 0.817 & 1.683 & 1\\ 2 & 0.817 & 1.683 & 1\\ 2 & 1.683 & 2.183 & 1\\ 1 & 1.683 & 2.183 & 1\end{bmatrix}

The xx coordinates are unchanged because rotation is about the X direction.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2078 · 10 marks

What is the method to recognize boundary point and interior point in solid modeling? Describe how BSP recursively subdivided a space into convex sets.

Answer

Boundary and interior points in solid modelling

In solid modelling, a solid is a set of points SS in 3D space. Using point-set topology:

  • A point pp is an interior point if a small ball (neighbourhood) around pp lies entirely within SS.
  • A point pp is a boundary point if every neighbourhood of pp, however small, contains both points of SS and points not in SS.
  • A point is exterior if some neighbourhood of it contains no point of SS.

The set of all boundary points is the boundary bSbS (the surface); the interior is iS=S−bSiS = S - bS. A valid solid is regular, which means it equals the closure of its interior, S=k(iS)S = k(iS), which removes dangling faces, edges or points. Regularised Boolean operations (union, intersection, difference) are used to keep results regular. The test is therefore: shrink a small ball around the point; if it is fully inside, the point is interior; if it straddles inside and outside, it is on the boundary.

BSP tree: recursive subdivision of space into convex sets

Binary Space Partitioning divides space with a plane that splits it into two half-spaces. Each half-space is a convex set, and each half-space is again divided recursively.

  1. Choose a partitioning plane (usually the plane of one polygon of the object). It divides space into the positive (front) half-space and the negative (back) half-space.
  2. Every polygon or object part is assigned to the front or back set; any polygon crossing the plane is split along it.
  3. Recursively repeat steps 1 and 2 on the front set and on the back set. Each recursion creates a new node with two children.
  4. Stop when each region contains at most one polygon (or is empty/solid), so that every leaf region is a convex cell.

Since each half-space is convex, and the intersection of convex sets is convex, every leaf region is convex. The leaves are labelled in or out of the solid, which gives a solid representation, and the tree can be traversed in back-to-front order for visibility.

          P1
        /    \
      P2      P3
     /  \    /  \
   in   out in   out

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2078 · 10 marks

List some significance of vitual reality. Differntitate between virtual reality and augmented reality with example. Demonstrate how a polygon can be created using OpenGL.

Answer

Significance of virtual reality

  • Gives immersive, interactive experience that feels real (presence).
  • Allows safe training in dangerous or costly situations (flight, surgery, military).
  • Makes it possible to visualise things that cannot be seen: molecules, the inside of the body, planets, unbuilt buildings.
  • Helps in education, giving experience-based learning.
  • Used in medicine (therapy, rehabilitation), entertainment, design and tourism.
  • Reduces the cost of physical prototyping and travel.

Virtual reality vs augmented reality

Virtual reality (VR)Augmented reality (AR)
Completely replaces the real world with a computer-generated environmentOverlays virtual objects on the real world view
User is isolated from the real surroundingsUser stays in contact with the real world
Needs a headset (HMD), sometimes gloves, trackersWorks with a smartphone, tablet or smart glasses
Needs high graphics power for full scenesNeeds less rendering, but needs accurate registration with the real world
Example: VR games such as Beat Saber, flight simulator, virtual surgery trainingExample: Pokemon Go, Snapchat filters, IKEA furniture preview, head-up display in cars

Creating a polygon in OpenGL

A polygon is drawn between glBegin(GL_POLYGON) and glEnd(), giving its vertices in order. A convex polygon must be used.

#include <GL/glut.h>

void display(void)
{
    glClear(GL_COLOR_BUFFER_BIT);
    glColor3f(0.0, 0.6, 0.3);
    glBegin(GL_POLYGON);
        glVertex2f(-0.5, -0.5);
        glVertex2f( 0.5, -0.5);
        glVertex2f( 0.7,  0.2);
        glVertex2f( 0.0,  0.7);
        glVertex2f(-0.7,  0.2);
    glEnd();
    glFlush();
}

int main(int argc, char **argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
    glutInitWindowSize(400, 400);
    glutCreateWindow("Polygon");
    glClearColor(1.0, 1.0, 1.0, 1.0);
    glutDisplayFunc(display);
    glutMainLoop();
    return 0;
}

This draws a filled pentagon. glPolygonMode(GL_FRONT_AND_BACK, GL_LINE) can be used to draw only the outline.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2078 · 5 marks

Discuss the strength and weakness of the human visual system. Describe Spline representation for the curve.

Answer

Strengths and weaknesses of the human visual system

Strengths

  • Very high resolution at the centre of vision (fovea), and a wide field of view of about 180 degrees.
  • Excellent at pattern recognition, detecting edges, shapes and motion.
  • Wide dynamic range: it adapts to a very wide range of brightness (dark to bright).
  • Good depth perception using binocular (stereo) and monocular cues.
  • Can perceive millions of colours and fill in missing information, so it tolerates noise.
  • Persistence of vision lets a sequence of still frames look like smooth motion.

Weaknesses

  • Poor resolution and colour perception at the periphery.
  • Limited sensitivity to very fine detail; it cannot distinguish pixels beyond a certain angular size.
  • Illusions: Mach bands, simultaneous contrast and optical illusions, which can mislead interpretation.
  • Perception of absolute brightness is poor (it judges relative brightness), and logarithmic in intensity.
  • Flicker is seen below about 50-60 Hz.
  • Limited attention and slow adaptation to sudden changes in lighting.

These characteristics are exploited in graphics: for example, frame rates of 24-60 fps, interpolated shading, and limited-colour displays.

Spline representation of a curve

A spline is a flexible curve produced by joining polynomial curve sections smoothly at points called knots. It is specified by control points through which the curve passes (interpolation spline) or around which it is shaped (approximation spline). Each section is usually a cubic polynomial,

x(u)=axu3+bxu2+cxu+dx,y(u), z(u) similarly,0≤u≤1x(u)=a_xu^3+b_xu^2+c_xu+d_x,\quad y(u),\ z(u)\ \text{similarly},\quad 0\le u\le1

The sections join with continuity conditions: C0C^0 (positions meet), C1C^1 (tangents match) and C2C^2 (curvature matches). Specification can be through boundary conditions, a characterising matrix form P(u)=U⋅M⋅GP(u)=U\cdot M\cdot G (with MM the basis matrix and GG the geometry vector), or blending functions. Common splines are Hermite, Bezier, B-spline and cardinal splines. They are used in CAD, animation paths, and font design.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2078 · 5 marks

Plot the 1^st octant of a circle centered at origin, having the radius 10 units.

Answer

Midpoint circle algorithm, radius r=10r=10, centre at origin

In the first octant (xx from 0 to yy, moving clockwise from (0,r)(0,r)), the decision parameter is

p0=1−r=1−10=−9p_0 = 1 - r = 1-10 = -9

At each step:

  • If pk<0p_k<0: next point is (xk+1, yk)(x_k+1,\,y_k) and pk+1=pk+2xk+1+1p_{k+1}=p_k+2x_{k+1}+1.
  • Otherwise: next point is (xk+1, yk−1)(x_k+1,\,y_k-1) and pk+1=pk+2xk+1+1−2yk+1p_{k+1}=p_k+2x_{k+1}+1-2y_{k+1}.

Stop when x≥yx\ge y.

kpkp_kNext point (xk+1,yk+1)(x_{k+1},y_{k+1})pk+1p_{k+1}
0−9-9(1,10)(1,10)−9+2+1=−6-9+2+1=-6
1−6-6(2,10)(2,10)−6+4+1=−1-6+4+1=-1
2−1-1(3,10)(3,10)−1+6+1=6-1+6+1=6
366(4,9)(4,9)6+8+1−18=−36+8+1-18=-3
4−3-3(5,9)(5,9)−3+10+1=8-3+10+1=8
588(6,8)(6,8)8+12+1−16=58+12+1-16=5
655(7,7)(7,7)5+14+1−14=65+14+1-14=6

At (7,7)(7,7), x≥yx\ge y, so we stop.

Points plotted in the first octant, starting from (0,10)(0,10):

(0,10), (1,10), (2,10), (3,10), (4,9), (5,9), (6,8), (7,7)(0,10),\ (1,10),\ (2,10),\ (3,10),\ (4,9),\ (5,9),\ (6,8),\ (7,7)

The other octants follow by symmetry: (±x,±y)(\pm x,\pm y) and (±y,±x)(\pm y,\pm x).

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2078 · 5 marks

Define fractal. Explain the Bezier curve and B-Spine curve.

Answer

Fractal

A fractal is a geometric object that has a self-similar structure at every scale and a fractal (non-integer) dimension. A fractal is generated by repeatedly applying a simple rule (iteration or recursion), and it shows infinite detail on magnification. Examples: Koch snowflake, Sierpinski triangle, Mandelbrot set, coastlines, mountains, clouds, trees. The similarity dimension is D=ln⁡nln⁡sD=\dfrac{\ln n}{\ln s}, where the object consists of nn copies each scaled by 1/s1/s (for the Koch curve, D=ln⁡4/ln⁡3≈1.26D=\ln4/\ln3\approx1.26).

Bezier curve

A Bezier curve is defined by n+1n+1 control points P0,…,PnP_0,\dots,P_n:

P(u)=∑i=0nPi Bi,n(u),Bi,n(u)=(ni)ui(1−u)n−i, 0≤u≤1P(u)=\sum_{i=0}^{n}P_i\,B_{i,n}(u),\qquad B_{i,n}(u)=\binom{n}{i}u^i(1-u)^{n-i},\ 0\le u\le1

Properties:

  • Degree is one less than the number of control points.
  • It passes through the first and last control points: P(0)=P0P(0)=P_0, P(1)=PnP(1)=P_n.
  • The tangent at the ends is along the first and last control segments.
  • It lies inside the convex hull of the control points.
  • Changing any control point changes the whole curve (global control).

For the cubic (n=3n=3): P(u)=(1−u)3P0+3u(1−u)2P1+3u2(1−u)P2+u3P3P(u)=(1-u)^3P_0+3u(1-u)^2P_1+3u^2(1-u)P_2+u^3P_3.

B-spline curve

P(u)=∑i=0nPi Bi,d(u),umin≤u≤umaxP(u)=\sum_{i=0}^{n}P_i\,B_{i,d}(u),\quad u_{min}\le u\le u_{max}

where Bi,dB_{i,d} are B-spline basis functions of degree d−1d-1 (order dd) given by the Cox-de Boor recursion over a knot vector. Properties:

  • Degree is independent of the number of control points.
  • Local control: moving a control point affects only a limited part of the curve (the basis functions are non-zero over dd knot intervals).
  • The curve lies within the convex hull of its control points.
  • Continuity Cd−2C^{d-2} at the knots.
  • It does not necessarily pass through the control points, but can be made to by using repeated (multiple) end knots.

B-splines thus overcome the global-control limitation of Bezier curves.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2078 · 5 marks

Find the new c-ordinate of the triangle ABC, with co-ordinates A(0, 0), B(1, 1) and C(5, 2) after it has been magnified to twice of its size.

Answer

Magnifying to twice the size is a uniform scaling with sx=sy=2s_x=s_y=2 about the origin:

[x′y′1]=[200020001][xy1]\begin{bmatrix}x'\\y'\\1\end{bmatrix}=\begin{bmatrix}2&0&0\\0&2&0\\0&0&1\end{bmatrix}\begin{bmatrix}x\\y\\1\end{bmatrix}

  • A(0,0)→A′(2×0, 2×0)=A′(0,0)A(0,0)\to A'(2\times0,\,2\times0)=A'(0,0)
  • B(1,1)→B′(2,2)B(1,1)\to B'(2,2)
  • C(5,2)→C′(10,4)C(5,2)\to C'(10,4)

The new triangle has vertices A′(0,0)A'(0,0), B′(2,2)B'(2,2), C′(10,4)C'(10,4). Each side is twice its original length, and the figure also moves away from the origin (since scaling is about the origin).

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2078 · 5 marks

What is the task of a polygon table? Why do we have to remove hidden surfaces? Explain with any one methodology.

Answer

Task of a polygon table

A polygon table stores the description of the polygon surfaces that make up a 3D object, in an organised form that allows quick processing. It has:

  • Geometric data: a vertex table (coordinates), an edge table (pointers to the two vertices of each edge) and a surface table (pointers to the edges of each polygon), which also holds the plane equation coefficients A,B,C,DA,B,C,D.
  • Attribute data: colour, transparency, reflectivity and texture of each polygon.

It avoids duplicating shared vertices and edges, helps to check consistency, and gives fast access during transformation, visibility tests and shading.

Why hidden surfaces must be removed

When a 3D scene is projected on the 2D screen, surfaces that lie behind others in the viewing direction would otherwise be drawn on top of nearer surfaces, and the image would look wrong and ambiguous (we could not tell which surface is in front). Removing them gives a correct, realistic picture and also saves processing time since hidden surfaces need no shading.

Method: depth-buffer (z-buffer) algorithm

Two buffers are used: a frame buffer with the colour of every pixel, and a depth buffer holding the depth (zz) of every pixel.

  1. Initialise the depth buffer to the maximum depth (far plane) and the frame buffer to the background colour.
  2. For each polygon, and for each pixel (x,y)(x,y) it covers, calculate the depth zz from the plane equation, z=−Ax−By−DCz=\dfrac{-Ax-By-D}{C} (incrementally, zx+1=z−ACz_{x+1}=z-\dfrac{A}{C}).
  3. If z<depth(x,y)z<\text{depth}(x,y) (nearer than what is stored), set depth(x,y)=z\text{depth}(x,y)=z and set the frame buffer to the polygon's colour at that pixel; otherwise leave it.
  4. After all polygons, the frame buffer holds the visible surfaces.

It is simple and works in any polygon order and for any surface, but it needs extra memory and has limited precision and difficulty with transparency.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2078 · 5 marks

Define intensity attenuation. Distinguish between Gouraud shading and Phong shading model.

Answer

Intensity attenuation

The intensity of light from a point source decreases as the distance travelled increases. In the physical case, the radiant energy falls off as 1/d21/d^2, where dd is the distance from the source. In graphics, using only 1/d21/d^2 gives too much variation for nearby sources and too little for distant ones, so an attenuation function is used:

f(d)=min⁡(1, 1a0+a1d+a2d2)f(d)=\min\left(1,\ \frac{1}{a_0+a_1d+a_2d^2}\right)

where a0a_0, a1a_1, a2a_2 are constants. The light intensity at the surface is then f(d) Ilf(d)\,I_l. This gives more realistic depth cues, with closer objects brighter than farther ones.

Gouraud shading and Phong shading

Gouraud shadingPhong shading
Interpolates intensities across the polygonInterpolates surface normals across the polygon
Illumination model is evaluated only at the verticesIllumination model is evaluated at every pixel
Fast, with less computationSlower, with more computation
Specular highlights may be missed or appear distorted, if they fall inside a polygonHighlights are rendered accurately
Mach bands may appearFewer Mach bands, smoother shading
Steps: vertex normals, vertex intensities, interpolation along edges and scan linesSteps: vertex normals, interpolate normals along edges and scan lines, normalise, apply the illumination model at each pixel
Suitable for diffuse surfaces and real-time hardwareSuitable for shiny surfaces and high quality images

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2078 · 5 marks

What is the advantage of real time rendering over offline rendering? Discuss the limitation of Z-Buffer algorithm.

Answer

Advantages of real-time rendering over offline rendering

Real-time rendering produces images fast enough (typically 30-60+ frames per second) for the user to interact with the scene, whereas offline rendering (ray tracing or path tracing for films) may take minutes or hours per frame.

  • Interactivity: the user can move the camera or objects and see the result immediately, which is essential for games, simulators, VR and CAD.
  • Speed: hardware (GPU) pipelines with rasterisation process millions of polygons per second; no waiting for a final render.
  • Fast feedback for designers: artists and engineers can change lighting, materials or geometry and judge the result at once.
  • Lower cost: it needs no render farm and can run on ordinary consumer hardware.
  • Dynamic content: animation, physics and user input can all be handled per frame.

The price is lower realism, since global illumination, accurate shadows and reflections are approximated, while offline rendering gives photo-realistic quality.

Limitations of the Z-buffer (depth-buffer) algorithm

The Z-buffer keeps, for every pixel, the depth of the nearest surface so far and updates the pixel only when a new surface is nearer.

  1. Extra memory: a depth buffer the size of the frame buffer is needed in addition to the colour buffer.
  2. Limited precision: depth is stored with finite bits, so two surfaces that are very close can have equal depth values (z-fighting) and may flicker.
  3. Every polygon is processed: all polygons are scan-converted even if hidden, which wastes time on scenes with high depth complexity (overdraw).
  4. No transparency: a single depth per pixel cannot handle translucent surfaces; they need extra sorting or an A-buffer.
  5. No anti-aliasing by itself: one depth per pixel gives jagged edges, and supersampling raises the memory further.
  6. Only for visible-surface determination: it does not compute shadows, reflections or refraction.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2078 · 5 marks

Describe the requirement for line clipping. Explain the scan line polygon filling algorithm.

Answer

Requirement for line clipping

A graphics scene is defined in world coordinates, but only the part inside the clipping window (view volume) is displayed. Line clipping is needed to:

  • remove the portions of lines that lie outside the window so that only visible parts are drawn;
  • avoid wasting time scan-converting and transforming invisible geometry;
  • prevent drawing outside the allowed screen or viewport area (and wrap-around or overflow in the frame buffer);
  • speed up later stages, since only the visible segments are passed to the display.

A line is classified as completely inside (accept), completely outside (reject) or partially inside (compute the intersection with window boundaries and keep the inside part). Algorithms such as Cohen-Sutherland and Liang-Barsky do this efficiently.

Scan-line polygon filling algorithm

The polygon is filled one scan line at a time, from the lowest yy to the highest yy.

  1. Find yminy_{min} and ymaxy_{max} of the polygon.
  2. For each scan line yy between them, find the intersections of the line with all polygon edges.
  3. Sort the intersection xx-values in increasing order.
  4. Pair them up (x1x_1-x2x_2, x3x_3-x4x_4, ...) and fill pixels between each pair (odd-even rule: the interior lies between the 1st and 2nd, 3rd and 4th intersections, and so on).
  5. Go to the next scan line and repeat.

Handling of special cases

  • A vertex shared by two edges counts as one intersection if the edges lie on opposite sides of the scan line (the vertex is a pass-through), and as two (or zero) if both edges are on the same side (a local minimum or maximum). In practice the upper end of each edge is shortened by one scan line.
  • Horizontal edges are ignored; they are filled by the neighbouring scan lines.

Efficiency using edge table and active edge list. For each edge store ymaxy_{max}, the starting xx at yminy_{min}, and the inverse slope 1/m1/m. The active edge list holds only the edges crossed by the current scan line. Moving to the next line, the intersection is updated incrementally:

xk+1=xk+1mx_{k+1} = x_k + \frac{1}{m}

so no line equation need be solved at each step. Edges are added when yy reaches their yminy_{min} and removed when yy exceeds ymaxy_{max}.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2078 · 5 marks

What is quadric surface? Compare between diffuse reflection and specular reflection.

Answer

Quadric surface

A quadric surface is a surface described by a second-degree equation in xx, yy, zz. They are common objects in modelling because they are simple to describe and render. Examples:

  • Sphere: x2+y2+z2=r2x^2 + y^2 + z^2 = r^2
  • Ellipsoid: (xrx)2+(yry)2+(zrz)2=1\left(\frac{x}{r_x}\right)^2 + \left(\frac{y}{r_y}\right)^2 + \left(\frac{z}{r_z}\right)^2 = 1
  • Torus, elliptic paraboloid, hyperboloid and cylinder are other quadrics.

Diffuse reflection vs specular reflection

BasisDiffuse reflectionSpecular reflection
SurfaceRough, dull surface (chalk, paper)Smooth, shiny surface (mirror, polished metal)
DirectionLight is scattered equally in all directionsLight is reflected mainly in one direction (angle of incidence = angle of reflection)
Viewer positionBrightness does not depend on viewpointBrightness depends on viewpoint; a highlight appears when the viewer is near the reflection direction
ModelLambert's cosine law: I=kdIlcos⁡θ=kdIl(N⋅L)I = k_d I_l \cos\theta = k_d I_l (\mathbf{N}\cdot\mathbf{L})Phong model: I=ksIl(R⋅V)nI = k_s I_l (\mathbf{R}\cdot\mathbf{V})^{n}
AppearanceGives the object its basic colourGives bright highlight spots; the colour is usually that of the light source
ShininessNo shininess exponentShininess exponent nn controls highlight size (larger nn gives a smaller, sharper highlight)

Here θ\theta is the angle between the surface normal N\mathbf{N} and the light direction L\mathbf{L}, R\mathbf{R} is the reflection vector and V\mathbf{V} is the view vector.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2079 · 10 marks

Explain the working details of Mid-point circle algorithm? Trace the points along the line path having two end points (6,9) and (2,3) using Bresenham’s line drawing algorithm.

Answer

Mid-point circle algorithm

The algorithm draws a circle of radius rr centred at the origin (then shifted to (xc,yc)(x_c, y_c)) by calculating only one octant, from (0,r)(0, r) to x=yx = y, and using 8-way symmetry for the remaining points. The circle function is

fcircle(x,y)=x2+y2−r2f_{circle}(x,y) = x^2 + y^2 - r^2

which is negative inside the circle, zero on it and positive outside. At each step xx is increased by 1 and the algorithm decides between the pixels (xk+1,yk)(x_k+1, y_k) and (xk+1,yk−1)(x_k+1, y_k-1) by evaluating ff at their midpoint (xk+1, yk−12)(x_k+1,\, y_k-\tfrac12). The decision parameter is

pk=fcircle(xk+1, yk−12)=(xk+1)2+(yk−12)2−r2p_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, the midpoint is inside the circle, so the next pixel is (xk+1,yk)(x_k+1, y_k) and pk+1=pk+2xk+1+1p_{k+1} = p_k + 2x_{k+1} + 1.
  • Otherwise the next pixel is (xk+1,yk−1)(x_k+1, y_k-1) and pk+1=pk+2xk+1+1−2yk+1p_{k+1} = p_k + 2x_{k+1} + 1 - 2y_{k+1}.

Initial point is (0,r)(0, r) and the initial parameter is

p0=54−r≈1−rp_0 = \tfrac54 - r \approx 1 - r

Steps

  1. Input rr and centre (xc,yc)(x_c, y_c); set x=0x = 0, y=ry = r, p=1−rp = 1 - r.
  2. Plot the 8 symmetric points of (x,y)(x, y) shifted by the centre.
  3. While x<yx < y: increment xx; if p<0p < 0, then p=p+2x+1p = p + 2x + 1; else y=y−1y = y - 1 and p=p+2x+1−2yp = p + 2x + 1 - 2y. Plot the symmetric points.
  4. Stop when x≥yx \ge y.

Bresenham line from (6,9) to (2,3)

Δx=∣2−6∣=4\Delta x = |2-6| = 4, Δy=∣3−9∣=6\Delta y = |3-9| = 6. Since Δy>Δx\Delta y > \Delta x the slope magnitude is greater than 1, so yy is the driving axis. Both coordinates decrease, so we trace from (2,3)(2,3) to (6,9)(6,9) (the same line, reversed); then xx and yy both increase.

p0=2Δx−Δy=8−6=2p_0 = 2\Delta x - \Delta y = 8 - 6 = 2

Rule: increment yy every step; if pk<0p_k < 0, xx is unchanged and pk+1=pk+2Δx=pk+8p_{k+1} = p_k + 2\Delta x = p_k + 8; if pk≥0p_k \ge 0, xx is incremented and pk+1=pk+2Δx−2Δy=pk−4p_{k+1} = p_k + 2\Delta x - 2\Delta y = p_k - 4.

kpkp_kNext point
02(3, 4)
1-2(3, 5)
26(4, 6)
32(5, 7)
4-2(5, 8)
56(6, 9)

Starting point is (2,3)(2,3). Points on the path: (2,3),(3,4),(3,5),(4,6),(5,7),(5,8),(6,9)(2,3), (3,4), (3,5), (4,6), (5,7), (5,8), (6,9). These are the same points traced from (6,9)(6,9) down to (2,3)(2,3).

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2079 · 10 marks

Differentiate between object space and image space methods of hidden surface removal. Describe the Z-buffer hidden surface removal algorithm.

Answer

Object space vs image space methods

BasisObject-space methodsImage-space methods
Works onObjects/polygons in the 3D scene (world/viewing coordinates)Pixels of the projected image
PrincipleCompare objects or parts of objects with each other to decide which are visibleFor each pixel, determine which object is visible at that pixel
PrecisionDevice independent; exact (floating point) precisionLimited by screen resolution
CostRoughly O(n2)O(n^2) comparisons for nn objectsRoughly O(n×p)O(n \times p) for nn objects and pp pixels
ExamplesPainter's (depth-sort) algorithm, back-face detection, area subdivision (Warnock)Z-buffer, A-buffer, scan-line, ray casting
OutputVisible parts can be drawn at any resolutionMust be recomputed if resolution changes

Z-buffer (depth-buffer) algorithm

Two buffers of the screen size are used: a frame buffer storing the colour of each pixel and a depth buffer storing the depth (zz value) of the nearest surface at each pixel.

  1. Initialise depth buffer to the maximum depth (far plane, e.g. 1.0) and the frame buffer to the background colour: depth(x,y)=1depth(x,y) = 1, frame(x,y)=backgroundframe(x,y) = background.
  2. For each polygon in the scene, scan-convert it. For each pixel (x,y)(x, y) covered by the polygon, calculate its depth zz.
  3. If z<depth(x,y)z < depth(x,y) (nearer to the viewer), set depth(x,y)=zdepth(x,y) = z and frame(x,y)=frame(x,y) = surface colour at (x,y)(x,y).
  4. After all polygons are processed, the frame buffer holds the visible surfaces.

Computing depth. From the plane equation Ax+By+Cz+D=0Ax + By + Cz + D = 0,

z=−Ax−By−DCz = \frac{-Ax - By - D}{C}

Along a scan line, moving from xx to x+1x+1 gives incrementally

z′=z−ACz' = z - \frac{A}{C}

and moving down one scan line at the same xx gives z′=z+BCz' = z + \frac{B}{C}. These incremental updates make the computation cheap.

Advantages: simple, polygons can be processed in any order, no sorting, easy to implement in hardware. Disadvantages: needs extra memory, cannot directly handle transparency, and wastes effort on hidden polygons.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2079 · 10 marks

Write the algorithm for Cohen-Sutherland Line clipping. Clip the polygon A(100,150), B(200,250) and C(300,200) with the clipping window defined by the coordinates (100,300), (300,300) and (200,100) using Sutherland Hodgeman Polygon Clipping algorithm.

Answer

Cohen-Sutherland line clipping algorithm

The plane is divided by the window edges into 9 regions, each with a 4-bit region code (bit 1 = above, bit 2 = below, bit 3 = right, bit 4 = left). The window itself has code 0000. Bits are set by

  • bit 1 (TOP) = 1 if y>ymaxy > y_{max}
  • bit 2 (BOTTOM) = 1 if y<yminy < y_{min}
  • bit 3 (RIGHT) = 1 if x>xmaxx > x_{max}
  • bit 4 (LEFT) = 1 if x<xminx < x_{min}

Algorithm

  1. Compute the region codes c1c_1, c2c_2 of the end points P1P_1, P2P_2.

  2. If c1=c2=0000c_1 = c_2 = 0000 (both codes zero), the line is completely inside: accept and draw it.

  3. Else if c1  AND  c2≠0000c_1 \;\text{AND}\; c_2 \neq 0000, the line is completely outside on one side: reject.

  4. Otherwise (partially visible): pick an end point whose code is not 0000. Find its intersection with the boundary corresponding to a bit set in its code:

    • left/right: x=xminx = x_{min} or xmaxx_{max}, y=y1+m(x−x1)y = y_1 + m(x - x_1)
    • top/bottom: y=ymaxy = y_{max} or yminy_{min}, x=x1+(y−y1)/mx = x_1 + (y - y_1)/m

    Replace that end point by the intersection point and recompute its code.

  5. Repeat from step 2 until the line is accepted or rejected.

Sutherland-Hodgman polygon clipping

The polygon is clipped against each window edge in turn; the output list of one edge is the input of the next. For each polygon edge from SS to EE:

  • S out, E in: output the intersection and EE.
  • S in, E in: output EE.
  • S in, E out: output the intersection only.
  • S out, E out: output nothing.

Numerical problem. The clipping window is the triangle with vertices P1(100,300)P_1(100,300), P2(300,300)P_2(300,300), P3(200,100)P_3(200,100). Its edges are

  • Top: y=300y = 300 (inside: y≤300y \le 300)
  • Right (P2P3P_2P_3): y=2x−300y = 2x - 300, i.e. g=2x−y−300g = 2x - y - 300 (inside: g≤0g \le 0)
  • Left (P3P1P_3P_1): y=−2x+500y = -2x + 500, i.e. f=2x+y−500f = 2x + y - 500 (inside: f≥0f \ge 0)

Polygon: A(100,150)A(100,150), B(200,250)B(200,250), C(300,200)C(300,200).

Clip against the left edge. f(A)=200+150−500=−150f(A) = 200+150-500 = -150 (out); f(B)=150f(B) = 150 (in); f(C)=300f(C) = 300 (in).

  • A→BA \to B (out to in): intersection at t=150300=0.5t = \frac{150}{300} = 0.5 gives (150,200)(150, 200); output (150,200)(150,200) and BB.
  • B→CB \to C (in to in): output CC.
  • C→AC \to A (in to out): t=300450=23t = \frac{300}{450} = \frac23 gives (166.67,166.67)(166.67, 166.67); output this point.

Result: (150,200), (200,250), (300,200), (166.67,166.67)(150,200),\ (200,250),\ (300,200),\ (166.67,166.67).

Clip against the top edge. All y≤300y \le 300, so every vertex is inside and the list is unchanged.

Clip against the right edge. g(150,200)=−200g(150,200) = -200 (in), g(200,250)=−150g(200,250) = -150 (in), g(300,200)=100g(300,200) = 100 (out), g(166.67,166.67)=−133.33g(166.67,166.67) = -133.33 (in).

  • (150,200)→(200,250)(150,200) \to (200,250): in to in; output (200,250)(200,250).
  • (200,250)→(300,200)(200,250) \to (300,200): in to out; t=150250=0.6t = \frac{150}{250} = 0.6 gives (260,220)(260, 220); output it.
  • (300,200)→(166.67,166.67)(300,200) \to (166.67,166.67): out to in; t=100233.33=37t = \frac{100}{233.33} = \frac37 gives (242.86,185.71)(242.86, 185.71); output it and (166.67,166.67)(166.67, 166.67).
  • (166.67,166.67)→(150,200)(166.67,166.67) \to (150,200): in to in; output (150,200)(150,200).

Final clipped polygon:

(200,250), (260,220), (242.86,185.71), (166.67,166.67), (150,200)(200,250),\ (260,220),\ (242.86,185.71),\ (166.67,166.67),\ (150,200)

Each new vertex lies on a window edge (for example (260,220)(260,220) satisfies y=2x−300y = 2x - 300), which checks the work.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2079 · 5 marks

Differentiate between raster and vector graphics method.

Answer

BasisRaster graphicsVector graphics
RepresentationImage stored as a grid of pixels, each with colour valueImage stored as mathematical descriptions of geometric primitives (points, lines, curves, polygons)
DisplayRefresh (raster-scan) display; the frame buffer is scanned line by lineRandom-scan (calligraphic) display; the beam draws lines directly
ScalingLoses quality (pixelation, jagged edges) when enlargedScales to any size without loss of quality
File sizeDepends on resolution and colour depth; usually largeDepends on complexity of shapes; usually small
RealismGood for photographs and shaded, complex imagesGood for line drawings, logos, technical drawings, fonts
EditingEdited pixel by pixelIndividual objects can be edited, moved or recoloured easily
MemoryFrame buffer of the whole screen is neededOnly a display list of commands is needed
FillingEasy to fill areas with colours and patternsFilling is harder
ExamplesBMP, JPEG, PNG, GIF; PhotoshopSVG, EPS, CDR, AI; Illustrator, CorelDRAW

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2079 · 5 marks

Explain about parametric curve. Describe the properties of Bezier curve.

Answer

Parametric curve

A parametric curve expresses each coordinate as a function of an independent parameter uu (or tt), usually in 0≤u≤10 \le u \le 1:

x=x(u),y=y(u),z=z(u)x = x(u),\quad y = y(u),\quad z = z(u)

For example, a circle is x=rcos⁡θ, y=rsin⁡θx = r\cos\theta,\ y = r\sin\theta. Unlike y=f(x)y = f(x), parametric forms can represent closed curves and curves with vertical tangents or multiple values of yy for one xx, and they are independent of the axes. Common types are Bezier, B-spline and Hermite curves. A Bezier curve with n+1n+1 control points p0,…,pn\mathbf{p}_0, \dots, \mathbf{p}_n is

P(u)=∑k=0npk Bk,n(u),Bk,n(u)=(nk)uk(1−u)n−k\mathbf{P}(u) = \sum_{k=0}^{n} \mathbf{p}_k\, B_{k,n}(u),\qquad B_{k,n}(u) = \binom{n}{k} u^k (1-u)^{n-k}

Properties of a Bezier curve

  1. It always passes through the first and last control points: P(0)=p0\mathbf{P}(0) = \mathbf{p}_0, P(1)=pn\mathbf{P}(1) = \mathbf{p}_n.
  2. The curve lies within the convex hull of its control points.
  3. The tangent at the start and end points is along the first and last control polygon segments: P′(0)=n(p1−p0)\mathbf{P}'(0) = n(\mathbf{p}_1 - \mathbf{p}_0), P′(1)=n(pn−pn−1)\mathbf{P}'(1) = n(\mathbf{p}_n - \mathbf{p}_{n-1}).
  4. The degree of the polynomial is one less than the number of control points (nn for n+1n+1 points).
  5. The blending functions are non-negative and sum to 1: ∑kBk,n(u)=1\sum_k B_{k,n}(u) = 1 (partition of unity).
  6. The curve has global control: moving one control point changes the whole curve (no local control).
  7. It is symmetric: reversing the order of control points gives the same curve.
  8. It is invariant under affine transformations (apply the transformation to the control points).
  9. It is variation diminishing: no straight line crosses the curve more often than it crosses the control polygon.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2079 · 5 marks

What are blobby objects? How it is represented? Explain the wireframe representation of 3D objects.

Answer

Blobby objects

Blobby (metaball) objects are non-rigid shapes whose surfaces show a tendency to blend or stick together when brought close, such as molecular structures, liquid drops, melting objects or muscle shapes. A blobby object is not a fixed shape; its form is the result of the interaction of several primitive "blobs".

Representation. Each blob has a Gaussian density distribution around its centre, and the total density function is the sum of these:

f(x,y,z)=∑kbk e−akrk2−T=0f(x,y,z) = \sum_k b_k\, e^{-a_k r_k^2} - T = 0

where rk=(x−xk)2+(y−yk)2+(z−zk)2r_k = \sqrt{(x-x_k)^2 + (y-y_k)^2 + (z-z_k)^2} is the distance to the centre of blob kk, aka_k and bkb_k control the blob's spread and height, and TT is a threshold. The surface is the set of points where f=0f = 0 (the sum equals the threshold). Where two blobs are far apart they remain separate; as they approach, their density fields add and a bridge forms between them. Alternatively a finite-range polynomial can be used, for example f(r)=b (1−r2/d2)2f(r) = b\,(1 - r^2/d^2)^2 for r≤dr \le d and 0 otherwise, which is cheaper to compute.

Wireframe representation of 3D objects

In wireframe (edge) representation the object is shown only by its vertices and edges; surfaces are not drawn or filled. It is stored as:

  • a vertex table with the (x,y,z)(x,y,z) of each vertex, and
  • an edge table listing the pair of vertices joined by each edge.

Features:

  • It is simple and very fast to draw, so it is used for quick previews and interactive editing.
  • It needs little memory and no hidden-surface or shading computation.
  • Its drawback is ambiguity: all edges (front and back) are visible, so the viewer may not tell which are in front, and the surfaces and volume are not defined, so one cannot compute properties like volume or do realistic shading.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2079 · 5 marks

Find the composite transformation matrix for reflection about a line y=mx+c.

Answer

Let the mirror line be y=mx+cy = mx + c. It has slope angle θ\theta with tan⁡θ=m\tan\theta = m and y-intercept (0,c)(0, c). Reflection is done by moving the line onto the x-axis, reflecting, and moving back.

Steps

  1. Translate the line down by cc so it passes through the origin: T(0,−c)T(0,-c).
  2. Rotate by −θ-\theta so the line coincides with the x-axis: R(−θ)R(-\theta).
  3. Reflect about the x-axis: Fx=[1000−10001]F_x = \begin{bmatrix}1&0&0\\0&-1&0\\0&0&1\end{bmatrix}.
  4. Rotate back by θ\theta: R(θ)R(\theta).
  5. Translate back up by cc: T(0,c)T(0,c).

Composite matrix (applied to column vectors, right to left):

M=T(0,c)⋅R(θ)⋅Fx⋅R(−θ)⋅T(0,−c)M = T(0,c)\cdot R(\theta)\cdot F_x\cdot R(-\theta)\cdot T(0,-c)

The middle product is

R(θ) Fx R(−θ)=[cos⁡2θsin⁡2θ0sin⁡2θ−cos⁡2θ0001]R(\theta)\,F_x\,R(-\theta) = \begin{bmatrix}\cos 2\theta & \sin 2\theta & 0\\ \sin 2\theta & -\cos 2\theta & 0\\ 0&0&1\end{bmatrix}

Using cos⁡2θ=1−m21+m2\cos 2\theta = \dfrac{1-m^2}{1+m^2} and sin⁡2θ=2m1+m2\sin 2\theta = \dfrac{2m}{1+m^2}, and including the translations:

M=11+m2[1−m22m−2mc2mm2−12c001+m2]M = \frac{1}{1+m^2}\begin{bmatrix}1-m^2 & 2m & -2mc\\ 2m & m^2-1 & 2c\\ 0 & 0 & 1+m^2\end{bmatrix}

so that

x′=(1−m2)x+2m y−2mc1+m2,y′=2m x+(m2−1)y+2c1+m2x' = \frac{(1-m^2)x + 2m\,y - 2mc}{1+m^2},\qquad y' = \frac{2m\,x + (m^2-1)y + 2c}{1+m^2}

Check. For m=0m = 0 (line y=cy = c): x′=xx' = x, y′=2c−yy' = 2c - y, correct. For m=1m = 1, c=0c = 0 (line y=xy = x): x′=yx' = y, y′=xy' = x, correct.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2079 · 5 marks

What is polygon table? Explain the use of this method in 3D object representation.

Answer

Polygon table

A 3D object is commonly represented by a set of polygon surfaces forming its boundary (a polygon mesh). The data about these polygons is stored in a polygon table, which has two parts:

  • Geometric data: the vertices, edges and polygon surfaces.
  • Attribute data: the colour, transparency, reflectivity (surface properties) and texture for each polygon.

The geometric data is organised in three tables:

  1. Vertex table: the coordinates of each vertex, for example V1:(x1,y1,z1)V_1: (x_1, y_1, z_1).
  2. Edge table: each edge as a pair of vertices, for example E1:V1,V2E_1: V_1, V_2.
  3. Polygon-surface table: each polygon as a list of its edges, for example S1:E1,E2,E3S_1: E_1, E_2, E_3.

Example for a triangle pair sharing an edge:

Vertex tableEdge tableSurface table
V1 (x1,y1,z1)E1: V1, V2S1: E1, E2, E3
V2 (x2,y2,z2)E2: V2, V3S2: E3, E4, E5
V3 (x3,y3,z3)E3: V3, V1
V4 (x4,y4,z4)E4: V3, V4
E5: V4, V1

Use in 3D object representation

  • It gives a compact way to store the object so that each shared vertex or edge is stored only once, saving memory.
  • Edges and vertices can be accessed quickly during transformation: the vertex coordinates are transformed once and all the polygons that use them follow.
  • It speeds up display, rendering and hidden-surface removal, since each polygon's edges are available directly.
  • Consistency can be checked, e.g. every edge must belong to at least two polygons in a closed object and every polygon must be closed; missing vertices or edges can be detected.
  • The plane equation of each polygon, Ax+By+Cz+D=0Ax + By + Cz + D = 0 (computed from three vertices), can be stored with it to give the normal vector for shading and back-face tests. A point is inside the surface if Ax+By+Cz+D<0Ax + By + Cz + D < 0 and outside if it is >0> 0.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2079 · 5 marks

Define the term ‘rendering’ in computer graphics. Explain Phong Shading Method with its advantage and disadvantage.

Answer

Rendering

Rendering is the process of generating a two-dimensional image from a 3D model (scene description of geometry, viewpoint, textures, materials and lighting) by a computer program. It covers visibility determination, illumination and shading calculations, producing the final pixel colours.

Phong shading (normal-vector interpolation)

Phong shading interpolates the surface normal vectors across the polygon and applies the illumination model at every pixel, unlike Gouraud shading, which interpolates intensities.

Steps:

  1. Compute the normal at each polygon vertex as the average of the normals of the polygons sharing that vertex: Nv=∑kNk∣∑kNk∣\mathbf{N}_v = \frac{\sum_k \mathbf{N}_k}{\left|\sum_k \mathbf{N}_k\right|}
  2. Linearly interpolate the normals along the polygon edges between vertices, and then along each scan line between the edge points.
  3. For each pixel, normalise the interpolated normal and evaluate the illumination model (ambient, diffuse and specular terms) with it to get the intensity.

For an edge between vertices 1 and 2, with a point at yy between them, the normal is

N=y−y2y1−y2N1+y1−yy1−y2N2\mathbf{N} = \frac{y - y_2}{y_1 - y_2}\mathbf{N}_1 + \frac{y_1 - y}{y_1 - y_2}\mathbf{N}_2

Advantages

  • Produces realistic, smooth shading and accurate specular highlights, even inside a polygon.
  • Greatly reduces Mach-band effects compared with Gouraud shading.

Disadvantages

  • Computationally expensive, since the illumination model is evaluated at every pixel (slower than Gouraud).
  • Still gives a faceted silhouette, as the polygon edges are not smoothed.
  • The interpolation of normals does not account for perspective foreshortening and can give anomalies on very coarse meshes.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2079 · 5 marks

Write short notes on (any two) a. BSP Tree b. Virtual Reality c. Intensity Attenuation

Answer

(a) BSP tree (Binary Space Partitioning tree)

A BSP tree is a hierarchical data structure that recursively divides space into two half-spaces by planes. It is used for hidden-surface removal and for ordering polygons back to front.

Construction:

  1. Choose a polygon from the scene and use its plane as the partitioning plane.
  2. Classify all other polygons as in front of, behind, or on the plane; a polygon crossing the plane is split into two parts.
  3. Put the front polygons in the front sub-tree and the back polygons in the back sub-tree; repeat recursively.

Display (painter's style): for a viewpoint, traverse the tree so that polygons on the far side of each plane are drawn first, then the plane's polygon, then those on the near side. The tree depends only on the geometry, so for a static scene it is built once and reused for any viewpoint, which makes it effective in games and in solid modelling.

(b) Virtual reality

Virtual reality (VR) is a computer-generated three-dimensional environment that a user can explore and interact with in real time, so that the user feels immersed in it. It uses:

  • a head-mounted display (HMD) with head tracking, so the view changes as the head moves;
  • input devices such as data gloves, motion controllers and 3D mice;
  • real-time rendering of stereoscopic images, along with 3D sound and sometimes haptic (force) feedback.

Applications include games, training simulators (pilots, surgeons), architectural walk-throughs, education, medicine and entertainment.

(c) Intensity attenuation

The intensity of light from a point source decreases as the distance from the source increases. In the real world this follows the inverse-square law, I∝1/d2I \propto 1/d^2. Using exactly 1/d21/d^2 gives too much variation for sources that are close and too little for distant ones, so graphics systems use

f(d)=min⁡(1, 1a0+a1d+a2d2)f(d) = \min\left(1,\ \frac{1}{a_0 + a_1 d + a_2 d^2}\right)

where a0a_0, a1a_1, a2a_2 are constants chosen by the user (the constant term prevents the value from becoming very large when dd is small). The intensity at a surface point is then I=f(d) IlI = f(d)\, I_l. Light from a source at infinity (a directional source such as the sun) is not attenuated.

(Any two of the above are required.)

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2080 · 10 marks

What is a Digital Differential Analyzer (DDA)? How can you draw the line using this algorithm? Trace the points on the line path between A (1,3) and B (6,7) using Bresenham’s line drawing algorithm.

Answer

Digital Differential Analyzer (DDA)

The DDA is a scan-conversion algorithm for drawing a line that uses the differential equation of the line, dy/dx=mdy/dx = m. It samples the line at unit intervals in one coordinate (the one that changes more) and finds the corresponding value of the other coordinate by adding a constant increment. It is faster than using y=mx+by = mx + b directly, since it needs only additions, but it uses floating-point arithmetic and rounding, so errors may accumulate.

Drawing a line with DDA from (x1,y1)(x_1,y_1) to (x2,y2)(x_2,y_2):

  1. Compute dx=x2−x1dx = x_2 - x_1 and dy=y2−y1dy = y_2 - y_1.
  2. Number of steps: steps=max⁡(∣dx∣,∣dy∣)steps = \max(|dx|, |dy|).
  3. Compute the increments: xinc=dx/stepsx_{inc} = dx / steps, yinc=dy/stepsy_{inc} = dy / steps.
  4. Set x=x1x = x_1, y=y1y = y_1 and plot (round(x),round(y))(\text{round}(x), \text{round}(y)).
  5. Repeat stepssteps times: x=x+xincx = x + x_{inc}, y=y+yincy = y + y_{inc}; plot (round(x),round(y))(\text{round}(x), \text{round}(y)).

(For ∣m∣≤1|m| \le 1 this gives xinc=1x_{inc} = 1, yinc=my_{inc} = m; for ∣m∣>1|m| > 1 it gives yinc=1y_{inc} = 1, xinc=1/mx_{inc} = 1/m.)

Bresenham's line from A(1,3) to B(6,7)

Δx=5\Delta x = 5, Δy=4\Delta y = 4, so the slope is 0.8<10.8 < 1 and xx is the driving axis.

p0=2Δy−Δx=8−5=3p_0 = 2\Delta y - \Delta x = 8 - 5 = 3

At each step xx increases by 1. If pk<0p_k < 0: yy stays, pk+1=pk+2Δy=pk+8p_{k+1} = p_k + 2\Delta y = p_k + 8. If pk≥0p_k \ge 0: yy increases by 1, pk+1=pk+2Δy−2Δx=pk−2p_{k+1} = p_k + 2\Delta y - 2\Delta x = p_k - 2.

kpkp_kNext point (xk+1,yk+1)(x_{k+1}, y_{k+1})
--(1, 3) start
03(2, 4)
11(3, 5)
2-1(4, 5)
37(5, 6)
45(6, 7)

Points on the line path: (1,3),(2,4),(3,5),(4,5),(5,6),(6,7)(1,3), (2,4), (3,5), (4,5), (5,6), (6,7).

Check with y=3+0.8(x−1)y = 3 + 0.8(x-1): at x=2,3,4,5x = 2,3,4,5 the exact values are 3.8,4.6,5.4,6.23.8, 4.6, 5.4, 6.2, which round to 4,5,5,64, 5, 5, 6, as found.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2080 · 10 marks

Differentiate between parallel and perspective projection with suitable diagram. Illustrate the window to viewport transformation with example.

Answer

Parallel vs perspective projection

BasisParallel projectionPerspective projection
ProjectorsParallel to each otherConverge at a single point, the centre of projection
Centre of projectionAt infinityAt a finite distance from the object
Size of objectSize independent of distance; parallel lines remain parallelDistant objects look smaller (perspective foreshortening); parallel lines converge at vanishing points
RealismLess realistic, but preserves true dimensions and angles (for orthographic)Realistic, as the human eye and camera see
UseEngineering and architectural drawingsGames, animation, virtual reality
TypesOrthographic (front, top, side, axonometric) and oblique (cavalier, cabinet)One-, two- and three-point perspective
Parallel:                    Perspective:
 object ---> |                       \
 object ---> |  view plane           object ----> | view plane
 object ---> |                       /           (projectors meet at eye)

In parallel projection with the view plane at z=0z = 0 looking along zz, xp=xx_p = x and yp=yy_p = y. In perspective projection with the eye at distance dd from the view plane,

xp=x dz,yp=y dzx_p = \frac{x\,d}{z},\qquad y_p = \frac{y\,d}{z}

Window-to-viewport transformation

A window is the region of the world coordinates to be displayed; a viewport is the area of the screen where it is displayed. The mapping keeps the relative position of every point. For a window (xwmin,ywmin)(xw_{min}, yw_{min})-(xwmax,ywmax)(xw_{max}, yw_{max}) and viewport (xvmin,yvmin)(xv_{min}, yv_{min})-(xvmax,yvmax)(xv_{max}, yv_{max}):

xv−xvminxvmax−xvmin=xw−xwminxwmax−xwmin\frac{xv - xv_{min}}{xv_{max} - xv_{min}} = \frac{xw - xw_{min}}{xw_{max} - xw_{min}}

so

xv=xvmin+(xw−xwmin) sx,yv=yvmin+(yw−ywmin) syxv = xv_{min} + (xw - xw_{min})\,s_x,\qquad yv = yv_{min} + (yw - yw_{min})\,s_y

sx=xvmax−xvminxwmax−xwmin,sy=yvmax−yvminywmax−ywmins_x = \frac{xv_{max} - xv_{min}}{xw_{max} - xw_{min}},\qquad s_y = \frac{yv_{max} - yv_{min}}{yw_{max} - yw_{min}}

It is performed as: translate the window to the origin, scale by (sx,sy)(s_x, s_y), and translate to the viewport position.

Example. Window: (20,20)(20,20) to (80,60)(80,60). Viewport: (100,100)(100,100) to (300,200)(300,200). Map the point (50,40)(50,40).

sx=300−10080−20=20060=3.33,sy=200−10060−20=10040=2.5s_x = \frac{300-100}{80-20} = \frac{200}{60} = 3.33,\qquad s_y = \frac{200-100}{60-20} = \frac{100}{40} = 2.5

xv=100+(50−20)(3.33)=100+100=200xv = 100 + (50-20)(3.33) = 100 + 100 = 200

yv=100+(40−20)(2.5)=100+50=150yv = 100 + (40-20)(2.5) = 100 + 50 = 150

The point (50,40)(50,40) is mapped to (200,150)(200,150), the centre of the viewport, as expected because (50,40)(50,40) is the centre of the window.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2080 · 10 marks

Why Liang Barsky Line Clipping Algorithm is efficient than Cohen Sutherland Algorithm? Explain the clipping procedure of Liang Barsky algorithm with suitable example.

Answer

Why Liang-Barsky is more efficient than Cohen-Sutherland

  • Cohen-Sutherland may need to compute several intersections of a line with window edges, recalculating region codes and repeating the loop each time; for a line that is partly visible it can clip against up to four boundaries one by one, producing intermediate end points.
  • Liang-Barsky uses the parametric form of the line and finds the visible part with the parameter values u1u_1 and u2u_2 directly, using only comparisons and divisions. Intersections are computed only once, at the end, and only when the line is actually visible.
  • It rejects trivially invisible lines early, without computing any intersection, so it needs fewer arithmetic operations than Cohen-Sutherland.

Clipping procedure

The line is written as

x=x1+u Δx,y=y1+u Δy,0≤u≤1,x = x_1 + u\,\Delta x,\qquad y = y_1 + u\,\Delta y,\qquad 0 \le u \le 1,

with Δx=x2−x1\Delta x = x_2 - x_1 and Δy=y2−y1\Delta y = y_2 - y_1. A point is inside the window if

xwmin≤x1+uΔx≤xwmax,ywmin≤y1+uΔy≤ywmaxxw_{min} \le x_1 + u\Delta x \le xw_{max},\qquad yw_{min} \le y_1 + u\Delta y \le yw_{max}

These four inequalities can be written as u pk≤qku\,p_k \le q_k for k=1,2,3,4k = 1,2,3,4 with

p1=−Δx, q1=x1−xwmin(left)p_1 = -\Delta x,\ q_1 = x_1 - xw_{min}\quad(\text{left}) p2=Δx, q2=xwmax−x1(right)p_2 = \Delta x,\ q_2 = xw_{max} - x_1\quad(\text{right}) p3=−Δy, q3=y1−ywmin(bottom)p_3 = -\Delta y,\ q_3 = y_1 - yw_{min}\quad(\text{bottom}) p4=Δy, q4=ywmax−y1(top)p_4 = \Delta y,\ q_4 = yw_{max} - y_1\quad(\text{top})

Algorithm

  1. Compute pkp_k and qkq_k for all four boundaries.
  2. If pk=0p_k = 0 the line is parallel to that boundary; if also qk<0q_k < 0 it lies outside, so reject it.
  3. For pk<0p_k < 0 (line goes from outside to inside) compute rk=qk/pkr_k = q_k/p_k; u1=max⁡(0, all such rk)u_1 = \max(0,\ \text{all such } r_k).
  4. For pk>0p_k > 0 (line goes from inside to outside) compute rk=qk/pkr_k = q_k/p_k; u2=min⁡(1, all such rk)u_2 = \min(1,\ \text{all such } r_k).
  5. If u1>u2u_1 > u_2 the line is completely outside: reject. Otherwise the clipped line runs from (x1+u1Δx, y1+u1Δy)(x_1 + u_1\Delta x,\ y_1 + u_1\Delta y) to (x1+u2Δx, y1+u2Δy)(x_1 + u_2\Delta x,\ y_1 + u_2\Delta y).

Example. Window: xwmin=ywmin=2xw_{min} = yw_{min} = 2, xwmax=ywmax=8xw_{max} = yw_{max} = 8. Line from P1(0,1)P_1(0,1) to P2(10,9)P_2(10,9): Δx=10\Delta x = 10, Δy=8\Delta y = 8.

kpkp_kqkq_krk=qk/pkr_k = q_k/p_k
1 (left)-100 - 2 = -20.2
2 (right)108 - 0 = 80.8
3 (bottom)-81 - 2 = -10.125
4 (top)88 - 1 = 70.875

u1=max⁡(0,0.2,0.125)=0.2u_1 = \max(0, 0.2, 0.125) = 0.2 and u2=min⁡(1,0.8,0.875)=0.8u_2 = \min(1, 0.8, 0.875) = 0.8. Since u1<u2u_1 < u_2, the line is partly visible.

New end points:

u1: (0+0.2⋅10, 1+0.2⋅8)=(2, 2.6)u_1:\ (0 + 0.2\cdot 10,\ 1 + 0.2\cdot 8) = (2,\ 2.6) u2: (0+0.8⋅10, 1+0.8⋅8)=(8, 7.4)u_2:\ (0 + 0.8\cdot 10,\ 1 + 0.8\cdot 8) = (8,\ 7.4)

The visible segment is from (2,2.6)(2, 2.6) to (8,7.4)(8, 7.4). Both points lie on the line y=1+0.8xy = 1 + 0.8x and on the left and right window edges respectively.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2080 · 5 marks

Write down algorithm steps of mid-point ellipse drawing algorithm.

Answer

Mid-point ellipse algorithm

For an ellipse with centre at the origin and radii rxr_x, ryr_y, the ellipse function is

fellipse(x,y)=ry2x2+rx2y2−rx2ry2f_{ellipse}(x,y) = r_y^2 x^2 + r_x^2 y^2 - r_x^2 r_y^2

It is negative inside the ellipse, zero on it and positive outside. Only one quadrant is calculated and the other three come from 4-way symmetry. The quadrant is split into two regions at the point where the slope is −1-1: region 1 (slope magnitude less than 1; step in xx) and region 2 (slope magnitude greater than 1; step in yy).

Algorithm steps

  1. Input rxr_x, ryr_y and the centre (xc,yc)(x_c, y_c). Set the start point (x0,y0)=(0,ry)(x_0, y_0) = (0, r_y).
  2. Region 1. Compute the initial decision parameter p10=ry2−rx2ry+14rx2p1_0 = r_y^2 - r_x^2 r_y + \tfrac14 r_x^2
  3. At each xkx_k in region 1, while 2ry2x<2rx2y2r_y^2 x < 2r_x^2 y:
    • If p1k<0p1_k < 0: next point is (xk+1,yk)(x_k+1, y_k) and p1k+1=p1k+2ry2xk+1+ry2p1_{k+1} = p1_k + 2r_y^2 x_{k+1} + r_y^2.
    • Else: next point is (xk+1,yk−1)(x_k+1, y_k-1) and p1k+1=p1k+2ry2xk+1−2rx2yk+1+ry2p1_{k+1} = p1_k + 2r_y^2 x_{k+1} - 2r_x^2 y_{k+1} + r_y^2.
  4. Region 2. Using the last point (x0,y0)(x_0, y_0) of region 1, calculate p20=ry2(x0+12)2+rx2(y0−1)2−rx2ry2p2_0 = r_y^2\left(x_0 + \tfrac12\right)^2 + r_x^2 (y_0 - 1)^2 - r_x^2 r_y^2
  5. At each yky_k in region 2, until y=0y = 0:
    • If p2k>0p2_k > 0: next point is (xk,yk−1)(x_k, y_k-1) and p2k+1=p2k−2rx2yk+1+rx2p2_{k+1} = p2_k - 2r_x^2 y_{k+1} + r_x^2.
    • Else: next point is (xk+1,yk−1)(x_k+1, y_k-1) and p2k+1=p2k+2ry2xk+1−2rx2yk+1+rx2p2_{k+1} = p2_k + 2r_y^2 x_{k+1} - 2r_x^2 y_{k+1} + r_x^2.
  6. For each calculated point, plot the symmetric points (±x,±y)(\pm x, \pm y), shifted by the centre: x=x+xcx = x + x_c, y=y+ycy = y + y_c.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2080 · 5 marks

Explain the importance of filling algorithms in graphics applications. Differentiate between boundary and flood fill algorithm with algorithm.

Answer

Importance of filling algorithms

Filling algorithms colour or pattern the interior of a closed region (polygon or shape). They are important because:

  • they give solid, shaded and realistic-looking objects instead of just outlines;
  • they are used in paint programs (bucket tool), CAD, GIS maps, charts and graphs, and games;
  • they allow patterns and textures (hatching, tiles) to be applied;
  • they are a base for shading, anti-aliasing and clipping of regions on raster displays.

Boundary fill vs flood fill

BasisBoundary fillFlood fill
RegionRegion bounded by a single boundary colourRegion of a single interior colour, bounded by any colours
Stops whenThe boundary colour is metA pixel with a colour other than the old (interior) colour is met
InputsSeed point, fill colour, boundary colourSeed point, fill colour, old interior colour
UseRegions whose boundary is drawn in one colourIrregular regions with several-coloured boundary, such as in paint programs
Testgetpixel != boundary AND != fillgetpixel == old colour

Boundary fill algorithm (4-connected)

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)

Flood fill algorithm (4-connected)

floodFill(x, y, fillColor, oldColor):
    if getPixel(x, y) == oldColor:
        setPixel(x, y, fillColor)
        floodFill(x+1, y, fillColor, oldColor)
        floodFill(x-1, y, fillColor, oldColor)
        floodFill(x, y+1, fillColor, oldColor)
        floodFill(x, y-1, fillColor, oldColor)

An 8-connected version also recurses on the four diagonal neighbours, so it can fill regions with diagonal gaps. The recursive versions use much stack; a stack/queue or scan-line approach is used in practice.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2080 · 5 marks

What is virtual reality? Explain some form of virtual reality.

Answer

Virtual reality

Virtual reality (VR) is a computer-generated, interactive, three-dimensional environment that gives the user the feeling of being present in it. The user can look around, move through and manipulate the virtual world in real time using special input and output devices (head-mounted display, data glove, motion trackers, haptic devices, 3D sound). Its key features are immersion, interaction and real-time response.

Some forms of virtual reality

  1. Non-immersive (desktop) VR: the virtual world is viewed on an ordinary monitor and controlled with a keyboard, mouse or joystick. Example: 3D games, CAD walkthroughs.
  2. Semi-immersive VR: a large screen, projection system or simulator cockpit gives a partly immersive experience while the user stays aware of the real surroundings. Example: flight simulators, driving simulators.
  3. Fully immersive VR: the user wears a head-mounted display and tracking gear (and sometimes gloves or body suit) that completely cut the user off from the real world. Example: VR gaming, surgery training.
  4. Augmented reality (AR): computer-generated objects are overlaid on a live view of the real world, for example Pokemon Go or AR navigation.
  5. Mixed reality (MR): virtual objects interact with the real world and with each other.
  6. CAVE (Cave Automatic Virtual Environment): a room whose walls are projection screens, giving a shared immersive experience to the users without a headset.
  7. Telepresence: the user controls a remote real device (robot, surgical instrument) as if present at its location.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2080 · 5 marks

Explain polygon surface representation using Polygon table and polygon meshes.

Answer

Polygon surface representation

A 3D object is most commonly represented by its boundary: a set of flat polygon surfaces that enclose the interior. It is popular because the surfaces are simple to describe, transform and render, and graphics hardware is optimised for polygons. Curved surfaces are approximated by many small polygons.

Polygon table

Polygon data is held in tables:

  • Geometric table: a vertex table (coordinates of each vertex), an edge table (each edge as a pair of vertices) and a polygon-surface table (each polygon as a list of its edges).
  • Attribute table: colour, transparency, reflectivity and texture for each polygon.

Example: a triangle S1S_1 with edges E1E_1 (V1,V2), E2E_2 (V2,V3), E3E_3 (V3,V1) is stored as S1:E1,E2,E3S_1: E_1, E_2, E_3. Storing shared vertices and edges once saves memory and makes consistency checks easy (every edge is used by at least one polygon, each polygon closes). The plane equation Ax+By+Cz+D=0Ax + By + Cz + D = 0 of each polygon is also stored; (A,B,C)(A,B,C) is the normal vector used for shading and back-face removal.

Polygon meshes

A polygon mesh is a collection of connected polygons (edges, vertices and faces) that together approximate a surface. Common forms:

  • Triangle strip: n−2n-2 connected triangles are specified by nn vertices, which is cheaper than listing 3(n−2)3(n-2) vertices.
  • Quadrilateral mesh: an n×mn \times m array of vertices defines (n−1)(m−1)(n-1)(m-1) quadrilaterals.

Triangles are preferred because they are always planar. Meshes are used because they are efficient to store and render, can approximate any shape to the required accuracy by using more polygons, and make shading with Gouraud and Phong methods straightforward. A drawback is that a smooth curve needs very many polygons, which increases storage and rendering cost.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2080 · 5 marks

What do you understand by solid modeling? Explain binary space partition method.

Answer

Solid modelling

Solid modelling is a method of representing a 3D object as a complete, unambiguous solid, with a well-defined inside and outside (interior volume), rather than only its surface or edges. Because the volume is known, properties such as mass, volume, centre of gravity and moment of inertia can be computed, and the model can be used for interference checking, cutting and machining simulation. Common representations are:

  • Constructive solid geometry (CSG): simple primitives (box, cylinder, sphere, cone) are combined by union, intersection and difference.
  • Boundary representation (B-rep): the solid is defined by its bounding faces, edges and vertices.
  • Sweep representation: a 2D shape is swept along a path (translational or rotational sweep).
  • Spatial partitioning: octrees and BSP trees.
  • Cell decomposition / voxel enumeration.

Binary space partition (BSP) method

BSP represents a solid or scene by recursively dividing space with planes into two half-spaces, giving a binary tree.

Construction:

  1. Select a polygon (or plane) as the partitioning plane. It forms the root node.
  2. Each remaining polygon is classified as in front of the plane, behind it, or on it. A polygon that crosses the plane is split in two along it.
  3. The front set becomes the front child and the back set the back child. The same process is applied recursively to each child until each node contains one polygon (or none).

Each node has the form: polygon, front sub-tree, back sub-tree.

Using it for display: with the viewpoint EE, at each node test whether EE lies in front of or behind the node's plane. If EE is in front, display the back sub-tree first (farthest), then the node's polygon, then the front sub-tree. If EE is behind, do the reverse. This gives a back-to-front order (painter's algorithm) without sorting, and works for any viewpoint, since the tree is independent of the view. Back-face culling can be combined with it.

In solid modelling a BSP tree can also classify a point as inside or outside the solid by locating it through the planes down to a leaf marked as inside or outside. Advantages are fast visibility ordering and support for Boolean operations; the drawback is the cost of building the tree and the extra polygons created by splitting.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2080 · 5 marks

How a realistic image can be generated in computer graphics? Explain fast phong shading.

Answer

Realistic images are produced by combining several steps of the rendering pipeline, each adding a cue the eye uses to judge depth and material:

  1. Modelling: objects are described with polygon meshes, curved surfaces (Bezier, B-spline) or solids, so that the shape is smooth and detailed.
  2. Viewing and projection: perspective projection gives size diminution with distance.
  3. Visible surface detection: hidden surfaces are removed (depth buffer, scan line, BSP) so only front surfaces appear.
  4. Illumination model: ambient, diffuse and specular components are computed for each point, I=kaIa+kdIl(N⋅L)+ksIl(R⋅V)nI = k_a I_a + k_d I_l(\mathbf N\cdot\mathbf L) + k_s I_l(\mathbf R\cdot\mathbf V)^{n}.
  5. Surface shading: intensity is interpolated across polygons (Gouraud or Phong shading) so facets look smooth.
  6. Extra effects: texture mapping, shadows, transparency, reflections (ray tracing) and anti-aliasing.

Fast Phong shading

Ordinary Phong shading interpolates the normal vector across the polygon and evaluates the full illumination model (including the expensive (R⋅V)n(\mathbf R\cdot\mathbf V)^n) at every pixel. Fast Phong shading reduces this cost by using a Taylor-series (forward difference) approximation of the intensity.

Let the normal at a point be interpolated as N=Ax+By+C\mathbf N = \mathbf A x + \mathbf B y + \mathbf C. The dot products in the illumination model then become

N⋅L=(A⋅L)x+(B⋅L)y+(C⋅L)\mathbf N\cdot\mathbf L = \mathbf{(A\cdot L)}x + \mathbf{(B\cdot L)}y + \mathbf{(C\cdot L)}

and the intensity is expanded as a Taylor series (quadratic in xx and yy):

I(x,y)=ax2+bxy+cy2+dx+ey+fI(x,y) = a x^2 + b xy + c y^2 + d x + e y + f

Along a scan line, the intensity at the next pixel is obtained from the previous one with only additions using forward differences:

I(x+1,y)=I(x,y)+ΔI(x,y),ΔI(x+1,y)=ΔI(x,y)+2aI(x+1,y) = I(x,y) + \Delta I(x,y),\qquad \Delta I(x+1,y)=\Delta I(x,y)+2a

So the coefficients are computed once per polygon and each pixel needs only a few additions instead of a normalisation and an exponentiation.

Steps:

  1. Determine the unit normals at the polygon vertices (average of the adjoining face normals).
  2. Compute the coefficients a,b,c,d,e,fa,b,c,d,e,f of the quadratic from the vertex data.
  3. For each scan line, compute the starting intensity and differences, and update incrementally across the span.

Advantage: much faster than true Phong shading and still gives good highlights. Limitation: accuracy falls for large polygons or when the light is close to the surface, since the quadratic is only an approximation.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2080 · 5 marks

Write short notes on a. OpenGL b. Flynn’s Classification

Answer

(a) OpenGL

OpenGL (Open Graphics Library) is a cross-platform, language-independent, hardware-independent API for rendering 2D and 3D graphics, developed by Silicon Graphics in 1992 and now maintained by the Khronos Group.

  • It provides a set of a few hundred functions (prefixed gl) for drawing primitives (points, lines, polygons), transformations, lighting, texture mapping, blending and hidden-surface removal with a depth buffer.
  • It works as a state machine: attributes such as colour, line width and matrix mode are set and stay in effect until changed.
  • Related libraries: GLU (utility functions such as gluPerspective), GLUT/freeglut (window and input handling), GLEW/GLAD (extension loading).
  • It has a pipeline architecture: vertex processing, primitive assembly, rasterisation, fragment processing, framebuffer operations. Modern OpenGL uses programmable shaders written in GLSL.
  • Example: glBegin(GL_TRIANGLES); glVertex2f(0,0); glVertex2f(1,0); glVertex2f(0,1); glEnd();

(b) Flynn's Classification

Flynn classified computer architectures by the number of instruction streams and data streams that can be processed simultaneously.

ClassInstruction streamsData streamsExample
SISDSingleSingleConventional uniprocessor
SIMDSingleMultipleVector processors, GPUs, array processors
MISDMultipleSingleRare; fault-tolerant/pipelined systolic systems
MIMDMultipleMultipleMulticore CPUs, multiprocessors, clusters

SIMD is especially important in graphics because the same operation (e.g. shading) is applied to many pixels or vertices at once; GPUs are built on this idea.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2081 · 10 marks

Derive the expression for Bresenham’s Line Drawing algorithm. Trace the points in the line path with starting point (6, 12) and end point (10, 5) using Bresenham’s line drawing algorithm.

Answer

Derivation of Bresenham's line algorithm

Consider a line from (x1,y1)(x_1,y_1) to (x2,y2)(x_2,y_2) with slope 0<m<10<m<1, Δx=x2−x1\Delta x = x_2-x_1, Δy=y2−y1\Delta y=y_2-y_1. We step xx by 1 each time and choose between the pixels (xk+1, yk)(x_k+1,\,y_k) and (xk+1, yk+1)(x_k+1,\,y_k+1).

The true line value at xk+1x_k+1 is

y=m(xk+1)+by = m(x_k+1)+b

The distances from the two candidate pixels are

d1=y−yk=m(xk+1)+b−ykd_1 = y - y_k = m(x_k+1)+b-y_k d2=(yk+1)−y=yk+1−m(xk+1)−bd_2 = (y_k+1)-y = y_k+1-m(x_k+1)-b

Their difference is

d1−d2=2m(xk+1)−2yk+2b−1d_1-d_2 = 2m(x_k+1) - 2y_k + 2b - 1

Define the decision parameter by multiplying by Δx\Delta x (positive) with m=Δy/Δxm=\Delta y/\Delta x:

pk=Δx(d1−d2)=2Δy xk−2Δx yk+c,c=2Δy+Δx(2b−1)p_k = \Delta x(d_1-d_2) = 2\Delta y\,x_k - 2\Delta x\,y_k + c,\quad c = 2\Delta y + \Delta x(2b-1)

  • If pk<0p_k<0, d1<d2d_1<d_2, so the lower pixel yky_k is closer: plot (xk+1,yk)(x_k+1,y_k).
  • If pk≥0p_k\ge 0, plot (xk+1,yk+1)(x_k+1,y_k+1).

For the next step,

pk+1−pk=2Δy(xk+1−xk)−2Δx(yk+1−yk)=2Δy−2Δx(yk+1−yk)p_{k+1}-p_k = 2\Delta y(x_{k+1}-x_k) - 2\Delta x(y_{k+1}-y_k) = 2\Delta y - 2\Delta x(y_{k+1}-y_k)

so

pk+1=pk+2Δy(pk<0),pk+1=pk+2Δy−2Δx(pk≥0)p_{k+1} = p_k + 2\Delta y \quad (p_k<0),\qquad p_{k+1}=p_k+2\Delta y-2\Delta x\quad (p_k\ge 0)

The initial value at (x1,y1)(x_1,y_1), where y1=mx1+by_1 = mx_1+b exactly, gives

p0=2Δy−Δxp_0 = 2\Delta y-\Delta x

Only integer additions and subtractions are needed.

Algorithm (for 0<m<10<m<1)

  1. Compute Δx,Δy\Delta x,\Delta y, plot (x1,y1)(x_1,y_1), set p0=2Δy−Δxp_0=2\Delta y-\Delta x.
  2. For each xkx_k: if pk<0p_k<0 plot (xk+1,yk)(x_k+1,y_k) and pk+1=pk+2Δyp_{k+1}=p_k+2\Delta y; else plot (xk+1,yk+1)(x_k+1,y_k+1) and pk+1=pk+2Δy−2Δxp_{k+1}=p_k+2\Delta y-2\Delta x.
  3. Repeat until x=x2x=x_2.

Tracing (6, 12) to (10, 5)

Δx=4\Delta x = 4, Δy=−7\Delta y = -7, so ∣m∣=7/4>1|m|=7/4>1 and the line goes down to the right. Interchange the roles of xx and yy: step yy by −1-1 each time and decide whether xx increases. Use a=∣Δy∣=7a=|\Delta y|=7 (number of steps) and b=∣Δx∣=4b=|\Delta x|=4.

p0=2b−a=8−7=1p_0 = 2b - a = 8-7 = 1

  • If p<0p<0: xx unchanged, p←p+2b=p+8p \leftarrow p+2b = p+8.
  • If p≥0p\ge 0: x←x+1x\leftarrow x+1, p←p+2b−2a=p−6p\leftarrow p+2b-2a = p-6.
kpkp_kNext point (x,y)(x,y)
01start (6, 12)
01 (≥0\ge0)(7, 11)
11−6=−51-6=-5 (<0<0)(7, 10)
2−5+8=3-5+8=3 (≥0\ge0)(8, 9)
33−6=−33-6=-3 (<0<0)(8, 8)
4−3+8=5-3+8=5 (≥0\ge0)(9, 7)
55−6=−15-6=-1 (<0<0)(9, 6)
6−1+8=7-1+8=7 (≥0\ge0)(10, 5)

Points on the line path: (6,12), (7,11), (7,10), (8,9), (8,8), (9,7), (9,6), (10,5).

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2081 · 10 marks

What is the major drawback of Sutherland Hodgeman Polygon Clipping Algorithm? Illustrate with a suitable example. Explain B-spline curve and its properties.

Answer

Major drawback of Sutherland-Hodgeman polygon clipping

The algorithm clips a polygon against each clip-window edge in turn, passing the output list of vertices to the next edge. It works well for convex polygons but fails for concave polygons: when the clipped result should consist of two or more separate pieces, the algorithm produces a single polygon with extraneous (false) edges connecting the pieces, because it outputs only one vertex list.

Example: Take a concave "U/L-shaped" polygon whose two arms both cross the right edge of a rectangular window, with the notch (the concave part) lying outside the window. Clipping against that edge keeps the vertices of both arms in a single list, so the output joins the two arms by an edge lying along the window boundary. The correct result is two disjoint polygons, but the algorithm gives one polygon with a degenerate overlapping line along the boundary, which is visible as a spurious line when the polygon is filled or its outline drawn.

Remedies: split the concave polygon into convex parts first, or use the Weiler-Atherton algorithm, which handles concave polygons and holes correctly.

B-spline curve

A B-spline curve is a piecewise polynomial curve defined by control points P0,…,Pn\mathbf P_0,\dots,\mathbf P_n, a degree dd (order k=d+1k=d+1) and a knot vector. It is

P(u)=∑i=0nPi Ni,k(u),umin⁡≤u≤umax⁡\mathbf P(u)=\sum_{i=0}^{n}\mathbf P_i\,N_{i,k}(u),\quad u_{\min}\le u\le u_{\max}

where the blending functions are given by the Cox-de Boor recursion:

Ni,1(u)={1ui≤u<ui+10otherwiseN_{i,1}(u)=\begin{cases}1 & u_i\le u<u_{i+1}\\ 0&\text{otherwise}\end{cases}

Ni,k(u)=u−uiui+k−1−uiNi,k−1(u)+ui+k−uui+k−ui+1Ni+1,k−1(u)N_{i,k}(u)=\frac{u-u_i}{u_{i+k-1}-u_i}N_{i,k-1}(u)+\frac{u_{i+k}-u}{u_{i+k}-u_{i+1}}N_{i+1,k-1}(u)

Properties

  1. The curve is a polynomial of degree k−1k-1 in each span, with continuity Ck−2C^{k-2} at the knots.
  2. Local control: moving one control point changes only the kk spans nearby, not the whole curve (unlike a Bezier curve).
  3. The degree is independent of the number of control points (unlike Bezier, whose degree is nn); n+1≥kn+1 \ge k is required.
  4. Convex hull property: the curve lies inside the convex hull of its control points, and the blending functions sum to 1 (∑iNi,k(u)=1\sum_i N_{i,k}(u)=1) and are non-negative.
  5. Affine invariance: transforming the control points transforms the curve in the same way.
  6. Variation-diminishing: the curve is no more wiggly than its control polygon.
  7. Uniform, open-uniform (the curve passes through the end points) and non-uniform knot vectors give different shapes; a Bezier curve is a special case.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2081 · 10 marks

Explain RGB color model. Differentiate between virtual reality and augmented reality with examples. Explain Binary Space Partitioning (BSP) trees with a suitable example.

Answer

RGB colour model

The RGB model is an additive colour model based on the three primaries Red, Green and Blue. Colours are produced by adding light of these three primaries, and it is used in CRT, LCD and LED displays.

  • A colour is a triple (R,G,B)(R,G,B), normally in [0,1][0,1] or 00 to 255255 per channel.
  • It is represented by a unit cube: black (0,0,0)(0,0,0) at the origin, white (1,1,1)(1,1,1) at the opposite corner, the primaries on the axes, and cyan (0,1,1)(0,1,1), magenta (1,0,1)(1,0,1), yellow (1,1,0)(1,1,0) at the other corners. The main diagonal gives greys.
  • Mixing: R + G = yellow, G + B = cyan, R + B = magenta, R + G + B = white.
  • With 8 bits per channel, 24 bits give about 16.7 million colours.

Virtual reality vs augmented reality

PointVirtual Reality (VR)Augmented Reality (AR)
EnvironmentCompletely computer-generated, replaces the real worldReal world with computer-generated objects overlaid
ImmersionFully immersivePartially immersive; user stays aware of surroundings
HardwareHead-mounted display, motion trackers, glovesSmartphone, smart glasses, HUD
InteractionWith the virtual world onlyWith real and virtual objects together
ExamplesVR games (Beat Saber), flight simulators, virtual surgery trainingPokemon Go, IKEA furniture placement app, Google Lens, navigation HUD

Binary Space Partitioning (BSP) trees

A BSP tree recursively divides space with planes into two half-spaces (front and back of the plane). It is used for visible surface determination and for object representation.

Construction:

  1. Choose a polygon as the root and use its plane as the partition plane.
  2. Classify all other polygons: in front of, behind, or straddling the plane. Straddling polygons are split into two pieces.
  3. Recursively build the front subtree and back subtree.

Display (back-to-front, painter style): for viewpoint EE, at each node, if EE is in front of the node's plane, draw the back subtree, then the node polygon, then the front subtree; otherwise reverse.

Example: Let a scene have three polygons P1P_1 (root), P2P_2 in front of P1P_1 and P3P_3 behind P1P_1. The tree is P1P_1 with front child P2P_2 and back child P3P_3. If the viewer is in front of P1P_1, the drawing order is P3,P1,P2P_3, P_1, P_2; if behind, it is P2,P1,P3P_2,P_1,P_3. If another polygon P4P_4 crosses the plane of P1P_1, it is split into P4aP_{4a} (front) and P4bP_{4b} (back).

The tree depends only on the geometry, so it is built once and a new view only needs a traversal, which is ideal for static scenes with moving viewers.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2081 · 5 marks

What do you mean by the refresh rate of a display device? Explain vector scan display with a suitable diagram.

Answer

Refresh rate

The refresh rate is the number of times per second that the image on a display is redrawn (refreshed), measured in hertz (Hz). A phosphor in a CRT glows for only a short time, and a raster or vector display must redraw the picture repeatedly to avoid flicker. Rates below about 60 Hz cause visible flicker; typical displays use 60, 75, 120 or 144 Hz. In a raster system the rate is the frame rate (frames per second) at which the frame buffer is scanned out.

Vector scan (random scan) display

In a vector scan display the electron beam is directed only to those parts of the screen where a picture is to be drawn, one line at a time, rather than sweeping the whole screen. The picture is stored as a set of line-drawing commands in a display file (refresh buffer).

  CPU --> Display file (refresh buffer) --> Display controller
                                                |
                                      (x,y) DAC / deflection
                                                |
                                           CRT beam --> screen

Operation:

  1. The application program and graphics package store line-drawing commands in the display file memory.
  2. The display processor (controller) reads each command in sequence, converts the coordinates into deflection voltages, and moves the beam to draw each line directly.
  3. After the last command, the cycle restarts, giving a refresh of 30 to 60 times a second.

Features:

  • Gives smooth, high-resolution lines with no jagged edges (no aliasing), and needs little memory since only commands are stored.
  • Refresh time depends on the number of lines; a complex picture may flicker.
  • Not suited to shaded or filled areas and realistic images; used for line drawings, CAD and plotters.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2081 · 5 marks

Plot the first octant of a circle centered at (-2, -2), having a radius of 5 units using the mid-point circle algorithm.

Answer

Mid-point circle algorithm for radius r=5r=5, centre (−2,−2)(-2,-2)

First generate the circle with centre at the origin, then shift by the centre.

Initial point (x0,y0)=(0,r)=(0,5)(x_0,y_0)=(0,r)=(0,5), initial decision parameter

p0=1−r=1−5=−4p_0 = 1 - r = 1-5=-4

Rule (while x<yx<y):

  • If pk<0p_k<0: next point (xk+1, yk)(x_k+1,\,y_k), pk+1=pk+2xk+1+1p_{k+1}=p_k+2x_{k+1}+1
  • Else: next point (xk+1, yk−1)(x_k+1,\,y_k-1), pk+1=pk+2xk+1+1−2yk+1p_{k+1}=p_k+2x_{k+1}+1-2y_{k+1}
kpkp_k(xk+1,yk+1)(x_{k+1},y_{k+1})pk+1p_{k+1}
0−4-4(1, 5)−4+3=−1-4+3=-1
1−1-1(2, 5)−1+5=4-1+5=4
244(3, 4)4+7−8=34+7-8=3
333(4, 3)stop since x>yx>y

The first octant (from x=0x=0 to x=yx=y) is therefore: (0,5), (1,5), (2,5), (3,4).

Now translate by the centre (−2,−2)(-2,-2): (x+xc,  y+yc)(x+x_c,\;y+y_c).

Origin-centredShifted to centre (−2,−2)(-2,-2)
(0, 5)(-2, 3)
(1, 5)(-1, 3)
(2, 5)(0, 3)
(3, 4)(1, 2)

Plotted points of the first octant: (-2,3), (-1,3), (0,3), (1,2). The other seven octants follow by symmetry, (±x,±y)(\pm x,\pm y) and (±y,±x)(\pm y,\pm x) about the centre.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2081 · 5 marks

Given a triangle with vertices A(2,3), B(5,5), C(4,3) by rotating 90 degrees about the origin and then translating two units in each direction. Use the homogeneous transformation matrix to find the new vertices of the triangle.

Answer

Vertices: A(2,3)A(2,3), B(5,5)B(5,5), C(4,3)C(4,3). Required transformation: rotation by 90∘90^\circ about the origin, then translation by (2,2)(2,2).

Homogeneous matrices:

R90=[cos⁡90∘−sin⁡90∘0sin⁡90∘cos⁡90∘0001]=[0−10100001],T=[102012001]R_{90}=\begin{bmatrix}\cos90^\circ&-\sin90^\circ&0\\ \sin90^\circ&\cos90^\circ&0\\0&0&1\end{bmatrix}=\begin{bmatrix}0&-1&0\\1&0&0\\0&0&1\end{bmatrix},\qquad T=\begin{bmatrix}1&0&2\\0&1&2\\0&0&1\end{bmatrix}

Composite matrix (rotation first, so M=T⋅RM=T\cdot R):

M=TR=[102012001][0−10100001]=[0−12102001]M = T R=\begin{bmatrix}1&0&2\\0&1&2\\0&0&1\end{bmatrix}\begin{bmatrix}0&-1&0\\1&0&0\\0&0&1\end{bmatrix}=\begin{bmatrix}0&-1&2\\1&0&2\\0&0&1\end{bmatrix}

Apply to the vertex matrix (columns are A,B,CA,B,C):

[0−12102001][254353111]=[−3+2−5+2−3+22+25+24+2111]=[−1−3−1476111]\begin{bmatrix}0&-1&2\\1&0&2\\0&0&1\end{bmatrix}\begin{bmatrix}2&5&4\\3&5&3\\1&1&1\end{bmatrix}=\begin{bmatrix}-3+2&-5+2&-3+2\\2+2&5+2&4+2\\1&1&1\end{bmatrix}=\begin{bmatrix}-1&-3&-1\\4&7&6\\1&1&1\end{bmatrix}

New vertices: A′(−1,4)A'(-1,4), B′(−3,7)B'(-3,7), C′(−1,6)C'(-1,6).

Check: after rotation, A→(−3,2)A\to(-3,2), B→(−5,5)B\to(-5,5), C→(−3,4)C\to(-3,4); adding (2,2)(2,2) gives the same result.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2081 · 5 marks

Construct the Bezier curve with the following polygon vertices (control points): A(1,1), B(2,3), C(4,3), and D(6,4).

Answer

For four control points the Bezier curve is cubic:

P(u)=(1−u)3P0+3u(1−u)2P1+3u2(1−u)P2+u3P3,0≤u≤1\mathbf P(u)=(1-u)^3\mathbf P_0+3u(1-u)^2\mathbf P_1+3u^2(1-u)\mathbf P_2+u^3\mathbf P_3,\quad 0\le u\le1

with P0=A(1,1)\mathbf P_0=A(1,1), P1=B(2,3)\mathbf P_1=B(2,3), P2=C(4,3)\mathbf P_2=C(4,3), P3=D(6,4)\mathbf P_3=D(6,4).

Component form:

x(u)=(1−u)3+6u(1−u)2+12u2(1−u)+6u3x(u)=(1-u)^3+6u(1-u)^2+12u^2(1-u)+6u^3 y(u)=(1−u)3+9u(1−u)2+9u2(1−u)+4u3y(u)=(1-u)^3+9u(1-u)^2+9u^2(1-u)+4u^3

Evaluate the curve at several values of uu:

uu(1−u)3(1-u)^33u(1−u)23u(1-u)^23u2(1−u)3u^2(1-u)u3u^3xxyy
0100011
0.250.4218750.4218750.1406250.0156251.9222.172
0.50.1250.3750.3750.1253.1252.875
0.750.0156250.1406250.4218750.4218754.5163.391
1000164

Example at u=0.5u=0.5: x=0.125(1)+0.375(2)+0.375(4)+0.125(6)=3.125x=0.125(1)+0.375(2)+0.375(4)+0.125(6)=3.125; y=0.125(1)+0.375(3)+0.375(3)+0.125(4)=2.875y=0.125(1)+0.375(3)+0.375(3)+0.125(4)=2.875.

The curve starts at A(1,1)A(1,1), ends at D(6,4)D(6,4), is tangent to ABAB at AA and to CDCD at DD, and passes through approximately (1.92,2.17)(1.92,2.17), (3.13,2.88)(3.13,2.88), (4.52,3.39)(4.52,3.39). It lies inside the convex hull of A,B,C,DA,B,C,D and does not pass through BB or CC.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2081 · 5 marks

Compare the Scanline Method for Visible Surface Detection with the Depth Buffer Method.

Answer

PointScan-line methodDepth-buffer (z-buffer) method
ApproachObject-space/image-space hybrid; processes the picture one scan line at a timeImage-space; processes polygons one by one, pixel by pixel
Data structuresEdge table, polygon table, active edge listDepth buffer plus refresh (frame) buffer
MemorySmall; only the current scan line is heldLarge; one depth value per pixel in addition to the frame buffer
Visibility testOn each span between edges, find the polygon with the nearest depth; if only one polygon covers the span, no depth comparison neededCompare zz of each polygon at every pixel with the stored value
Order of polygonsNot required, but needs sorting of edgesAny order
CoherenceUses scan-line, edge and span coherence heavilyUses depth coherence to compute zz incrementally across a polygon
ComplexityMore complex to implement (intersecting or cyclic overlap needs polygon splitting)Very simple and easy to implement in hardware
Transparency, intersecting surfacesHard to handleHandles intersecting surfaces naturally; transparency needs extra work
AliasingSame pixel-level aliasingSame; also depth precision problems

Both give correct visible surfaces; the scan-line method saves memory at the cost of complexity, while the depth-buffer method is simple and widely used in hardware (GPUs).

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2081 · 5 marks

Explain any two functions in OpenGL. Write the basic commands to draw the pixel and polygon in OpenGL.

Answer

Two OpenGL functions

  1. glClear(GLbitfield mask) clears the buffers named by the mask, for example glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); clears the colour buffer to the colour set by glClearColor(r,g,b,a) and resets the depth buffer. It is called at the beginning of each frame.

  2. glColor3f(GLfloat r, GLfloat g, GLfloat b) sets the current drawing colour, with each component in [0,1][0,1]; for example glColor3f(1.0, 0.0, 0.0); makes subsequent primitives red.

(Others: glViewport, glMatrixMode, glTranslatef, glFlush.)

Drawing a pixel (point)

glPointSize(4.0);
glColor3f(1.0, 1.0, 0.0);
glBegin(GL_POINTS);
    glVertex2i(100, 150);
glEnd();
glFlush();

Drawing a polygon

glColor3f(0.0, 0.0, 1.0);
glBegin(GL_POLYGON);
    glVertex2f(50.0, 50.0);
    glVertex2f(150.0, 50.0);
    glVertex2f(150.0, 120.0);
    glVertex2f(100.0, 170.0);
    glVertex2f(50.0, 120.0);
glEnd();
glFlush();

glBegin(mode) starts a list of vertices and glEnd() terminates it; glVertex* supplies each vertex. GL_POLYGON fills a convex polygon; GL_TRIANGLES and GL_QUADS are other options.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2081 · 5 marks

Differentiate between parallel projection and perspective projections.

Answer

Projection maps 3D points to a 2D view plane. The two main classes are parallel and perspective projection.

PointParallel projectionPerspective projection
ProjectorsParallel linesConverge at a single point, the centre of projection
Centre of projectionAt infinityAt a finite distance from the object
Size of objectIndependent of distance from the view plane; no diminutionFarther objects look smaller (perspective foreshortening)
Parallel linesRemain parallelConverge at vanishing points (unless parallel to the view plane)
RealismLess realisticMore realistic, like human vision or a camera
Shape and measurementsPreserves relative proportions, angles in the faces parallel to the plane; accurate measurementsDistorts distances and angles; measurements are not preserved
TypesOrthographic (front, top, side, axonometric/isometric) and oblique (cavalier, cabinet)One-, two- and three-point perspective, by number of vanishing points
MatrixAffine; last row [0  0  0  1][0\;0\;0\;1]Non-affine; the homogeneous coordinate w≠1w\ne1, needs division by ww
UsesEngineering and architectural drawings, CADGames, animation, simulation, realistic scenes

For perspective with the view plane at z=dz=d from the centre of projection at the origin: xp=x dzx_p = \dfrac{x\,d}{z}, yp=y dzy_p=\dfrac{y\,d}{z}. For orthographic projection onto z=0z=0: xp=xx_p=x, yp=yy_p=y.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2081 · 5 marks

Describe any two basic illumination models.

Answer

An illumination (lighting) model computes the intensity of light reflected from a surface point toward the viewer. Two basic models are described below.

1. Ambient light model

Ambient light is the uniform background light reflected by all surfaces from the surroundings; it has no direction. The reflected intensity is

Iamb=kaIaI_{amb}=k_a I_a

where IaI_a is the ambient light intensity and kak_a (0≤ka≤10\le k_a\le1) is the ambient reflection coefficient of the surface. A scene with only ambient light looks flat, since every point on the object gets the same intensity.

2. Diffuse reflection (Lambertian) model

Ideal diffuse reflectors (dull, matte surfaces) scatter light equally in all directions, so the intensity does not depend on the viewing direction but on the angle θ\theta between the surface normal N\mathbf N and the direction to the light source L\mathbf L (Lambert's cosine law):

Idiff=kdIlcos⁡θ=kdIl(N⋅L),0≤θ≤90∘I_{diff}=k_d I_l\cos\theta = k_d I_l(\mathbf N\cdot\mathbf L),\quad 0\le\theta\le 90^\circ

with kdk_d the diffuse coefficient and IlI_l the intensity of the point source. Combined with ambient light:

I=kaIa+kdIl(N⋅L)I = k_a I_a + k_d I_l(\mathbf N\cdot\mathbf L)

(Specular reflection / Phong model), adds a highlight for shiny surfaces:

Ispec=ksIl(R⋅V)nsI_{spec}=k_s I_l(\mathbf R\cdot\mathbf V)^{n_s}

where R\mathbf R is the reflection direction, V\mathbf V the viewing direction and nsn_s the shininess exponent. The full Phong model is I=kaIa+kdIl(N⋅L)+ksIl(R⋅V)nsI=k_aI_a+k_dI_l(\mathbf N\cdot\mathbf L)+k_sI_l(\mathbf R\cdot\mathbf V)^{n_s}.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2081 · 5 marks

Write short notes on: a) Sweep Representation b) Intensity Attenuation

Answer

(a) Sweep representation

Sweep representation constructs a 3D solid by moving a 2D shape or a 3D object along a path through space.

  • Translational sweep: a 2D region is moved along a straight line perpendicular to its plane. A rectangle swept along a line gives a cuboid; a circle gives a cylinder. The solid is the union of all positions of the shape.
  • Rotational sweep: a 2D shape is rotated about an axis, for example a semicircle swept 360∘360^\circ gives a sphere, and a rectangle gives a cylinder or a rectangle offset from the axis gives a ring (torus when the shape is a circle).
  • General sweep: the path can be curved and the shape can scale or rotate along the path (e.g. pipes, spiral staircases, spring).

It is simple, produces symmetric objects efficiently and is used in CAD, but cannot represent arbitrary shapes; usually it is combined with Boolean operations in constructive solid geometry.

(b) Intensity attenuation

The intensity of light from a point source decreases as it travels away from the source; this is intensity attenuation. In theory it follows the inverse-square law, I∝1/d2I\propto 1/d^2, where dd is the distance from the source. In practice a pure 1/d21/d^2 gives too much variation between near and far surfaces when the light is far or too little when the source is close, so a function with a bounded value is used:

f(d)=min⁡(1a0+a1d+a2d2,  1)f(d)=\min\left(\frac{1}{a_0+a_1d+a_2d^2},\;1\right)

where a0,a1,a2a_0,a_1,a_2 are constants that can be adjusted. The radial intensity attenuation is then Il⋅f(d)I_l \cdot f(d), so the diffuse term becomes

I=kaIa+f(d) kdIl(N⋅L)I = k_aI_a + f(d)\,k_dI_l(\mathbf N\cdot\mathbf L)

It gives depth cues: nearer surfaces look brighter, and farther ones are darker, which makes the image more realistic. For a light at infinity no attenuation is applied.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2082 · 10 marks

Explain Bresenham’s line drawing algorithms. Compare it with DDA line algorithm. Draw a line from (2, 3) to (10, 8) by using Bresenham’s algorithm.

Answer

Bresenham's line drawing algorithm

Bresenham's algorithm draws a line using only integer arithmetic. For a line with 0<m<10<m<1 it moves one pixel in xx at each step and decides whether yy stays the same or increases by 1, using a decision parameter based on the difference of the distances of the two candidate pixels from the true line.

With Δx=x2−x1\Delta x=x_2-x_1, Δy=y2−y1\Delta y=y_2-y_1:

  1. Plot the start point (x1,y1)(x_1,y_1) and compute p0=2Δy−Δxp_0=2\Delta y-\Delta x.
  2. At each xkx_k: if pk<0p_k<0, plot (xk+1,yk)(x_k+1,y_k) and pk+1=pk+2Δyp_{k+1}=p_k+2\Delta y; otherwise plot (xk+1,yk+1)(x_k+1,y_k+1) and pk+1=pk+2Δy−2Δxp_{k+1}=p_k+2\Delta y-2\Delta x.
  3. Repeat Δx\Delta x times. For other slopes, swap the roles of xx and yy or change the signs of the steps.

Comparison with DDA

PointDDABresenham
ArithmeticFloating point: xk+1=xk+Δx/stepsx_{k+1}=x_k+\Delta x/\text{steps}, needs roundingInteger only: additions, subtractions and shifts
SpeedSlower (rounding, floating point)Faster
AccuracyRound-off error accumulates, the line may drift for long linesNo accumulated error, the closest pixel is always chosen
HardwareHarder to implementEasy to implement in hardware
ResultLess accurateMore accurate and efficient

Line from (2, 3) to (10, 8)

Δx=8\Delta x=8, Δy=5\Delta y=5, m=0.625<1m=0.625<1.

p0=2Δy−Δx=10−8=2,2Δy=10,2Δy−2Δx=−6p_0=2\Delta y-\Delta x=10-8=2,\quad 2\Delta y=10,\quad 2\Delta y-2\Delta x=-6

kpkp_kNext pixel
start(2, 3)
02 (≥0\ge0)(3, 4)
12−6=−42-6=-4 (<0<0)(4, 4)
2−4+10=6-4+10=6 (≥0\ge0)(5, 5)
36−6=06-6=0 (≥0\ge0)(6, 6)
40−6=−60-6=-6 (<0<0)(7, 6)
5−6+10=4-6+10=4 (≥0\ge0)(8, 7)
64−6=−24-6=-2 (<0<0)(9, 7)
7−2+10=8-2+10=8 (≥0\ge0)(10, 8)

Pixels plotted: (2,3), (3,4), (4,4), (5,5), (6,6), (7,6), (8,7), (9,7), (10,8).

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2082 · 10 marks

What is a polygon mesh? Describe its types. Construct a polygon table and edge table for a cube of side 2 units placed with one vertex at origin.

Answer

Polygon mesh

A polygon mesh is a collection of vertices, edges and polygonal faces (usually triangles or quadrilaterals) that together define the surface of a 3D object. Each edge is shared by at most two faces, and it is the most common representation in graphics because polygons are easy to transform, shade and render in hardware.

Types of polygon mesh representations

  1. Explicit representation: each polygon is stored as a list of its vertex coordinates, P=((x1,y1,z1),…,(xn,yn,zn))P=((x_1,y_1,z_1),\dots,(x_n,y_n,z_n)). It is simple, but shared vertices are repeated, wasting memory and risking cracks.
  2. Pointers to a vertex list: vertices are stored once in a vertex list, and each polygon stores indices into it. Shared vertices are not duplicated, but shared edges are still drawn twice.
  3. Pointers to an edge list: each polygon points to edges in an edge list; each edge points to its two vertices (and the polygons that share it). Edges are drawn only once, and adjacency information is available.

Also, by structure: triangle meshes, quad meshes, triangle strips/fans, and general polygon meshes.

Cube of side 2 with one vertex at the origin

Vertices:

V(x, y, z)
V1(0,0,0)
V2(2,0,0)
V3(2,2,0)
V4(0,2,0)
V5(0,0,2)
V6(2,0,2)
V7(2,2,2)
V8(0,2,2)

Edge table (12 edges):

EdgeVerticesEdgeVertices
E1V1, V2E7V7, V8
E2V2, V3E8V8, V5
E3V3, V4E9V1, V5
E4V4, V1E10V2, V6
E5V5, V6E11V3, V7
E6V6, V7E12V4, V8

Polygon (surface) table (6 faces):

FaceDescriptionEdges
F1Bottom (z=0z=0)E1, E2, E3, E4
F2Top (z=2z=2)E5, E6, E7, E8
F3Front (y=0y=0)E1, E10, E5, E9
F4Back (y=2y=2)E3, E11, E7, E12
F5Left (x=0x=0)E4, E12, E8, E9
F6Right (x=2x=2)E2, E11, E6, E10

Each edge appears in exactly two faces, as required for a closed mesh (Euler: V−E+F=8−12+6=2V-E+F=8-12+6=2).

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2082 · 10 marks

Explain the Painter’s algorithm for visible surface detection. Explain the BSP tree method used for visible surface determination. How does it divide the space and organize objects in a scene?

Answer

Painter's algorithm

The painter's algorithm (depth-sort algorithm) works like a painter who paints distant parts of a scene first and nearer ones over them. It is an object-space/image-space method.

Steps:

  1. Sort all polygons by decreasing depth, using the farthest zz value (or the mean zz) of each polygon.
  2. Resolve ambiguities where the zz ranges of two polygons overlap. For polygons PP (farthest) and QQ, check in order whether (i) their xx extents do not overlap, (ii) their yy extents do not overlap, (iii) PP is wholly behind QQ's plane, (iv) QQ is wholly in front of PP's plane, (v) their projections do not overlap. If any test passes, PP can be drawn before QQ; otherwise swap them, and if there is still a problem (cyclic overlap or intersecting polygons) split a polygon.
  3. Scan convert the polygons in order from back to front, so nearer polygons overwrite farther ones.

Advantages: simple, handles transparency easily. Disadvantages: sorting cost, cyclic overlap and intersecting surfaces need splitting, and overdraw wastes time.

BSP tree method

Binary Space Partitioning builds a tree that subdivides the scene using planes, and the tree is traversed in a view-dependent order to give a back-to-front list without sorting each frame.

How it divides space:

  1. Select a polygon from the scene; its plane Ax+By+Cz+D=0Ax+By+Cz+D=0 divides space into two half-spaces: front (where Ax+By+Cz+D>0Ax+By+Cz+D>0) and back (<0<0).
  2. Put every other polygon in the front list or back list depending on its side. Polygons that cross the plane are split along the plane into two parts, one on each side. Polygons lying in the plane stay with the root node.
  3. Recursively repeat on each list until each contains at most one polygon.

How objects are organised: each internal node stores a polygon (the partitioning plane) and has a front child (polygons in front) and a back child (polygons behind); the leaves are empty or single polygons.

Display: traverse the tree with respect to the viewpoint EE. At each node, evaluate the plane equation at EE: if EE is in front, display back subtree, the node polygon, then the front subtree; if EE is behind, display the front subtree, the node, and the back subtree. The result is back-to-front drawing (painter style), with correct occlusion.

The tree is built once for static geometry, so each new view only needs a linear traversal. The drawback is that the build is expensive, splitting increases the polygon count, and it is not suited to moving objects.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2082 · 5 marks

Explain the need for machine-independent graphics languages. How do such standards benefit application developers?

Answer

Need for machine-independent graphics languages

Early graphics programs were written for specific display devices with their own commands, so they could not run on other hardware. A machine-independent graphics language or standard (GKS, PHIGS, OpenGL, DirectX, Vulkan) defines a common set of functions that work regardless of the underlying hardware, operating system or manufacturer. This is needed because:

  • Display devices (CRT, LCD, plotters, printers) and graphics cards differ greatly in resolution, colour and commands.
  • Rewriting the program for every device is costly and error-prone.
  • Software needs to be portable between systems and must survive hardware upgrades.
  • A shared interface lets hardware vendors write drivers, while application developers write programs only once.

Benefits to application developers

  1. Portability: the same source code runs on many platforms and devices with little or no change.
  2. Reduced development time and cost: developers use ready-made functions for primitives, transformations, viewing, lighting and textures instead of writing low-level device code.
  3. Device independence: the program describes the picture in abstract coordinates; the driver maps it to the actual device.
  4. Standardisation and learning: a well-defined API with documentation makes it easier to learn and to share code and skills.
  5. Easier maintenance and upgrade: new hardware can be supported by new drivers without changing the application.
  6. Hardware acceleration: standard calls are mapped to the graphics card features, giving good performance.
  7. Interoperability and reuse: libraries and tools built on the standard can be reused.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2082 · 5 marks

Define 2D rotation in computer graphics. Derive the rotation matrix and calculate the new coordinates of a point (2, 3) after a rotation of 45° about the origin.

Answer

2D rotation

Rotation turns an object about a pivot point (here the origin) through an angle θ\theta along a circular path in the xyxy plane; positive θ\theta is anticlockwise.

Derivation

Let a point P(x,y)P(x,y) be at distance rr from the origin at angle ϕ\phi from the xx-axis:

x=rcos⁡ϕ,y=rsin⁡ϕx=r\cos\phi,\qquad y=r\sin\phi

After rotation by θ\theta the point P′(x′,y′)P'(x',y') is at angle ϕ+θ\phi+\theta:

x′=rcos⁡(ϕ+θ)=rcos⁡ϕcos⁡θ−rsin⁡ϕsin⁡θx'=r\cos(\phi+\theta)=r\cos\phi\cos\theta-r\sin\phi\sin\theta y′=rsin⁡(ϕ+θ)=rcos⁡ϕsin⁡θ+rsin⁡ϕcos⁡θy'=r\sin(\phi+\theta)=r\cos\phi\sin\theta+r\sin\phi\cos\theta

Substituting xx and yy:

x′=xcos⁡θ−ysin⁡θ,y′=xsin⁡θ+ycos⁡θx'=x\cos\theta-y\sin\theta,\qquad y'=x\sin\theta+y\cos\theta

In matrix form (homogeneous):

[x′y′1]=[cos⁡θ−sin⁡θ0sin⁡θcos⁡θ0001][xy1]\begin{bmatrix}x'\\y'\\1\end{bmatrix}=\begin{bmatrix}\cos\theta&-\sin\theta&0\\\sin\theta&\cos\theta&0\\0&0&1\end{bmatrix}\begin{bmatrix}x\\y\\1\end{bmatrix}

Rotating (2,3)(2,3) by 45∘45^\circ

cos⁡45∘=sin⁡45∘=0.7071\cos45^\circ=\sin45^\circ=0.7071.

x′=2(0.7071)−3(0.7071)=−0.7071x'=2(0.7071)-3(0.7071)=-0.7071 y′=2(0.7071)+3(0.7071)=3.5355y'=2(0.7071)+3(0.7071)=3.5355

The new point is P′(−0.707,  3.536)P'(-0.707,\;3.536). Check: the distance from the origin is 0.5+12.5=13=22+32\sqrt{0.5+12.5}=\sqrt{13}=\sqrt{2^2+3^2}, unchanged.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2082 · 5 marks

How is the transformation matrix computed when switching from one coordinate system to another? Illustrate with an example

Answer

Transformation between coordinate systems

To express a point given in one Cartesian system xyxy in another system x′y′x'y', we move and rotate the second system until it coincides with the first. Suppose the origin of x′y′x'y' is at (x0,y0)(x_0,y_0) in the xyxy system, and its x′x' axis is rotated by an angle θ\theta from the xx axis.

Steps:

  1. Translate so the origin of x′y′x'y' moves to the origin of xyxy: T(−x0,−y0)T(-x_0,-y_0).
  2. Rotate by −θ-\theta so the x′x' axis coincides with the xx axis: R(−θ)R(-\theta).

Mxy→x′y′=R(−θ) T(−x0,−y0)=[cos⁡θsin⁡θ0−sin⁡θcos⁡θ0001][10−x001−y0001]M_{xy\to x'y'}=R(-\theta)\,T(-x_0,-y_0)=\begin{bmatrix}\cos\theta&\sin\theta&0\\-\sin\theta&\cos\theta&0\\0&0&1\end{bmatrix}\begin{bmatrix}1&0&-x_0\\0&1&-y_0\\0&0&1\end{bmatrix}

An equivalent description: the rows of the rotation part are the unit vectors of the new axes expressed in the old system. The inverse M−1=T(x0,y0)R(θ)M^{-1}=T(x_0,y_0)R(\theta) converts back. In 3D the same idea applies, using the unit vectors u,v,n\mathbf u,\mathbf v,\mathbf n of the new axes as rows of the rotation matrix.

Example

The system x′y′x'y' has its origin at (2,1)(2,1) and is rotated by θ=90∘\theta=90^\circ. Find the coordinates of P(4,3)P(4,3) in x′y′x'y'.

M=[010−100001][10−201−1001]=[01−1−102001]M=\begin{bmatrix}0&1&0\\-1&0&0\\0&0&1\end{bmatrix}\begin{bmatrix}1&0&-2\\0&1&-1\\0&0&1\end{bmatrix}=\begin{bmatrix}0&1&-1\\-1&0&2\\0&0&1\end{bmatrix}

[x′y′1]=[01−1−102001][431]=[2−21]\begin{bmatrix}x'\\y'\\1\end{bmatrix}=\begin{bmatrix}0&1&-1\\-1&0&2\\0&0&1\end{bmatrix}\begin{bmatrix}4\\3\\1\end{bmatrix}=\begin{bmatrix}2\\-2\\1\end{bmatrix}

So PP is (2,−2)(2,-2) in the new system. Check: the vector from the new origin is (2,2)(2,2); the x′x' axis points along (0,1)(0,1), giving x′=2x'=2, and the y′y' axis along (−1,0)(-1,0), giving y′=−2y'=-2.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2082 · 5 marks

Explain the 3D viewing pipeline in computer graphics. Explain about how a 3D world coordinate system is transformed to a 2D screen.

Answer

3D viewing pipeline

The 3D viewing pipeline is the sequence of transformations and operations that converts an object defined in 3D world coordinates into a 2D image on the display device.

Modelling coords -> World coords -> Viewing (camera) coords
   -> Projection coords -> Normalised coords -> Device (screen) coords
  1. Modelling transformation: each object, defined in its own local coordinates, is placed in the scene (world coordinates) by scaling, rotation and translation.
  2. Viewing transformation: the world is transformed to the camera system. The viewer is placed at the origin looking down an axis, by translating the view reference point to the origin and rotating so that the view-plane normal n\mathbf n, view-up vector v\mathbf v and u=v×n\mathbf u=\mathbf v\times\mathbf n coincide with the axes.
  3. Projection transformation: 3D camera coordinates are projected onto the view plane, by parallel projection (xp=x, yp=yx_p=x,\,y_p=y) or perspective projection (xp=xd/z, yp=yd/zx_p=xd/z,\,y_p=yd/z). Objects are clipped against the view volume (frustum or box), here or in normalised coordinates.
  4. Normalisation and clipping: the view volume is mapped to a canonical volume (e.g. a unit cube); clipping and visible-surface detection are applied, and hidden surfaces removed.
  5. Viewport (workstation) transformation: the projected window is mapped to the viewport in device coordinates by scaling and translating:

xv=xvmin⁡+(xw−xwmin⁡) sx,sx=xvmax⁡−xvmin⁡xwmax⁡−xwmin⁡x_v=x_{v\min}+(x_w-x_{w\min})\,s_x,\qquad s_x=\frac{x_{v\max}-x_{v\min}}{x_{w\max}-x_{w\min}}

and similarly for yy.

  1. Rasterisation: the 2D primitives are scan converted into pixels, with shading and the depth buffer.

From 3D world to 2D screen: a world point (x,y,z)(x,y,z) is multiplied by the viewing matrix to get camera coordinates, then by the projection matrix (with a divide by ww for perspective) to get a 2D point on the view plane, and finally by the window-to-viewport mapping to get pixel coordinates (xs,ys)(x_s,y_s).

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2082 · 5 marks

For control points P0(0,0), P1(1,2), P2(3,3), and P3(4,0), calculate the Bezier curve point at u = 0.5. Also plot the rough curve shape.

Answer

The cubic Bezier curve is

P(u)=(1−u)3P0+3u(1−u)2P1+3u2(1−u)P2+u3P3\mathbf P(u)=(1-u)^3\mathbf P_0+3u(1-u)^2\mathbf P_1+3u^2(1-u)\mathbf P_2+u^3\mathbf P_3

At u=0.5u=0.5 the blending weights are:

(1−u)3=0.125,3u(1−u)2=0.375,3u2(1−u)=0.375,u3=0.125(1-u)^3=0.125,\quad 3u(1-u)^2=0.375,\quad 3u^2(1-u)=0.375,\quad u^3=0.125

With P0(0,0)\mathbf P_0(0,0), P1(1,2)\mathbf P_1(1,2), P2(3,3)\mathbf P_2(3,3), P3(4,0)\mathbf P_3(4,0):

x=0.125(0)+0.375(1)+0.375(3)+0.125(4)=0.375+1.125+0.5=2.0x=0.125(0)+0.375(1)+0.375(3)+0.125(4)=0.375+1.125+0.5=2.0 y=0.125(0)+0.375(2)+0.375(3)+0.125(0)=0.75+1.125=1.875y=0.125(0)+0.375(2)+0.375(3)+0.125(0)=0.75+1.125=1.875

Point at u=0.5u=0.5: (2,  1.875)(2,\;1.875).

Check by de Casteljau: midpoints of the control polygon give (0.5,1)(0.5,1), (2,2.5)(2,2.5), (3.5,1.5)(3.5,1.5); then (1.25,1.75)(1.25,1.75), (2.75,2)(2.75,2); then (2,1.875)(2,1.875). This agrees.

Rough shape: the curve starts at (0,0)(0,0) going toward P1P_1 (steeply upward at slope 2), rises in an arch passing through about (2,1.875)(2,1.875) at the middle, and curves downward to finish at (4,0)(4,0) with a tangent along P2P3P_2P_3 (slope −3-3). Other points: u=0.25→(0.94,1.31)u=0.25\to(0.94,1.31) and u=0.75→(3.06,1.69)u=0.75\to(3.06,1.69) approximately. It is symmetric-looking, a smooth hump below the control polygon's peak at height 3, and it lies inside the convex hull of the four points.

 y
 3 |        P2
 2 |    P1  .  ___
   |      .--'   '--.
 1 |    ./            '.
   |  ./                \
 0 +-P0------------------P3-- x
   0   1    2    3    4

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2082 · 5 marks

What is spatial-partitioning representation? Explain how it differs from boundary representation in terms of geometry storage and processing.

Answer

Spatial-partitioning representation

In spatial-partitioning (space-subdivision) representation a solid is described by dividing the space it occupies into small non-overlapping solid units and recording which units are inside the object. Common forms:

  • Voxel (cell) enumeration: space is divided into a regular grid of cubes (voxels); each is marked occupied or empty.
  • Octree: the cube enclosing the object is recursively divided into 8 octants. Each node is labelled full, empty or mixed, and only mixed nodes are divided further.
  • BSP tree: space is recursively split by planes into two half-spaces.

Difference from boundary representation (B-rep)

B-rep describes an object by its bounding surfaces: faces, edges and vertices (polygon meshes, spline patches), with the interior being implied.

PointSpatial partitioningBoundary representation
Geometry storedThe volume occupied: cells/voxels or tree nodesOnly the surface: vertices, edges, faces
StorageCan be large for fine resolution (voxel grids grow as n3n^3); octrees reduce itCompact for simple shapes
AccuracyApproximate, determined by cell resolutionExact (for polygons or curved patches)
Interior informationExplicit; easy to test whether a point is insideImplicit; needs ray casting or normal tests
ProcessingBoolean operations, volume, mass and collision tests are simple (set operations on cells)Rendering, transformation and display are fast and direct; Boolean operations are complex
Typical usesMedical imaging (CT, MRI), scientific data, collision detection, 3D modelling of solidsCAD, games, animation, general rendering

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2082 · 5 marks

What is constant intensity shading? Compare Phong shading and fast Phong shading.

Answer

Constant intensity shading

Constant intensity (flat) shading applies one illumination calculation per polygon, using a single normal for the whole polygon, and fills the entire polygon with that intensity.

  • It is fast and simple.
  • It is accurate only when the surface is truly flat, the light and the viewer are far away so that N⋅L\mathbf N\cdot\mathbf L and R⋅V\mathbf R\cdot\mathbf V are almost constant over the polygon.
  • On curved surfaces approximated by polygons, the individual facets are visible, and intensity discontinuities appear at the edges (Mach band effect).

Phong shading vs fast Phong shading

PointPhong shadingFast Phong shading
MethodInterpolates the surface normal across the polygon (from vertex normals) and evaluates the full illumination model at each pixelApproximates the intensity with a Taylor-series (quadratic) expansion in x,yx,y and updates it incrementally along the scan line
Per-pixel workNormalise the normal, compute N⋅L\mathbf N\cdot\mathbf L, R⋅V\mathbf R\cdot\mathbf V, raise to power nsn_sA few additions using forward differences
SpeedSlow (about 6 to 8 times Gouraud)Considerably faster, close to Gouraud shading
AccuracyMost accurate; good specular highlightsSlightly less accurate, particularly for large polygons or sharp highlights
NormalsInterpolated and re-normalised per pixelInterpolation of normal is incorporated into the polynomial coefficients; no per-pixel normalisation
UseWhen high quality is neededWhen speed matters and an approximate result is acceptable

Both give smooth shading and highlights inside polygons, unlike constant shading.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2082 · 5 marks

Discuss the use of virtual reality in education. How does VR enhance student engagement and learning outcomes?

Answer

Use of virtual reality in education

Virtual reality (VR) places learners inside a computer-generated 3D environment, using a head-mounted display, controllers and motion tracking. It is used in education for:

  • Science and medicine: virtual dissection and anatomy, surgical simulation, chemistry and physics labs where experiments are dangerous or costly.
  • Engineering and technical training: operating machinery, flight and driving simulators, circuit and construction practice.
  • History and geography: virtual field trips to ancient sites, other countries, space or the human cell.
  • Language and soft skills: immersive conversation practice, public speaking, and therapy and special-needs education.
  • Remote and distance learning: shared virtual classrooms for students who cannot attend physically.

How VR enhances engagement and learning outcomes

  1. Immersion and presence: the learner experiences the content rather than just reading about it, which holds attention and reduces distraction.
  2. Learning by doing: hands-on practice in a safe place; mistakes cost nothing and can be repeated.
  3. Visualising abstract concepts: molecules, geometry, planetary motion and the like can be seen in 3D and manipulated, which aids understanding.
  4. Better retention: experiential, multi-sensory learning improves memory and recall compared with passive lectures.
  5. Motivation and interactivity: game-like activities and instant feedback raise interest.
  6. Accessibility and cost: expensive or unreachable facilities (labs, field sites) become available to many students.

Limitations: cost of equipment, motion sickness, need for content creation and teacher training, and limited access in low-resource schools.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2082 · 5 marks

Write short notes on: a. Lighting in OpenGL b. Orthographic projection

Answer

(a) Lighting in OpenGL

OpenGL uses a local illumination model: the colour of each vertex (or fragment) is computed from the light sources, the material of the surface and the surface normal. Lighting is switched on with glEnable(GL_LIGHTING) and each light with glEnable(GL_LIGHT0).

The final colour is the sum of four components:

  • Ambient light: uniform background light that reaches every surface equally, so no surface is completely black.
  • Diffuse light: scattered equally in all directions from a rough surface. Its intensity depends on the angle between the surface normal N\mathbf{N} and the light direction L\mathbf{L}: Id=kd Il max⁡(N⋅L, 0)I_d = k_d\, I_l \,\max(\mathbf{N}\cdot\mathbf{L},\,0)
  • Specular light: the bright highlight on shiny surfaces, depending on the viewer direction V\mathbf{V} and the reflection vector R\mathbf{R}: Is=ks Il max⁡(R⋅V, 0)nI_s = k_s\, I_l \,\max(\mathbf{R}\cdot\mathbf{V},\,0)^{n} where nn is the shininess exponent.
  • Emission: light given out by the object itself.

Light properties are set with glLightfv(GL_LIGHT0, GL_AMBIENT / GL_DIFFUSE / GL_SPECULAR / GL_POSITION, values). Material properties are set with glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, ...) and glMaterialf(GL_FRONT, GL_SHININESS, ...). Correct normals must be supplied with glNormal3f(). Shading is chosen by glShadeModel(GL_FLAT) or GL_SMOOTH (Gouraud shading). Lights can be directional (position with w=0w=0), point lights (w=1w=1) or spotlights.

(b) Orthographic projection

Orthographic (parallel) projection projects points onto the view plane along lines parallel to the viewing direction, which is perpendicular to the plane. Projectors never converge, so there is no perspective foreshortening: size does not change with distance, and parallel lines stay parallel and true lengths and angles are preserved on faces parallel to the plane. It is used in engineering and architectural drawings (plan, front and side views).

For projection onto the plane z=0z=0:

xp=x,yp=y,zp=0,M=[1000010000000001]x_p = x,\quad y_p = y,\quad z_p = 0,\qquad M=\begin{bmatrix}1&0&0&0\\0&1&0&0\\0&0&0&0\\0&0&0&1\end{bmatrix}

The view volume is a rectangular box. In OpenGL it is set with glOrtho(left, right, bottom, top, near, far) (or gluOrtho2D for 2D), which maps the box to the canonical cube [−1,1]3[-1,1]^3: [2r−l00−r+lr−l02t−b0−t+bt−b00−2f−n−f+nf−n0001]\begin{bmatrix}\frac{2}{r-l}&0&0&-\frac{r+l}{r-l}\\0&\frac{2}{t-b}&0&-\frac{t+b}{t-b}\\0&0&\frac{-2}{f-n}&-\frac{f+n}{f-n}\\0&0&0&1\end{bmatrix}

Its drawback is that it looks less realistic than perspective projection because depth cues are lost.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

Questions from TU BSc CSIT 2075 Third Semester Numerical Method (TU IOST board exam, 2075), TU BSc CSIT 2077 Third Semester Numerical Method (TU IOST board exam, 2077), TU BSc CSIT 2078 Third Semester Numerical Method (TU IOST board exam, 2078), TU BSc CSIT 2079 Third Semester Numerical Method (TU IOST board exam, 2079), TU BSc CSIT 2080 Third Semester Numerical Method (TU IOST board exam, 2080), TU BSc CSIT 2081 Third Semester Numerical Method (TU IOST board exam, 2081), TU BSc CSIT 2075 Third Semester Computer Architecture (TU IOST board exam, 2075), TU BSc CSIT 2077 Third Semester Computer Architecture (TU IOST board exam, 2077), TU BSc CSIT 2078 Third Semester Computer Architecture (TU IOST board exam, 2078), TU BSc CSIT 2079 Third Semester Computer Architecture (TU IOST board exam, 2079), TU BSc CSIT 2080 Third Semester Computer Architecture (TU IOST board exam, 2080), TU BSc CSIT 2081 Third Semester Computer Architecture (TU IOST board exam, 2081), TU BSc CSIT 2075 Third Semester Computer Graphics (TU IOST board exam, 2075), TU BSc CSIT 2077 Third Semester Computer Graphics (TU IOST board exam, 2077), TU BSc CSIT 2078 Third Semester Computer Graphics (TU IOST board exam, 2078), TU BSc CSIT 2079 Third Semester Computer Graphics (TU IOST board exam, 2079), TU BSc CSIT 2080 Third Semester Computer Graphics (TU IOST board exam, 2080), TU BSc CSIT 2081 Third Semester Computer Graphics (TU IOST board exam, 2081), TU BSc CSIT 2082 Third Semester Computer Graphics (TU IOST board exam, 2082), TU BSc CSIT 2074 Third Semester Data Structures and Algorithms (TU IOST board exam, 2074), TU BSc CSIT 2075 Third Semester Data Structures and Algorithms (TU IOST board exam, 2075), TU BSc CSIT 2077 Third Semester Data Structures and Algorithms (TU IOST board exam, 2077), TU BSc CSIT 2078 Third Semester Data Structures and Algorithms (TU IOST board exam, 2078), TU BSc CSIT 2079 Third Semester Data Structures and Algorithms (TU IOST board exam, 2079), TU BSc CSIT 2080 Third Semester Data Structures and Algorithms (TU IOST board exam, 2080), TU BSc CSIT 2081 Third Semester Data Structures and Algorithms (TU IOST board exam, 2081), TU BSc CSIT 2075 Third Semester Statistics II (TU IOST board exam, 2075), TU BSc CSIT 2077 Third Semester Statistics II (TU IOST board exam, 2077), TU BSc CSIT 2078 Third Semester Statistics II (TU IOST board exam, 2078), TU BSc CSIT 2079 Third Semester Statistics II (TU IOST board exam, 2079), TU BSc CSIT 2080 Third Semester Statistics II (TU IOST board exam, 2080), TU BSc CSIT 2081 Third Semester Statistics II (TU IOST board exam, 2081) and TU BSc CSIT 2082 Third Semester Statistics II (TU IOST board exam, 2082). Answers are written for this site; check them against your class notes.