0% found this document useful (0 votes)
89 views8 pages

Computer Graphics Final

This document provides instructions and questions for a computer graphics exam. It includes 5 questions related to Cohen-Sutherland line clipping algorithm, 3D rotation of a pyramid, frame buffer storage requirements for a raster display, Bezier curve parametric equations, and circle generation using Bresenham's algorithm. The questions test concepts like outcodes, slope calculation, transformation matrices, memory calculations, curve sketching, and symmetric properties of circles. Students are asked to provide solutions explaining their work and thinking in detail.

Uploaded by

Ibtsam Ayyaz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
89 views8 pages

Computer Graphics Final

This document provides instructions and questions for a computer graphics exam. It includes 5 questions related to Cohen-Sutherland line clipping algorithm, 3D rotation of a pyramid, frame buffer storage requirements for a raster display, Bezier curve parametric equations, and circle generation using Bresenham's algorithm. The questions test concepts like outcodes, slope calculation, transformation matrices, memory calculations, curve sketching, and symmetric properties of circles. Students are asked to provide solutions explaining their work and thinking in detail.

Uploaded by

Ibtsam Ayyaz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

COMSATS University Islamabad Lahore Campus

Terminal Examination – Semester FALL 2020


CSD Credit
Course Title: Computer Graphics Course Code: (3,1)
304/353 Hours:
Course Programme
Aamer Mehmood BS Computer Sciences
Instructor/s: Name:
FA17-
th th
Semester: 6 ,5 Batch: BCS/SP18- Section: Date: 6th Jan, 2021
BCS
Time Allowed: 3 Hours Maximum Marks: 50
Student’s
Reg. No.
Name:
Important Instructions / Guidelines:

● Use proper indentation, comments, naming conventions and self-explanatory names if you want to secure
better marks

Question 1(marks=1+1+2+2+4): We wish to use the Cohen Sutherland algorithm to clip line K
(40,45) and L (80,115) against a window with lower left-hand corner at (60,40) and upper right-
hand corner at (90,105).
Answer the following:
a. What is the outcode of K ?
b. What is the outcode of L ?
c. What information do we get from the above two outcodes ?
d. What is the gradient of line KL ?
e. What are the clipping points we get using the Cohen Sutherland algorithm?
Solution:

(A) 0001

(B) 1000

(C) 0001 depicts that window is being intersected from left side and 1000 depicts that window is being
intersected from top

(D) Slope m = (115.000000 - 45.000000) / (80.000000 - 40.000000)


m = 1.750000

(E) Region for point (40, 45) -> 1000


Region for point (80, 115) -> 0001
Y0 = 45 + 1.75 x (60 - 40)
Y0 = 80
X0 = 60

Region for point (60, 80) -> 0000


Region for point (80, 115) -> 0001
New Line co-ordinates (60, 80), (80, 115)

Line has to be clipped!

Slope m = (115 - 80) / (80 - 60)


m = 1.75

X1 = 60 + (105 - 80) / 1.75


X1 = 74.28
Y1 = 105

Region for point (60, 80) -> 0000


Region for point (74.28, 105) -> 0000

New Line coordinates (60, 80), (74.28, 105)

Question 2(marks=3+5+2):

B(9,12,9)

Given a pyramid as shown in the figure above. We wish to rotate this figure by 60 degrees about an
axis that passes through points A(4,7,5) and B(9,12,9).
A(4,7,5)
The transformation matrix for this rotation can be expressed in terms of basic transformation
matrices as follows:
Transformation = T(-x,-y,-z)*R-β*R-α*Rθ*Rβ*Rα*T(x,y,z)
Where α, β and γ denote rotation angle about x,y and z axis respectively.

Given x=-4, y=-7 and z=-5,

(a) What should be the value of α ? (Hint: Take α to be positive and smallest of the possible
angles )
(b) What should be the value of β? Given that β is negative and smallest of the possible angles)
(c) What should be Rθ ?

Solution:
(A) α = 90
(B) β = -90
(C)
Rθ = Cos(60) Sin(60) 0 0 0.5 0.87 0 0
-Sin(60) Cos(60) 0 0= -0.87 0.5 0 0
0 0 1 0 0 0 1 0
0 0 0 1 0 0 0 1

