Application of sutherland hodgman polygon clipping, Computer Graphics

For good understanding of the application of the rules specified above see the following figure, where the shaded region demonstrates the clipped polygon.

801_Application of Sutherland Hodgman Polygon Clipping.png

Figure: Sutherland-Hodgman Polygon Clipping

Pseudo code for Sutherland - Hodgman Algorithm

Define variables

In VertexArray is the array of input polygon vertices

outVerteArray is the array of output polygon vertices

Nin is the number of entries in inVertexArray

Nout is the number of entries in outVertexArray

n is the number of edges of the clip polygon

ClipEdge[x] is the xth edge of clip polygon defined by a pair of vertices

s, p are the start and end point respectively of current polygon edge

i is the intersection point with a clip boundary

j is the vertex loop counter

Define Functions

AddNewVertex(newVertex, Nout, outVertexArray)

: Adds newVertex to outVertexArray and then updates Nout

InsideTest(testVertex, clipEdge[x])

: Checks whether the vertex lies inside the clip edge or not;

  retures         TRUE is inside else returns FALSE

Intersect (first, second, clipEdge[x])

: Clip polygon edge (first, second) against clipEdge[x], outputs the intersection point

{                                        :  begin main

x = 1

while (x ≤ n)                     : Loop through all the n clip edges

{

Nout = 0                            : Flush the outVertexArray

s = inVertexArray[Nin] : Start with the last vertex in inVertexArray

for j = 1 to Nin do             : Loop through Nin number of polygon vertices (edges)

{

p = inVertexArrray[j]

if InsideTest(p, clipEdge[x] = = TRUE then                     : Case A

and D

if InsideTest(s, clipEdge[x] = = TRUE then

AddNewVertex(p, Nout, outVertexArray)                        : Case A

else

i = Intersect(s, p, clipEdge[x])                           :  Case D

AddNewVertex(i, Nout, outVertexArray)

AddNewVertex(p, Nout, outVertexArray)

end if

else      :  i.e. if InsideTest(p, clipEdge[x] = = FALSE

(Cases 2 and 3)

if InsideTest(s, clipEdge[x]) = =TRUE then                     : Case B

{

 Intersect(s, p, clipEdge[x])

AddNewVertex(i, Nout, outVertexArray)

end if                                        : No action for case C

 

s = p                                         : Advance to next pair of vertices j = j + 1

end if                                         :  end {for}

}

x = x + 1                                     : Proceed to the next ClipEdge[x +1]

Nin = Nout

inVertexArray = outVertexArray            :  The output vertex array for the current clip edge becomes the input vertex array for the next clip edge

}                                        : end while

}                                        : end main

Posted Date: 4/3/2013 3:50:42 AM | Location : United States







Related Discussions:- Application of sutherland hodgman polygon clipping, Assignment Help, Ask Question on Application of sutherland hodgman polygon clipping, Get Answer, Expert's Help, Application of sutherland hodgman polygon clipping Discussions

Write discussion on Application of sutherland hodgman polygon clipping
Your posts are moderated
Related Questions

Vertical retrace - Display Devices In a refresh CRT monitor, the time it takes for an electron beam to return to the top, left most point on the monitor after refreshing all ho

Magnify a triangle with vertices A = (1,1), B = (3,1) and C = (2,2) to twice its size in such a way that A remains in its original position.  Answer: You need to apply scaling b

Q.   Describe the z- Buffer algorithm for hidden surface removal. Ans. Z- buffer method: This method compares surface depths at each pixel position on the projection plane. T

What is character generation and explain it''s two method: 1> Bitmap method 2> outline method.

Question 1 Write a note on digitizers Question 2 Discuss on line drawing algorithm Question 3 Explain 3D viewing Question 4 Explain different types of cohe

Problem: (a) Distinguish between mono and stereo sound? (b) Calculate the size of a 5 minutes mono sound file of CD quality and with a 16 -bit rate. (c) With reference

File Formats that are used for Vector Data This data can be saved in a wide variety of file formats are as: •EPS: the most well-accepted file format to exchange vector dra

Animator Studio and Elastic Reality - Computer Animation Animator Studio It is a cell animation program from AutoDesk. Its predecessor was Animator Pro for PC DOS. Anima

What do you mean by scan conversion?  A main task of the display processor is digitizing a picture definition given in an application program into a set of pixel-intensity valu