Application of sutherland hodgman polygon clipping, Computer Graphics

Assignment Help:

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


Related Discussions:- Application of sutherland hodgman polygon clipping

B-spline curves - uniform b-splines and de boor algorithm, B-spline curves ...

B-spline curves are piecewise smooth polynomial curves.  B-spline curves are defined over an interval which has been partitioned into sub-intervals. On each subinterval B-sp

Mpeg-2 , MPEG-2 : MPEG-2 that is Moving Picture Experts Group format 2 is ...

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

Modify the dda algorithm for negative sloped lines, 1. Modify the DDA algo...

1. Modify the DDA algorithm for negative sloped lines; discuss both the cases i.e., slope > 1 and 0   Ans. For the generation of lines along with negative slopes as:

Rotation - 2-d and 3-d transformations, Rotation - 2-D and 3-D transformati...

Rotation - 2-D and 3-D transformations Within 2-D rotation, an object is rotated via an angle θ along w.r.t. the origin. This angle is assumed to be +ive for anticlockwise rot

Positioning Techniques, Explain Positioning Techniques in computer Graphics...

Explain Positioning Techniques in computer Graphics in detail

List of 3-d animation software, List of 3-D Animation Software Here is ...

List of 3-D Animation Software Here is a short list of several 3-D animation software are - Softimage ( Microsoft) -  Alias/Wavefront ( SGI) -  3D studia MAX (Autodesk

Cathode ray tube, cathode ray tube is an analog or digital device

cathode ray tube is an analog or digital device

Pitfalls in computer simulation - computer aided design, Pitfalls in comput...

Pitfalls in computer simulation Though generally avoided in computer simulations, in strict logic the rules governing floating point arithmetic even apply. For illustration, t

Write a c code for generating concentric circles, Write a C code for genera...

Write a C code for generating concentric circles.  Put the circle function circleMidpoint()in a for loop  as follows: for( int radius = MinRadius; radius circleMidpoint(i

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd