Module Contact: Dr R J Lapeer, CMP Copyright of the University of East Anglia Version 1

Similar documents
Module Contact: Dr Stephen Laycock, CMP Copyright of the University of East Anglia Version 1

Module Contact: Dr Rudy Lapeer, CMP Copyright of the University of East Anglia Version 1

Module Contact: Dr Rudy Lapeer (CMP) Copyright of the University of East Anglia Version 1

CS1354 GRAPHICS AND MULTIMEDIA DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING QUESTION BANK SUB CODE / SUBJECT: CS1354 GRAPHICS AND MULTIMEDIA.

EXAMINATIONS 2017 TRIMESTER 2

Chapter 8: Implementation- Clipping and Rasterization

CHETTINAD COLLEGE OF ENGINEERING & TECHNOLOGY CS2401 COMPUTER GRAPHICS QUESTION BANK

CMSC 435/634: Introduction to Graphics

Module Contact: Dr Stephen Laycock, CMP Copyright of the University of East Anglia Version 1

Institutionen för systemteknik

CS2401 COMPUTER GRAPHICS ANNA UNIV QUESTION BANK

The University of Calgary

SRM INSTITUTE OF SCIENCE AND TECHNOLOGY


1 Some easy lines (2, 17) (10, 17) (18, 2) (18, 14) (1, 5) (8, 12) Check with a ruler. Are your lines straight?

Module Contact: Dr Geoff McKeown, CMP Copyright of the University of East Anglia Version 1

In today s lecture we ll have a look at: A simple technique The mid-point circle algorithm

CSC 240 Computer Graphics. Fall 2015 Smith College

Roll No. : Invigilator's Signature :.. GRAPHICS AND MULTIMEDIA. Time Allotted : 3 Hours Full Marks : 70

Part 3: 2D Transformation

CMSC 435/634: Introduction to Graphics

Graphics System. Processor. Output Display. Input Devices. Frame Buffer. Memory. Array of pixels. Resolution: # of pixels Depth: # of bits/pixel

QUESTION 1 [10] 2 COS340-A October/November 2009

MODULE - 4. e-pg Pathshala

GeoGebra. 10 Lessons. maths.com. Gerrit Stols. For more info and downloads go to:

OXFORD ENGINEERING COLLEGE (NAAC Accredited with B Grade) DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING LIST OF QUESTIONS

CS-321 Thursday 12 September 2002 Quiz (3 pts.) What is the purpose of a control grid in a cathode ray tube (CRT)?

BHARATHIDASAN ENGINEERING COLLEGE,NATTRAMPALLI

UNIVERSITY OF NEBRASKA AT OMAHA Computer Science 4620/8626 Computer Graphics Spring 2014 Homework Set 1 Suggested Answers

End-Term Examination

Precept 2 Aleksey Boyko February 18, 2011

We can use square dot paper to draw each view (top, front, and sides) of the three dimensional objects:

(a) rotating 45 0 about the origin and then translating in the direction of vector I by 4 units and (b) translating and then rotation.

Spring 2009 Prof. Hyesoon Kim

OpenGL/GLUT Intro. Week 1, Fri Jan 12

CS602 MCQ,s for midterm paper with reference solved by Shahid

Andrew Yenalavitch Homework 1 CSE Fall 2014

Introduction to OpenGL: Part 2

MET71 COMPUTER AIDED DESIGN

EXAMINATIONS 2016 TRIMESTER 2

OpenGL Graphics System. 2D Graphics Primitives. Drawing 2D Graphics Primitives. 2D Graphics Primitives. Mathematical 2D Primitives.

EECE 478. Learning Objectives. Learning Objectives. Rasterization & Scenes. Rasterization. Compositing

For more info and downloads go to: Gerrit Stols

Module Contact: Dr Pierre Chardaire, CMP Copyright of the University of East Anglia Version 1

CS 4731: Computer Graphics Lecture 21: Raster Graphics: Drawing Lines. Emmanuel Agu

Assignment 1. Simple Graphics program using OpenGL

CS 130 Final. Fall 2015

Solution Notes. COMP 151: Terms Test

Viewing with Computers (OpenGL)

CHAPTER 1 Graphics Systems and Models 3

CS 428: Fall Introduction to. Transformations in OpenGL + hierarchical modeling. Andrew Nealen, Rutgers, /21/2009 1

Module Contact: Dr Gavin Cawley, CMP Copyright of the University of East Anglia Version 1

Line Drawing Week 6, Lecture 9

Do not turn over until you are told to do so by the Invigilator.

Midterm Exam Fundamentals of Computer Graphics (COMP 557) Thurs. Feb. 19, 2015 Professor Michael Langer

