Computer Graphics Final
Computer Graphics Final
● 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
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.
(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
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)
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
(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.
(-x, y) ,( x, -y), (-x, -y), (y, x), (-y, x), (y, -x), (-y, -x) will also be lie on the curve.
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.