联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp

您当前位置:首页 >> C/C++编程C/C++编程

日期:2021-06-13 05:55

159.235 GRAPHICAL PROGRAMMING

SEMESTER TWO 2019

_________________________________________________________________________________________________________

Time Allowed: THREE (3) hours

This paper contains FIVE (5) questions.

Answer all questions in the Blue Answer Booklet provided.

For all questions, you may assume that all necessary files and code are included.

This exam contributes up to 60% to your final grade

Non programmable calculators only are permitted.

Students may NOT remove any part of this exam paper from the exam room.

The exam paper will be made available on the University Library website.

Total = 60 marks

1902/159.235 CP1

AKLI

Page 2 of 7

CoS

Question 1. [10 marks total]

Consider the following screenshot for a Java calculator application. The “File” menu contains just a

single “Quit” menu item for exiting the application.

a) What GUI containers and widget components are involved here, and how are they related?

For your answer, you may provide appropriate Java code that shows how the components

are added, and/or draw a diagram showing how they are related. Any code you show does

not have to be syntactically perfect but it should show the key features being used.

[4 marks]

b) Describe what you have to do in order to get the application to write into the display in

response to pushing one of the buttons.

[3 marks]

c) On pushing the “=” button, the application will evaluate the expression and write the

answer in the display. Describe what you would need to do to implement this feature.

[2 marks]

d) Java Swing is one GUI library. Name one other.

[1 mark]

1902/159.235 CP1

AKLI

Page 3 of 7

CoS

Question 2. [10 marks total]

a) Sketch the rendered output of the following Java code. Assume a 200 by 200 pixel display

panel

protected void paintComponent( Graphics g ){

System.out.println("repainting");

Graphics2D g2 = (Graphics2D) g;

g2.translate(100.0, 100.0);

g2.scale(1, -1);

g2.fillRect(-50, 40, 100, 10);

g2.rotate(Math.PI / 2.0);

g2.fillRect(-50, 40, 100, 10);

}

[4 marks]

b) A primitive computer display has a spatial resolution of 1024 by 1024 pixels and can only

display 1 bit per pixel (i.e. pixel elements are either lit or unlit). How much memory is

required by the corresponding framebuffer? How much framebuffer memory would be

required by a modern 24 bit colour display with the same spatial resolution? Give your

answers in bytes

[2 marks]

c) A monochromatic imaging camera, on a deep space probe, with 2000X1000 pixels encodes

its data as 32 bits per pixel. It is desired to reduce the intensity depth to 8 bits per pixel so

the data can be sent via a low gain antenna.

i. How many intensity levels per pixel will be possible in the compressed image?

ii. What are the image sizes, in bytes, before and after compression?

[2 marks]

d) Consider the following simple algorithm for quantization of intensity values, f, that are

normalized in the range 0-1.

f_quant = floor[7 * f + 0.7]

i. How many intensity levels are mapped in this relation?

ii. What is the quantization error for f=0.8?

[2 marks]

1902/159.235 CP1

AKLI

Page 4 of 7

CoS

Question 3. [10 marks total]

For this question, assume a Point class and a Matrix class have been defined to allow working

with homogeneous coordinates.

The Matrix class has a .times() method to allow multiplication with other Matrix and Point

instances:

Matrix times(Matrix m);

Point times(Point p);

This operation allows chaining, i.e. if A, B, C, and D are four Matrix instances and P1 and P2 are

two Point instances, then one can carry out multiplications as follows (for example):

D = A.times(B).times(C);

P2 = A.times(P1);

Furthermore, assume the following methods have been defined, which create new instances of

various transformation matrices:

// Translation by distances dx, dy, and dz along x, y, and z axes

static Matrix getTranslate(double dx, double dy, double dz);


// Rotate by given angle around x, y, and z-axes. The angle is

// given in degrees with conversion to radians handled internally

// by the methods.

static Matrix getRotationX(double ang);

static Matrix getRotationY(double ang);