To Do. Computer Graphics (Fall 2008) Course Outline. Course Outline. Methodology for Lecture. Demo: Surreal (HW 3)

Scene Graphs. CS4620/5620: Lecture 7. Announcements. HW 1 out. PA 1 will be out on Wed

Computer Graphics : Bresenham Line Drawing Algorithm, Circle Drawing & Polygon Filling

CS475/675: Computer Graphics End-Semester Examination (Solutions), Fall 2016

CS602 Midterm Subjective Solved with Reference By WELL WISHER (Aqua Leo)

0. Introduction: What is Computer Graphics? 1. Basics of scan conversion (line drawing) 2. Representing 2D curves

Lecture 5 2D Transformation

Module Contact: Dr Geoff McKeown, CMP Copyright of the University of East Anglia Version 1

CS184 : Foundations of Computer Graphics Professor David Forsyth Final Examination

Assignment #6 2D Vector Field Visualization Arrow Plot and LIC

Lecture 5b. Transformation

Generating Vectors Overview

Introduction to OpenGL

S U N G - E U I YO O N, K A I S T R E N D E R I N G F R E E LY A VA I L A B L E O N T H E I N T E R N E T

Tópicos de Computação Gráfica Topics in Computer Graphics 10509: Doutoramento em Engenharia Informática. Chap. 2 Rasterization.

COMPUTER GRAPHICS, MULTIMEDIA AND ANIMATION, Second Edition (with CD-ROM) Malay K. Pakhira

THE AUSTRALIAN NATIONAL UNIVERSITY Final Examinations(Semester 2) COMP4610/COMP6461 (Computer Graphics) Final Exam

CS184 : Foundations of Computer Graphics Professor David Forsyth Final Examination (Total: 100 marks)

QUESTION BANK 10CS65 : COMPUTER GRAPHICS AND VISUALIZATION

Scan Conversion. Drawing Lines Drawing Circles

Module 2 Test Study Guide. Type of Transformation (translation, reflection, rotation, or none-of-theabove). Be as specific as possible.

Realtime 3D Computer Graphics Virtual Reality

Spring 2011 Prof. Hyesoon Kim

Points and lines. x x 1 + y 1. y = mx + b

Drawtool. Toby Jaffey December 2, Drawtool What is it? What can I do with it? Data format...

Output Primitives Lecture: 3. Lecture 3. Output Primitives. Assuming we have a raster display, a picture is completely specified by:

CSCI 4620/8626. Coordinate Reference Frames

Cs602-computer graphics MCQS MIDTERM EXAMINATION SOLVED BY ~ LIBRIANSMINE ~

Math 9: Chapter Review Assignment

From Vertices to Fragments: Rasterization. Reading Assignment: Chapter 7. Special memory where pixel colors are stored.

Output Primitives. Dr. S.M. Malaek. Assistant: M. Younesi

The Rendering Pipeline (1)

Answer BOTH questions from Section A and ONE question from Section B.

Texture Mapping. Texture (images) lecture 16. Texture mapping Aliasing (and anti-aliasing) Adding texture improves realism.

lecture 16 Texture mapping Aliasing (and anti-aliasing)

Efficient Plotting Algorithm

Rasterization and Graphics Hardware. Not just about fancy 3D! Rendering/Rasterization. The simplest case: Points. When do we care?

Virtual Environments

