Skip to main content

Chapter 6

Computer Graphics (old course)

TU BIM past exam questions

Past questions and answers

17 questions set from this chapter. Most repeated first.

  • 2016 AD Model · 1 mark

In which package of java classes that implement shape interface is defined?

Answer

The classes that implement the Shape interface (such as Line2D, Rectangle2D, Ellipse2D, Arc2D) are defined in the package java.awt.geom. The Shape interface itself is in java.awt.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2016 AD Model · 1 mark

Why normalized space is used while mapping window to device co-ordinate system?

Answer

A normalized device coordinate (NDC) space, typically [0,1]×[0,1][0,1]\times[0,1], is used as an intermediate step so that the window-to-viewport mapping becomes device independent. The same picture is first mapped to the normalized space and then to the specific device coordinates, so the application does not depend on the resolution or size of each device, and only one mapping per device is needed.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2016 AD Model · 1 mark

Write the 3D scaling about arbitrary point in homogenous matrix form.

Answer

Scaling by sx,sy,szs_x, s_y, s_z about an arbitrary point (xf,yf,zf)(x_f, y_f, z_f) is: translate the point to the origin, scale, then translate back.

M=T(xf,yf,zf)⋅S(sx,sy,sz)⋅T(−xf,−yf,−zf)M = T(x_f,y_f,z_f)\cdot S(s_x,s_y,s_z)\cdot T(-x_f,-y_f,-z_f)

M=[sx00xf(1−sx)0sy0yf(1−sy)00szzf(1−sz)0001]M=\begin{bmatrix} s_x & 0 & 0 & x_f(1-s_x)\\ 0 & s_y & 0 & y_f(1-s_y)\\ 0 & 0 & s_z & z_f(1-s_z)\\ 0&0&0&1\end{bmatrix}

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2016 AD Model · 1 mark

Write a piece of code in Java to specify thickness of a line equal to 2.

Answer

Graphics2D g2 = (Graphics2D) g;
g2.setStroke(new BasicStroke(2));   // line thickness = 2
g2.drawLine(50, 50, 200, 100);

BasicStroke(2) sets the line width to 2 pixels, and it is placed in the paint/paintComponent method.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2016 AD Model · 1 mark

How machine independent graphical languages help programmers?

Answer

A machine-independent graphical language (such as OpenGL, GKS or PHIGS) provides a standard set of commands for drawing, independent of the hardware. It helps programmers because:

  • the same program runs on different devices and platforms without rewriting (portability);
  • they need not know the details of the display hardware or drivers;
  • development is faster, with a simpler and higher-level programming interface;
  • programs are easier to maintain and to upgrade to new hardware.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2016 AD Model · 1 mark

Write the relationship between simulation and virtual reality.

Answer

Simulation is the modelling of a real or imagined system's behaviour over time on a computer, and virtual reality (VR) is an immersive, interactive 3D environment. VR is built on simulation: the simulated model supplies the behaviour, physics and responses of the virtual world, and VR provides the immersive interface (head-mounted display, sensors) through which the user experiences and interacts with it in real time. Examples are flight simulators and surgery training.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2016 AD Model · 1 mark

Define intensity attenuation.

Answer

Intensity attenuation is the decrease in the intensity of light as it travels from the light source to a surface. For a point source it is commonly modelled as f(d)=1a0+a1d+a2d2f(d)=\dfrac{1}{a_0+a_1 d+a_2 d^2}, where dd is the distance from the source, so the farther an object is from the source, the dimmer it appears. It gives depth cues to the rendered scene.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2016 AD Model · 1 mark

Calculate the size of video of 15 fps if the video run for 4 minutes and if one frame is represented by 64 bit.

Answer

Number of frames:

15 fps×4×60 s=3600 frames15\ \text{fps}\times 4\times 60\ \text{s} = 3600\ \text{frames}

Size:

3600×64=230400 bits=28800 bytes≈28.1 KB3600\times 64 = 230400\ \text{bits} = 28800\ \text{bytes} \approx 28.1\ \text{KB}

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2016 AD Model · 1 mark

Make distinction between specular and diffuse reflection.

Answer

BasisSpecular reflectionDiffuse reflection
SurfaceSmooth, shinyRough, dull
ReflectionLight reflected mainly in one direction, where angle of incidence equals angle of reflectionLight scattered equally in all directions
Viewer dependenceDepends on the viewing positionIndependent of the viewing position
AppearanceBright highlightsUniform, matte colour
ModelPhong: ks(R⋅V)nk_s (R\cdot V)^nLambert: kd(N⋅L)k_d (N\cdot L)

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2016 AD Model · 1 mark

