373HW
-
Upload
ali-farhan -
Category
Documents
-
view
216 -
download
2
description
Transcript of 373HW
![Page 1: 373HW](https://reader035.fdocuments.us/reader035/viewer/2022081206/577cc16e1a28aba711930827/html5/thumbnails/1.jpg)
-1/2-
Q A T A R U N I V E R S I T Y
C o l l e g e o f E n g i n e e r i n g
Dept. of Computer Science & Eng’g
Homework Date: 13/12/2014 @ 11:59PM
Weight: 10%
Computer Graphics (CMPS 373)
Fall 2014 Semester
ANSWER THE FOLLOWING:
Question1. [5 marks]
a) Write a function called leftMotif() that draws two arcs inside a
square (see the figure on the right). The arcs are drawn each with
its center at opposite corners of the square (bottom-left corner and
top-right corner) and its radius is equal to the side of the square.
Use the following prototype:
void leftMotif(float side);
To draw the square you may use the ngon() function with the
center point at ( ) and . Also set the
rotation angle to 45 degrees.
b) Write another function called rightMotif() that draws two arcs
inside a square (see the figure on the right). The arcs are drawn
each with its center at opposite corners of the square (bottom-right
corner and top-left corner) and its radius is equal to the side of
the square. Use the following prototype:
void rightMotif(float side);
To draw the square you may use the ngon() function with the
center point at ( ) and . Also set the
rotation angle to 45 degrees.
c) Using leftMotif() and rightMotif()
and a suitable display function draw the
following pattern.
![Page 2: 373HW](https://reader035.fdocuments.us/reader035/viewer/2022081206/577cc16e1a28aba711930827/html5/thumbnails/2.jpg)
-2/2-
Question2. [5 marks]
a) Write a C++ function that draws the diamond shown
on the right. The left vertex is at (x0,y0), and the
lengths of its diagonals are d and d3 . The function
prototype is:
void drawDiamond (GLfloat x0, GLfloat y0, GLfloat d)
b) Write another function that uses the above
drawDiamond() function to draw the logo on the
right which consists of three blue diamonds, which
make 120o with each other. The vertices meet at the
point (xc, yc) which is the center of the logo. The
function prototype is:
void drawLogo (GLfloat xc, GLfloat yc, GLfloat d)
[ Hint: repeat the following steps three times:
- draw the horizontal diamond, then
- rotate 120 degrees. ]
c) Write a program that rotates the above logo, centered at (0,0), about the z-axis in an anti-
clockwise direction, at a speed of 1o per screen redisplay. Use double buffering to reduce
flicker. (Hint: position the origin of the xy-plane in the middle of the window.)
d) Add to your program a keyboard callback function which allows the user to choose the
speed of rotation according to the values given in the following table:
Key E, e S, s 1 2 Any other key
Action Stop program rotate=0 rotate=0.75 rotate=1.5 rotate=1
Artifacts to submit:
An MS-Word document that contains the source code followed by a screenshot(s) of the graphics output
windows, for each of the above two questions . Please include all the code you used so that we can run it
when your work is assessed. Please do not submit as PDF format.
Please make sure you include a cover sheet that includes your own details and the course and assignment
details.
x0
y0 d
d3