From Ver(ces to Fragments: Rasteriza(on

COMP30019 Graphics and Interaction Scan Converting Polygons and Lines

Module Contact: Dr Pierre Chardaire, CMP Copyright of the University of East Anglia Version 1

Einführung in Visual Computing

Chapter 2: Transformations. Chapter 2 Transformations Page 1

Example Examination 2IV

CS 543 Lecture 1 (Part 3) Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

Transcription:

UNIVERSITY OF EAST ANGLIA School of Computing Sciences Main Series UG Examination 2012-13 GRAPHICS 1 CMPC2G04 Time allowed: 2 hours Answer THREE questions out of FOUR. (40 marks each) Notes are not permitted in this examination. Do not turn over until you are told to do so by the invigilator. CMPC2G04 Module Contact: Dr R J Lapeer, CMP Copyright of the University of East Anglia Version 1

Page 2 1. The window in Figure 1 (a) below shows a bug which is capable of crawling across the screen in any possible direction. The user interface is keyboard and mouse based. The left and right keyboard arrows allow the bug to rotate around its own axis in anti-clockwise and clockwise directions respectively, whilst the up and down arrows allow the bug to accelerate or decelerate respectively. Once the left mouse button is activated, the bug starts moving forwards according to a velocity vector with a speed set by the up and down arrows and a direction set by the left and right arrows. Additionally, three rotating clusters of three triangles, squares and circles, respectively, surround the bug. The individual polygons rotate around their centre, whilst their clusters can rotate around the cluster centre and finally all clusters rotate collectively around the screen centre (similar to a teacup ride on the fairground). There is collision detection enabled between the bug and the rotating objects, the latter being capable of knocking the bug backwards once they collide. The aim of the game is to let the bug escape without being hit by the rotating objects. A demo (executable) of this simple game was shown during the lectures. (a) (b) Figure 1. a. Figure 1(b) shows the update of the bug s position. The variable dmove in the code corresponds to the speed (length of velocity vector v) of the bug and is determined by the up and downward arrows. From the figure it can be seen that the update for the x coordinate is given by the following equation: x n x0 dmove cos( / 2 )

Page 3 Where x 0 is the x-coordinate of the current position and x n is the x-coordinate of the next position. Tasks: i. Write down the equation used to update the y-coordinate. [3 marks] ii. Why is /2 added to? [4 marks] b. A snippet of the display function for this 2D game is shown below: void display(void) { glclear(gl_color_buffer_bit); setrotmat(m,pi*spin[0]/180.0,2); glcolor3f(0.0,1.0,0.0); Idisplay(theTriangle,-25.0,25.0); glcolor3f(1.0,0.0,0.0); Idisplay(theSquare,0,-35.355); glcolor3f(0.0,0.0,1.0); Idisplay(theCircle,25.0,25.0); glpushmatrix(); glenable(gl_texture_2d); glbindtexture(gl_texture_2d,texname); glcolor3f(1.0,1.0,1.0); xn=xo+dmove*cos(pi/2+alpha*pi/180.0); yn=yo+dmove*sin(pi/2+alpha*pi/180.0); xo=xn;yo=yn; settramat(mb1,xn,yn,0.0); setrotmat(mb2,pi*alpha/180.0,2); MultMat(mb1,mb2,mb); glloadmatrixf(mb); glbegin(gl_quads); gltexcoord2f(0.0,0.0); glvertex2f(bugpoly.vert[0].x,bugpoly.vert[0].y); gltexcoord2f(1.0,0.0); glvertex2f(bugpoly.vert[1].x,bugpoly.vert[1].y); gltexcoord2f(1.0,1.0); glvertex2f(bugpoly.vert[2].x,bugpoly.vert[2].y); gltexcoord2f(0.0,1.0); glvertex2f(bugpoly.vert[3].x,bugpoly.vert[3].y); glend(); glpopmatrix(); glutswapbuffers(); glflush(); gldisable(gl_texture_2d); PLEASE TURN OVER

Page 4 The function settramat replaces the fourth column of a 4x4 transformation matrix stored in a vector of length 16 called mb1, with [xn yn 0.0 1.0] T. The function setrotmat takes an angle (float) as second argument and an axis ID (int) as third argument (0=x,1=y,2=z) and creates a 4 x4 rotational matrix, stored in a vector of length 16. i. Assuming the angle (second argument) is 90 degrees, write down the corresponding 4x4 matrix. [4 marks] ii. Write down the body of the function setrotmat(float *m,float angle,int axis) using a switch/case statement to specify the code for each different axis. Since the code only needs to work in 2D, you can leave the case statements for two particular axes blank. You can make use of a function setidentity(m) to set your matrix m equal to the identity matrix. [10 marks] iii. After the positional coordinates of the bug are updated to their new positions xn and yn, respectively, the updated values are assigned to x0 and y0 in the function display. Why is this necessary? Could this be performed more optimally without using x0 and y0? If so, rewrite the code snippet. [4 marks] c. Without going into an in depth implementation of the code for the bug game, write down a function body illustrating a nested hierarchy of three rotations such as the one displayed in the game by the clusters of triangles, circles and squares, i.e. the teacup ride effect. Call the function idisplay() and use the glpushmatrix(), glpopmatrix(), gltranslatef(x,y,z) and glrotatef(a,x,y,z) functions. You can use variables such as poly[i] (i=0 for circles, 1 for triangles, 2 for squares) and a pseudo function such as display(poly[i])to display individual polygons. Use the global variables centre_angle, cluster_angle and poly_angle for the rotational angles at each respective level. You do not need to update these angles in this function as that happens somewhere else and angles are the same for each type of polygon (so no need to put some random effects in it). The x,y screen coordinates of the centres of each cluster are (-25.0,25.0) for the triangles; (0,-35.355) for the squares and (25.0,25.0) for the circles. Hint: the radius (call it Radius1) of the clusters around the centre is sqrt(25^2+25^2 35.355). The positions of the circles, triangles and squares is 30º, 150º and 270º respectively (note the 120º increment between angles). The radius within each cluster is 10.0 (call it Radius2). Within the cluster, the polygons are initially positioned (See Fig. 1(a)) at 90º, 210º and 330º (note the 120º increment between angles). Hint: Build your program from the middle outwards, i.e. start with the local transformations of the individual polygons, then in their clusters, then the clusters around the centre. [15 marks]

Page 5 2. a. In the context of rasterising outline fonts, describe what is meant by the terms: Hinting, Antialiasing and Sub-pixel rendering. b. In the context of the CIE colour spaces: [10 marks] i. Describe the CIE XYZ colour space. What was the motivation behind its development? What is the main difference between the shapes of the CIE RGB and CIE XYZ colour matching functions? [5 marks] ii. Given any XYZ triplet, how do you calculate its chromaticity coordinates xy? If an xy coordinate equals [0.3 0.33], what is its corresponding z coordinate? [2 marks] iii. Draw the CIE xy diagram containing the shape of a typical display colour gamut. In the diagram, indicate the locations of the spectral curve, purple line and display primaries. [5 marks] c. You downloaded a.jpg image from the web. How would you change the saturation of this image? Your answer should include a clear description of all the steps of the algorithm. [9 marks] d. Describe the RGB, CMY and HSV colour spaces and their main applications. [9 marks] PLEASE TURN OVER

Page 6 3. a. We consider the mid-point algorithm for line drawing. In the lectures we have seen how to determine the E-NE pixels in the 0-45 degrees octant based on the mid-point criterion using a decision variable d. i. Write down the mid-point criterion (determine d) when considering the N- NE pixels in the 45-90 degree octant. Use Figure 2 as a guide. Also write down the conditions (i.e. with respect to parameters a,b and m) for which the criterion is valid. [12 marks ] ii. What is the main advantage of the midpoint algorithm over the DDA algorithm? [3 marks ] iii. Briefly discuss anti-aliasing techniques for line drawing. [9 marks ] Figure 2. b. Imagine we start with a square at the origin as shown in Figure 3(a). We wish to derive the articulated geometry (some kind of robotic arm) as shown in Figure 3(b). Specify the 2D transformation matrices (in the right order) to arrive at this geometry by solely using three squares all starting in the origin as shown in Figure 1a. Do this in three steps, i.e. first for the gantry, then the first link, then for the second link, as seen in the lectures. [16 marks]

Page 7 Figure 3. PLEASE TURN OVER

Page 8 4. a. Consider the scan-line algorithm for the polygon in Figure 4. i. Show the relevant scan lines on an updated figure. Also indicate which points need to be lowered by drawing a dot underneath and label this new point with the primed label of the original point. [ 8 marks ] ii. Determine the initial bucket-sorted edge table using linked lists. [12 marks] Figure 4.

Page 9 b. The figure below shows a region with one line to be clipped. Illustrate how the Cohen-Sutherland clipping algorithm (programming code shown below) will clip this line using a step by step approach, i.e. by clearly referring to the programming code line numbers which are processed during program execution. Also make sure you mention the state of any variable that is altered when a particular line is processed. Update Figure 5 with the new points generated during the execution of the program. [20 marks] Figure 5. PLEASE TURN OVER

Page 10 1. void ClipLine_Cohen_Sutherland(coord winmin, coord winmax, coord p0, coord p1){ 2. unsigned char code0,code1; 3. int done = FALSE, draw = FALSE; 4. float m; 5. while(!done){ 6. code0 = encode(p0,winmin,winmax); 7. code1 = encode(p1,winmin,winmax); 8. if(accept(code0,code1)){ /* Line is entirely inside clip-window */ 9. done = TRUE; 10. draw = TRUE; 11. else { 12. if(reject(code0,code1)) 13. done = TRUE; 14. else { 15. if(inside(code0)){ /* Init. Point inside clip-window => swap */ 16. swappts(&p0,&p1); 17. swapcodes(&code0,&code1); 18. if(p1.x!= p0.x){ /* No vertical line */ 19. m=((float)(p1->y-p0->y))/((float)(p1->xp0->x)); 20. if(code0 & LEFT_EDGE){ 21. p0.y += (winmin.x-p0.x)*m; 22. p0.x = winmin.x; 23. else if(code0 & RIGHT_EDGE){ 24. p0.y += (winmax.x-p0.x)*m; 25. p0.x = winmax.x; 26. else if(code0 & BOTTOM_EDGE){ 27. if(p1.x!= p0.x)/* None-vert.lines*/ 28. p0.x += (winmin.y-p0.y)/m; 29. p0.y = winmin.y; 30. else if(code0 TOP_EDGE){ 31. if(p1.x!= p0.x)/* None-vert.lines*/ 32. p0.x += (winmax.y-p0.y)/m; 33. p0.y = winmax.y; /* end_while */ 34. if(draw)line_dda_b(p0.x,p0.y,p1.x,p1.y); END OF PAPER