In which condition A buffer is used rather than Z buffer?

Answer

The A-buffer (accumulation buffer, an extension of the Z-buffer) is used when transparent or translucent surfaces, or anti-aliasing of edges, must be handled. The Z-buffer stores only one depth and colour per pixel, so it handles only opaque surfaces, while the A-buffer keeps a linked list of surface data for each pixel and can combine the colours of several overlapping surfaces.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2016 AD Model · 4 marks

Write a program in Java to draw a circle with radius 8 and center (4, 2) using midpoint circle algorithm.

Answer

Midpoint circle algorithm (radius r=8r=8, centre (xc,yc)=(4,2)(x_c,y_c)=(4,2))

Start at (0,r)=(0,8)(0,r)=(0,8) with decision parameter p0=1−r=−7p_0 = 1 - r = -7. For each step xk+1=xk+1x_{k+1}=x_k+1 and:

  • if pk<0p_k<0: next point (xk+1, yk)(x_k+1,\,y_k) and 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) 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. The remaining octants come from symmetry: each computed (x,y)(x,y) gives (±x,±y)(\pm x,\pm y) and (±y,±x)(\pm y,\pm x), which are then shifted by (4,2)(4,2).

kpkp_k(x,y)(x,y)plotted (x+4,y+2)(x+4,y+2)
0-7(0,8)(4,10)
1-4(1,8)(5,10)
21(2,8)(6,10)
3-6(3,7)(7,9)
43(4,7)(8,9)
52(5,6)(9,8)

Java program

import javax.swing.*;
import java.awt.*;

public class MidpointCircle extends JPanel {
    int xc = 4, yc = 2, r = 8;
    int scale = 20;                       // magnify so pixels are visible

    void plot(Graphics g, int x, int y) {
        // origin shifted to the middle of the panel, y axis pointing up
        int px = 200 + x * scale, py = 200 - y * scale;
        g.fillRect(px, py, scale / 2, scale / 2);
    }

    void plot8(Graphics g, int x, int y) {
        plot(g, xc + x, yc + y); plot(g, xc - x, yc + y);
        plot(g, xc + x, yc - y); plot(g, xc - x, yc - y);
        plot(g, xc + y, yc + x); plot(g, xc - y, yc + x);
        plot(g, xc + y, yc - x); plot(g, xc - y, yc - x);
    }

    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        g.setColor(Color.BLUE);
        int x = 0, y = r, p = 1 - r;
        plot8(g, x, y);
        while (x < y) {
            x++;
            if (p < 0) {
                p += 2 * x + 1;
            } else {
                y--;
                p += 2 * x + 1 - 2 * y;
            }
            plot8(g, x, y);
        }
    }

    public static void main(String[] args) {
        JFrame f = new JFrame("Midpoint Circle");
        f.add(new MidpointCircle());
        f.setSize(420, 440);
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.setVisible(true);
    }
}

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2016 AD Model · 4 marks

Reflect rectangle PQRS, P(1,2), Q(1,6), R(9,6) and S(9,2) on y=5 axis, then scale about (2,3) with scale factor (4,2) and finally rotate with rotation angle +45o about origin. Use homogenous coordinate system to calculate transformed rectangle coordinates.

Answer

Using homogeneous coordinates, the combined matrix is M=R⋅S(2,3)⋅FM = R\cdot S_{(2,3)}\cdot F (applied right to left).

(a) Reflection about y=5y=5. Translate down by 5, reflect about the x-axis, translate back:

F=T(0,5) Refx T(0,−5)=[1000−110001]F = T(0,5)\,\text{Ref}_x\,T(0,-5)=\begin{bmatrix}1&0&0\\0&-1&10\\0&0&1\end{bmatrix}

so (x,y)→(x, 10−y)(x,y)\to(x,\,10-y):

P(1,2)→(1,8)P(1,2)\to(1,8), Q(1,6)→(1,4)Q(1,6)\to(1,4), R(9,6)→(9,4)R(9,6)\to(9,4), S(9,2)→(9,8)S(9,2)\to(9,8).

(b) Scaling by (sx,sy)=(4,2)(s_x,s_y)=(4,2) about (2,3)(2,3):

S=T(2,3) Scale(4,2) T(−2,−3)=[40−602−3001]S=T(2,3)\,\text{Scale}(4,2)\,T(-2,-3)=\begin{bmatrix}4&0&-6\\0&2&-3\\0&0&1\end{bmatrix}

i.e. x′=4x−6,  y′=2y−3x'=4x-6,\; y'=2y-3:

P→(−2,13)P\to(-2,13), Q→(−2,5)Q\to(-2,5), R→(30,5)R\to(30,5), S→(30,13)S\to(30,13).

(c) Rotation by +45∘+45^\circ about the origin:

R=[cos⁡45∘−sin⁡45∘0sin⁡45∘cos⁡45∘0001]=[0.7071−0.707100.70710.70710001]R=\begin{bmatrix}\cos45^\circ&-\sin45^\circ&0\\ \sin45^\circ&\cos45^\circ&0\\0&0&1\end{bmatrix}=\begin{bmatrix}0.7071&-0.7071&0\\0.7071&0.7071&0\\0&0&1\end{bmatrix}

with x′′=0.7071(x′−y′)x''=0.7071(x'-y') and y′′=0.7071(x′+y′)y''=0.7071(x'+y').

  • P′(−2,13)P'(-2,13): x′′=0.7071(−15)=−10.61x''=0.7071(-15)=-10.61, y′′=0.7071(11)=7.78y''=0.7071(11)=7.78
  • Q′(−2,5)Q'(-2,5): x′′=0.7071(−7)=−4.95x''=0.7071(-7)=-4.95, y′′=0.7071(3)=2.12y''=0.7071(3)=2.12
  • R′(30,5)R'(30,5): x′′=0.7071(25)=17.68x''=0.7071(25)=17.68, y′′=0.7071(35)=24.75y''=0.7071(35)=24.75
  • S′(30,13)S'(30,13): x′′=0.7071(17)=12.02x''=0.7071(17)=12.02, y′′=0.7071(43)=30.41y''=0.7071(43)=30.41

Combined matrix

M=R S F=[2.8281.414−16.2632.828−1.4147.778001]M=R\,S\,F=\begin{bmatrix}2.828&1.414&-16.263\\2.828&-1.414&7.778\\0&0&1\end{bmatrix}

Transformed rectangle: P′′(−10.61, 7.78)P''(-10.61,\,7.78), Q′′(−4.95, 2.12)Q''(-4.95,\,2.12), R′′(17.68, 24.75)R''(17.68,\,24.75), S′′(12.02, 30.41)S''(12.02,\,30.41).

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2016 AD Model · 4 marks

Derive parallel and perspective projection matrix.

Answer

Projection maps 3D points onto a 2D view plane.

Parallel (orthographic) projection

Projectors are parallel to each other. For projection onto the plane z=0z=0 along the z-axis, a point (x,y,z)(x,y,z) goes to (xp,yp)=(x,y)(x_p,y_p)=(x,y), and the z coordinate is dropped:

[xpypzp1]=[1000010000000001][xyz1]\begin{bmatrix}x_p\\y_p\\z_p\\1\end{bmatrix}=\begin{bmatrix}1&0&0&0\\0&1&0&0\\0&0&0&0\\0&0&0&1\end{bmatrix}\begin{bmatrix}x\\y\\z\\1\end{bmatrix}

For an oblique parallel projection with projector direction making angle α\alpha and length factor LL with the plane, xp=x+zLcos⁡αx_p=x+zL\cos\alpha, yp=y+zLsin⁡αy_p=y+zL\sin\alpha:

Moblique=[10Lcos⁡α001Lsin⁡α000000001]M_{oblique}=\begin{bmatrix}1&0&L\cos\alpha&0\\0&1&L\sin\alpha&0\\0&0&0&0\\0&0&0&1\end{bmatrix}

Parallel projection preserves relative dimensions and parallel lines, so it is used in engineering drawings.

Perspective projection

Projectors meet at the centre of projection. Put the centre at the origin and the view plane at z=dz=d. By similar triangles:

xpd=xz,ypd=yz  ⇒  xp=x dz=xz/d,yp=y dz=yz/d\frac{x_p}{d}=\frac{x}{z},\qquad \frac{y_p}{d}=\frac{y}{z}\;\Rightarrow\; x_p=\frac{x\,d}{z}=\frac{x}{z/d},\quad y_p=\frac{y\,d}{z}=\frac{y}{z/d}

In homogeneous form with h=z/dh=z/d:

