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
Compression methods utilized for digital video can be categorized in three major groups: General reason compression techniques can be utilized for any type of data. Intr

Write a program that allows interactive manipulation of the position and orientation of a camera. Draw a teapot at the global origin 0,0,0. You can find a shaded teapot model and

MPEG-2 : MPEG-2 that is Moving Picture Experts Group format 2 is the standard used through DVD and is of a much higher quality than MPEG- 1. This format gives for 720 x 480 resolu

Electronic Encyclopedia : This is the application of multimedia for the creation of an encyclopedia along with millions of entries and hypertext cross references covering a br

Key Frame Systems - computer animation This method is for low-level motion control. In fact these systems comprise languages that are designed simply to produce the in-between

Polygon Tables - curves and surfaces All polygons are analogous to a graph G (V, E). Remember that the analogy in which a polygon surface can be specified along with as a set

Q. Why are all resolutions in ratio of 4:3? The bad news is that almost every monitor can only display upto a maximum of 262,144 colours (i.e.  18 bits/pixel Colour Depth). The

Advantages of the z-buffer method:              1) The z-buffer method or algorithm is easy to apply and it needs no sorting of surface in a scene. 2) In z-buffer algorithm

Persistence (of phosphor) - Display devices Time it takes the emitted light from screen to decay to one-tenth of its original intensity. The point where an electron gun strikes

Determine the perspective transformation matrix upon to z = 5 plane, when the center of projection is at origin. Solution. As z = 5 is parallel to z = 0 plane, the normal is s