Question (1)

 

 

A-Why do we study clipping?

 Only render what will be visible in the drawing window: eliminate from the rendering pipeline all those primitives which will not appear in the final view port. 

 

b-Apply Cohen Sutherland Line Clip

M=6/12=0.5

For point (8,3)      Code :1001

For point (22,10)   Code:0110

(8,3)&(22,10)->>0

Clipping (8,3)         y=4

x=x0+1/M(y-y0)

x=8+2(4-3)=10

point on  clip region is (10,4)

Clipping (22,10)     x=20

y=y0+M(x-x0)

y=10+1/2(20-22)=9

point on  clip region is (20,9)

 

d-Apply Line-Barsky Clipping

 

dx=14    ,   dy=7

 

p1=-14             q1=-2

p2=14               q2=12

p3=-7                q3=-1

p4=7                  q4=6

 

       t0=0    &   t1=1

 

 

 

 

 

àleft edge

 

P1<0              t0=q1/p1=1/7

     t0=max(0,1/7)=1/7

 

àright edge

P2>0                 t1=q2/p2=6/7

     t1=min(1,6/7)=6/7

 

 

 

àtop edge

P3<0              t0=q3/p3=1/7

     t0=1/7

 

àbottom edge

P4>0                 t1=q4/p4=6/7

     t1=6/7

 

t0<t1

à t0=1/7

x1=8+1/7*14=10

y1=3+1/7*7=4

point intersection (10,4)

àt1=6/7

x2=8+6/7*14=20

y2=3+6/7*7=9

point intersection (20,9)

 

 

Question (2)

Select a, b, c, or d that satisfies each statement

x

 

ix

viii

vii

vi

v

iv

iii

ii

i

a

b

d

d

c

d

d

d

b

d

 

 

 

 

 

 

Question (3)

Put T for correct statement and F for wrong statement

x

 

ix

viii

vii

vi

v

iv

iii

ii

i

T

F

T

F

F

F

T

F

F

F

 

 

 

 

 

 

Question (4)

Briefly explain:

i)The difference between Screen resolution and screen size

Resolution is not the same thing as screen size if we have resolution (20 by 15)display could have been 5cm(as mobile phone display),40cm across(as monitor)or 20cm(as projection system) but the resolution would always be 20 by 15.

 

ii) Steps that a computer takes to plot the point (22.25, 10.4)

At the lowest level, computers only understand integer's coordinates. So if we want to plot appoint at (22.25, 10.4) we will need some schema for converting it sensibly into integer value.

 

iii) Why we need to use homogenous coordinate.

Addition necessary to perform translation can be achieved by multiplication

 

iv) Do you want to have the point of this sub-question?

Yes, of course

 

v) Problem of Brute Force algorithm in drawing a line and how to solve them (give an example)

If we have gradient m is >1, Gaps starts to appear in the line as value of y increase by an amount greater than the increments of x, The solution to this gaps is to always use the most rapidly changing variable(x or y) as the index to the loop .When the gradient (m>1) use y as control variable in the loop and make x the subject of the equation:

x=(y-c)m .There is the second problem with the brute force that it is require floating point arithmetic which is slow when compared with using integer only arithmetic.

 

 

 

 

(An Example)

Let x_from=10,y_from=10,x_to=40,y_to=90

Y

X

10

10

13

11

15

12

18

13

21

14

 

 

 

 

 

 

 

vi) 24 bit color representation

Each pixel will be represented by 24 bits 3*8 bit bytes. Each byte represents a number between 0 and 255 and each byte is associated with one primary color red ,blue and green

 

vii)The difference between computer and math(point and line).

(For a point)In math, a point has no size, it is infinitesimally small, to a computer, and a point is the size of a pixel

 (For a line)In math it can be defined by its end points, also line in math has no thickness, in computer graphics it does.

viii)The decision criteria(in Bresenham's algorithm).

Iterating the x values from left to right. if the pixel at(xi,yi)has been plotted, then the next one must be either (xi,yi)or(xi,yi+1).Why because of the gradient it can not go up more one than one step in the y-direction for one step in x and it can not go down at all. How can we work out which pixel to plot? by calculating the difference between the true mathematical value of y at xi+1(we will call that yreal)  

 

ix) Cheating with eight arcs (when drawing circle), and why?

Some saving of calculation (and hence time) can be made by using the symmetry of the circle. The use of this symmetry means that values of x and y only need to calculated for the octant where 0<x<=y. Start with x=radius and y=0.

 

x) The difference between convex and concave polygons.

Convex solid has the property that a line drawn from any point on the surface to a point on a second surface passes entirely through the interior of the solid

Concave solid has the property that a line drawn from any point on the surface to a point on a second surface not  passes entirely through the interior of the solid

 

xi) The boundary condition used to complete the four equation to solve the spline curve parameters.

1- The lines meet

                                         The last x value in segment si is equal to first x value in      segment s(i+1)

2-The join between the lines is continuous. The gradient of the end of the segment si=the gradient of the first of segment s(i+1)

3-The line meet smoothly The 2nd derivative of the end of the segment si=the gradient of the first of segment s(i+1)

 

 

Question (5)

i) Ask your self question and answer it.

Question:

 What is Digital Differential Analysis –An increment algorithm?

Answer:

 A slightly better (quicker)way of calculating x and y values is the digital differential analyzer algorithm which does not require sine or cosine tables but instead upon calculating the gradient of a circle at a point  and using that to approximate the position of the next point .

 

Our starting point is the equation of circle (of radius R) centered on the origin.

 

(II)

 

 

Question (6)

 

 

 

 

 

(I)

 

   (a )      (0,3)

(b)       (1,2)

(c)       (2,1)

(d)       (3,1)

Is not logical start(0,3) &end (3,1)

 

(II)

     dx=3-0=3

     dy=-2

     d=-7

incrE=-4

incrNE=-10

x=0

y=3

(III)

       The algorithm will draw the start point only and will not enter while loop 

(IV)

While dy0-dy1>0

yi+1=yi +1

y++

x is incremented always  by 1

 

(V)

Void MidPointLine(int X0,int Y0,int X1,int Y1)

{

  int dX=X1-X0;

  int dY=Y1-Y0;

  int d=2*dy;

  int incrE=2*dY;

  int incrNE=2*(dY-dX);

  int X=X1;

int Y=Y1;

writePixel(X,Y);

while(X>X0)

{

  if(<=0)

    {

      d=d+incrE;

     }

   else

    {

     d=d+incrNE;

     Y--;

     }

  X--;

   Writepixel(X,Y);

   }

}

 

 

 

Question(7)

(I)

Xmin=0

Ymin=1

Xmax=3

Ymax=3

 

(II)

Y0,X1

 

(III)

No

 

(IV)

Don’t change value of code after operation ,The algorithm will be incorrect

 

(V)

‘+’ meaning ‘and’

 

(VI)

a=(0,3)

b=(1,2)

c=(2,1)

d is outside of the clip region

 

(VII)