[xhyhzhh]=[100001000010001/d0][xyz1]\begin{bmatrix}x_h\\y_h\\z_h\\h\end{bmatrix}=\begin{bmatrix}1&0&0&0\\0&1&0&0\\0&0&1&0\\0&0&1/d&0\end{bmatrix}\begin{bmatrix}x\\y\\z\\1\end{bmatrix}

Dividing by hh gives (xp,yp,zp)=(xdz,ydz,d)(x_p,y_p,z_p)=\left(\dfrac{x d}{z},\dfrac{y d}{z},d\right).

Distant objects appear smaller (perspective foreshortening), so the result looks realistic but does not preserve sizes or parallelism.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2016 AD Model · 4 marks

Digitize the line with endpoints A(1, 9) and B(6, 1) using Bresenham's line drawing algorithm. Show all necessary steps.

Answer

Endpoints A(1,9)A(1,9) and B(6,1)B(6,1).

Δx=5\Delta x = 5, Δy=∣1−9∣=8\Delta y = |1-9| = 8. Since Δy>Δx\Delta y>\Delta x the line is steep (slope −8/5-8/5, negative), so we step in yy (decreasing by 1 each time) and decide whether to increment xx.

Initial decision parameter: p0=2Δx−Δy=10−8=2p_0 = 2\Delta x-\Delta y = 10-8 = 2.

Rule at each step (yy decreases by 1):

  • if pk<0p_k<0: xx unchanged, pk+1=pk+2Δx=pk+10p_{k+1}=p_k+2\Delta x = p_k+10
  • if pk≥0p_k\ge0: xx increases by 1, pk+1=pk+2Δx−2Δy=pk−6p_{k+1}=p_k+2\Delta x-2\Delta y=p_k-6
kpkp_knext pixel (x,y)(x,y)
start(1,9)
02(2,8)
1-4(2,7)
26(3,6)
30(4,5)
4-6(4,4)
54(5,3)
6-2(5,2)
78(6,1)

Digitized pixels: (1,9), (2,8), (2,7), (3,6), (4,5), (4,4), (5,3), (5,2), (6,1). The last pixel equals BB, confirming the result.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2016 AD Model · 4 marks

You are provided with the clipping rectangle with co-ordinates A(10, 10), B(10, 20), C(20, 10) and D(20, 20). Clip the given polygon PQRS with coordinates P(-10, -20), Q(10, 60), R(0, 10) and S(10, 10) using Sutherland - Hodgeman polygon clipping algorithm.

Answer

Clip window: xmin=10,  xmax=20,  ymin=10,  ymax=20x_{min}=10,\;x_{max}=20,\;y_{min}=10,\;y_{max}=20. Polygon vertices in order: P(−10,−20)P(-10,-20), Q(10,60)Q(10,60), R(0,10)R(0,10), S(10,10)S(10,10).

Sutherland-Hodgeman clips the polygon against each window edge in turn (left, right, bottom, top). A point is inside the left edge if x≥10x\ge10. For each polygon edge (V1→V2)(V_1\to V_2): in-in outputs V2V_2; in-out outputs the intersection; out-out outputs nothing; out-in outputs the intersection and V2V_2.

1. Left edge (x=10x=10)

  • P→QP\to Q (out to in): intersection with x=10x=10 is (10,60)(10,60); output (10,60)(10,60), Q(10,60)Q(10,60)
  • Q→RQ\to R (in to out): intersection (10,60)(10,60)
  • R→SR\to S (out to in): intersection (10,10)(10,10); output (10,10)(10,10), S(10,10)S(10,10)
  • S→PS\to P (in to out): intersection (10,10)(10,10)

After removing duplicates the list is (10,60),(10,10)(10,60),(10,10).

2. Right edge (x=20x=20): both points have x=10≤20x=10\le20, so both are inside and the list is unchanged.

3. Bottom edge (y=10y=10): y=60y=60 and y=10y=10 are both ≥10\ge10, so the list is unchanged.

4. Top edge (y=20y=20): (10,60)(10,60) is outside and (10,10)(10,10) is inside.

  • (10,60)→(10,10)(10,60)\to(10,10) (out to in): intersection (10,20)(10,20), then (10,10)(10,10)
  • (10,10)→(10,60)(10,10)\to(10,60) (in to out): intersection (10,20)(10,20)

