Homework-3 CAP405: COMPUTER GRAPHICS

Submitted to – Lect. Sandeep Sharma

Submitted bySurendra MCA 4th SEM D3804A15 10806601

DECLARATION It is declared by me that this assignment is purely my effort and I had done my assignment of my own. I accept that I had taken the help of internet and books of modern programming tools and technique but I had used my own language while answering the questions of homework 1. I had tried my best to make my assignment unique from other student.

DECLARED BY Surendra

Part A 1) Illustrate the concept of Window to view-port transformation by taking a real world example. Answer:
“The process that converts objects coordinates in WCS to normalized device coordinates is called Window to view-port transformation ”.

Window to view-port transformation having three steps transformation composition as suggested by the following sequence of pictures:

As the world window increases in size the image in viewport decreases in size and vice-versa. Used in two applications:

 

Panning - Moving the window around the world Zooming- Reducing/increasing the window size

2) Differentiate following terms by taking suitable example:

a) Window b) View port c) Clipping ANSWER:
 

A world-coordinate area selected for display is called a window. An area on a display device to which a window is mapped is called a viewport. The window defines what is to be viewed; the viewport defines where it is to be displayed. Generally, any procedure that identifies those portions of a picture that are either inside or outside of a specified region of space is referred to as a clipping algorithm, or simply clipping.

yw max

yv max
yw min yv min xw min

xw max

xv min

xv max

Example of window and viewport:

yw

xw

3) Give the different scenarios under which various clipping methods will be applicable and useful. ANSWER:

y

P4

y
P2

ywmax

P3

ywmax
P5 P 10 P6
P 1

P7

P7

P5 P 10

P6

P 1

P8

ywmin
P9

ywmin xwmin

′ P9

′ P8

xwmax

x

xwmin

xwmax

x

xmin ≤ x ≤ xmax ymin ≤ y ≤ ymax

w ind

Part B
4)

Develop a procedure to implement Cohen Sutherland line clipping Algorithm. ANSWER:

First we test whether both endpoints are inside (and hence draw the line segment) or whether both are left of , right of ,

all or none text clipping

below , or above (then we ignore line segment). Otherwise we split the line segment into two pieces at a clipping edge (and thus reject one part). Now we proceed iteratively. A rather simple accept-reject test is the following: Divide the plane into 9 regions and assign a 4 bit code to each:

1000 ...above top edge 0100 ...below bottom edge 0010 ...right of right edge 0001 ...left of left edge Maths calculates the corresponding bit-codes for both endpoints.

Figure: Codes for the 9 regions associated to clipping rectangle

If both codes are zero then the line segment is completely inside the rectangle. If the bitwise-and of these codes is not zero then the line does not hit since both endpoints lie on the wrong side of at least one boundary line (corresponding to a bit equal to 1). Otherwise take a line which is met by the segment (for this find one non-zero bit), divide the given line at the intersection point in two parts and reject the one lying in the outside halfplane.

Figure: Example of Cohen-Sutherland line-clipping algorithm

5) Take an example and perform interior and exterior clippings on the Text. ANSWER: A typical example of the application of exterior clipping is in multiple window systems.3rd is exterior clipping and

6) Can we say that like images, texts can also be clipped? If yes, justify your answer by taking an example text and perform clipping. ANSWER: We can say that like images, texts can also be clipped. Three strategies can be followed: • all-or-none string clipping – use a bounding rectangle for the string • all-or-none character clipping – use a bounding rectangle for the character

• individual character clipping – like line/curve clipping (outlined char’s) - compare individual pixels (bit-mapped

T