Question 3. (marks= 5+5)


(A). Suppose RGB raster system is to be designed using on 8-inch x 10-inch screen with a
resolution of 100 pixels per inch in each direction. If we want to store 6 bits per pixel in the frame
buffer, how much storage (in bytes) do we need for frame buffer?
(B). How much time is spent scanning across each column of pixels during screen refresh on
a raster system with resolution of 800 X 600 and a refresh rate of 29 frames per second?

Solution:

(A)
(8 inch x 100 pixels/inch) * (10 inch x 100 pixels/inch) * 6 bits * 3 layers * 8 bits per byte
≈ 1.7166 MB

(B) Scan rate for each pixel row = 60 frames/sec * 1024 lines/frame
= 61, 440 lines/sec
And the scan time is approximately 16.3 microseconds per scan line. (Scan time per
frame is 1/60 sec, or approximately 16.7 milliseconds.)

Question 4(marks=8+2):
For the Bezier curve that has the following control points:
p0=(5, 9)
p1=(3, 7)
p2=(7, 5)
p3=(5, 3)

a. Find the parametric equations for the curve


b. Draw a rough sketch of the curve.

Solution:

k
kn n−k
(A) P ( u )=∑ ( Pk u k C (1−u) )
n=0
3
P ( u )=∑ ( Pk u k nk C (1−u)n−k )
n=0

P ( u )=P0 u0 30C (1−u)3 + P1 u1 31C (1−u)2 + P2 u 2 32C (1−u)1+ P 3 u3 33C (1−u)0

P ( u )=P0 (1−u)3 + P1 u 3(1−u)2 + P2 u 2 3(1−u)1 + P3 u3

P ( x ) =5(1−u)3 +9 u(1−u)2+21 u2 (1−u)1 +5 u3

P ( y )=9(1−u)3+ 21u(1−u)2+15 u2 (1−u)1+3 u3

(B)
Question 5: (marks = 5+5)
(A). Draw the line between (1,1) and (7,9) using Bradenham’s line drawing algorithm.
(B). Bradenham’s algorithm can be extended to circles. Convince yourself of this statement
by considering a circle centered at the origin. Which parts of the circle must be generated by an
algorithm and which parts can be found by symmetry? Can you find a part of the circle such that if
we know a point generated by a scan-conversion algorithm, we can reduce the number of
candidates for the next pixel?
Solution:

(A)

M = (y2-y1) / (x2-x1)
= (9-1) / (7-1)
= 8/6 = 4/3
= 1.333
Y = y1+ m(x-x1)
X Y New points
1 1 (1,1)
2 2.33 (2,2.33)
3 3.66 (3,3.66)
4 4.99 (4,4.99)
5 6.33 (5,6.33)
6 7.66 (6,7.99)
7 8.99 (7,8.99)

(B)

If the movement of a point is performed in such a way that its distance from the point
which is fixed, is always constant, then the locus sketched by this point generates a circle.

The point that is fixed is called as the circle center and the distance which is fixed is called as
the circle radius.
( x – a)2 + ( y - b)2 = k2

Where (a, b) and k are the constant distance/center and the radius of the circle respectively.
Consider a circle centered at origin whose equation is given by

x2 + y2 = k2

Where the points x and y lies on the circle and is the constant distance (radius) of the circle.

Consider the figure which is given below:


Figure describes that if can be taken as a pixel which lies on the circle then the pixels

(-x, y) ,( x, -y), (-x, -y), (y, x), (-y, x), (y, -x), (-y, -x) will also be lie on the curve.

This observation is also called as eight fold symmetry of the circle.

Consequently, there are only need to generate of the circle and a degree wedge and
another part can be obtained by copying this part using symmetry

If a wedge is taken which is started from the bottom and makes an angle 45 degree, then
the slope of this curve varies from 0 to 1.

It gives an idea that 1 / 8 part of the circle must be generated, and another part of the circle
can be found by symmetry.

Yes, a part of the circle can be generated which can reduce the number of candidates for
next pixels. This can be achieved by taking a wedge which is started from the bottom and
makes an angle 45 degree.
Therefore, the slope of this curve varies from 0 to 1 which is used to reduce the number of
candidates for next pixels.

You might also like