Result: the polygon lies entirely on or outside the left boundary, so only a degenerate (zero-area) portion remains: the vertices (10,20)(10,20) and (10,10)(10,10), i.e. the line segment along the left window edge x=10x=10 from (10,10)(10,10) to (10,20)(10,20). No area of the polygon is visible inside the window.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2016 AD Model · 5 marks

What is visible surface should detection? Compare scan-line and painter's algorithm method.

Answer

Visible surface detection (hidden surface removal) is the process of deciding which surfaces or parts of surfaces of 3D objects are visible from a given viewpoint, so that only those are displayed and hidden ones are removed. It gives a realistic image in which nearer objects block farther ones. Methods are of two kinds: object-space (e.g. back-face detection, painter's algorithm) and image-space (e.g. z-buffer, scan-line).

Comparison of scan-line and painter's algorithm

BasisScan-line methodPainter's (depth-sort) algorithm
SpaceImage-spaceMainly object-space with image-space filling
WorkingProcesses the image one scan line at a time; for each line finds the polygons crossing it and the nearest one at each pixel spanSorts all polygons by depth (farthest first) and paints them in that order, nearer ones overwriting farther ones
Data structuresEdge table, polygon table, active edge listSorted list of polygons
Depth handlingDepth compared only where polygons overlap on a scan line, using coherenceDepth order decided by sorting; overlapping polygons may need splitting
ProblemsComplex bookkeeping of tablesCyclic overlap and intersecting polygons cannot be ordered without splitting; wasted painting of hidden areas
MemoryNeeds only one scan line of depth informationNeeds the whole polygon list but no depth buffer

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2016 AD Model · 5 marks

What do you mean by lighting model? Write the procedure to implement constant shading and also mention applications of this method.

Answer

A lighting (illumination) model is a mathematical model that calculates the intensity (colour) of light at a point on a surface from the light sources, surface properties (reflectivity, texture, orientation) and the viewer's position. Typical components are ambient light, diffuse reflection, Id=kdIlcos⁡θ=kdIl(N⋅L)I_d=k_dI_l\cos\theta=k_dI_l(\mathbf N\cdot\mathbf L), and specular reflection, Is=ksIl(R⋅V)nI_s=k_sI_l(\mathbf R\cdot\mathbf V)^{n} (Phong model). A surface-rendering (shading) method then applies the model to polygon surfaces.

Constant (flat) shading procedure

  1. Take each polygon of the object and find its surface normal N\mathbf N from the vertex coordinates (cross product of two edges).
  2. Evaluate the lighting model once for the polygon, using N\mathbf N, the light direction L\mathbf L and view direction V\mathbf V, to get one intensity value.
  3. Fill the entire polygon (all its pixels) with that single intensity.
  4. Repeat for every polygon.

It assumes the light source and viewer are far away, so N⋅L\mathbf N\cdot\mathbf L and V⋅R\mathbf V\cdot\mathbf R are constant over the polygon.

Applications

  • Fast preview and wireframe/solid rendering where speed matters more than quality
  • Rendering flat-faced objects such as buildings and boxes
  • Real-time systems and games with low-polygon models
  • Approximating curved surfaces coarsely (visible facets and Mach bands are the drawback)

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

Questions from TU BIM Fifth Semester IT 228 Artificial Intelligence Model Question 2024 (Faculty of Management model question 2024, BIM fifth semester, via EducateNepal), TU BIM Fifth Semester IT 242 Software Design and Development Model Question 2024 (Faculty of Management model question 2024, BIM fifth semester, via EducateNepal), TU BIM Fifth Semester IT 243 Programming with Python Model Question 2024 (Faculty of Management model question 2024, BIM fifth semester, via EducateNepal), TU BIM Fifth Semester IT 244 Information Security Model Question 2024 (Faculty of Management model question 2024, BIM fifth semester, via EducateNepal), TU BIM Fifth Semester MKT 201 Fundamentals of Marketing Model Question 2024 (Faculty of Management model question 2024, BIM fifth semester, via EducateNepal), TU BIM Fifth Semester IT 221 Computer Graphics 2016 (model question) (Faculty of Management model question 2016 (old course), via EducateNepal), TU BIM Fifth Semester IT 222 Java Programming II 2016 (model question) (Faculty of Management model question 2016 (old course), via EducateNepal) and TU BIM Fifth Semester IT 223 Advance Internetworking 2016 (model question) (Faculty of Management model question 2016 (old course), via EducateNepal). Answers are written for this site; check them against your class notes.