static Matrix getRotationZ(double ang);


// Scaling by factors sx, sy, and sz along the x, y, and z-axes

static Matrix getScale(double sx, double sy, double sz);


// A one point perspective with the projection screen at located

// distance d along z-axis

static Matrix getPerspective(double d);


// Generate a view matrix for a camera placed at pCam and

// pointing to pTarget in the world scene. The view matrix

// converts from world to camera coordinates. The “up”

// direction is implicitly handled by the method.

static Matrix lookat(Point pCam, Point pTarget);

1902/159.235 CP1

AKLI

Page 5 of 7

CoS

Question 3. (continued)

a) Show how to use these methods to obtain a transformation matrix to allow the following

operations:

i. Move a point by a distance 11 along the x-axis, -2 along the y-axis, and 25 along the zaxis

ii. Rotate a point 42 degrees around the z-axis, and then displace it by the distances in (i).

iii. Rotate a point 10 degrees around the z-axis, then 20 degrees around the y-axis, then 30

degrees around the x-axis

iv. Carry out the reverse of the operation in (iii)

[4 marks]

b) A tetrahedron is modeled in local coordinates by the following array of vertices:

Point[] pV = { new Point(0, 0, 0, 1),

new Point(0, 0, 1, 1),

new Point(0, 1, 0, 1),

new Point(1, 0, 0, 1) };

We wish to place this model into the world scene by:

- stretching by factors 2, 3, and 4 in the x, y, and z-axes

- then rotating by angles 30, 10, and 70 degrees around the z, y, and x-axes (in that order)

- and finally placing the object so that the first vertex is at x=60, y=30, and z=10 in the world scene

Further, we wish to place a camera in the world scene at x=50, y=80, and z=200 with the camera

axis pointing to the origin in the world scene. The camera views this scene in 1 point perspective

with the projection plane at distance 2 along the camera z-axis.

Show how to use these methods to transform all vertices from local to camera coordinates.

[4 marks]

c) The following matrix operates on homogeneous coordinates and performs a projective

transformation in 3 dimensions onto a 2 dimensional plane.

Find the Cartesian coordinates of all the vanishing points making sure to identify each

vanishing point axis.

How many points of perspective are therefore featured in this transformation?

[2 marks]

1902/159.235 CP1

AKLI

Page 6 of 7

CoS

Question 4 [15 marks total]

a) Consider the following 2D image of various shapes that is to be sampled at the positions

given by the small filled circles and then displayed on a graphics device

Describe TWO effects of aliasing that would occur as a result of this low resolution. You may

include a diagram as appropriate.

[4 mark]

b) Post-filtering is one approach to anti-aliasing that is of particular interest to games

developers. Describe one possible post-processing method.

[3 marks]

c) The Painters Algorithm aims to solve the visible surface problem by rendering surfaces in

order of distance (depth) from the view point. Describe one situation where this will not

work.

[2 marks]

d) Consider the following plan of a set of walls that form part of a scene in a computer game.

i. Draw a binary space partitioning tree for this plan using wall C as the root facet

ii. Describe how one could render these surfaces by traversing this tree.

[6 marks]

1902/159.235 CP1

AKLI

Page 7 of 7

CoS

Question 5 [15 marks total]

Consider the following wireframe scene which has been mapped and projected onto a 2D

viewport, but without illumination and hidden surface removal. Note the mirror just behind the

teapot.

a) Describe a procedure that illuminates the desktop surfaces by treating those surfaces as

diffuse reflectors.

[5 marks]

b) Consider the chrome teapot as a near-perfect reflector placed near the mirror, which is also

a near-perfect reflector. Describe a possible global illumination procedure that can produce

a high quality rendering of the multiple reflections between the teapot and the mirror.

[5 marks]

c) Describe a procedure that uses texture mapping to produce a floor pattern from an input

texture image.

[5 marks]

+ + + + + + + +


版权所有:编程辅导网 2021 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。 站长地图

python代写
微信客服:codinghelp