write a polygon clipping algorithm to clip a


Write a polygon clipping algorithm to clip a polygon against rectangular clipping are.

Read the vertices of polygon to be clipped. 2. Read the coordinates of the rectangular clipping area against which it has to be clipped. 3. Considering the edge of rectangular area one at a time we apply the following algorithm. 4. /* p is the input vertex, vertex under consideration S is the previous vertex. F is the first point. E is the edge under consideration (of rectangular 7 area against which it has to be clipped) */ Input vertex P 5. If P is the point store it in a variable say F and proceed to step 7. 6. If P is not the first point then if edge 5t intersect edge E under consideration. Computer the intersection point 1 Output vertex 1 else proceed to step 7. 7. Store P in variable S (S=P) 8. If S is on left side of edge E output vertex S. 9. Repeat steps 4 to 8 till all the vertices are processed 10. /* for closing polygon */ if 3f intersect E Computer intersection point 1 output vertex 1 11. Repeat the above steps (4 to 10) with new output polygon obtained from step 10 for other edges of rectangular area under consideration. 

 

Request for Solution File

Ask an Expert for Answer!!
Computer Graphics: write a polygon clipping algorithm to clip a
Reference No:- TGS0156122

Expected delivery within 24 Hours