There are four possible cases for any given edge of given polygon against current clipping edge e.
- Both vertices are inside : Only the second vertex is added to the output list
- First vertex is outside while second one is inside : Both the point of intersection of the edge with the clip boundary and the second vertex are added to the output list
- First vertex is inside while second one is outside : Only the point of intersection of the edge with the clip boundary is added to the output list
- Both vertices are outside : No vertices are added to the output list
- To decide if a point is inside or outside the clipper polygon
- To find the point of intersection of an edge with the clip boundary
Determining which side a point lies againt a line
If the vertices of the clipper polygon are given in clockwise order then all the points lying on the right side of the clipper edges are inside that polygon. This can be calculated using :
Given that the line starst from (x1,y1) and ends at (x2,y2):
\[P=(x2-x1)(y-y1)-(y2-y1)(x-x1)\]
if P<0 the point is on the right sie of the lin
P=0 the ponit is on the line
P>0 pont is on left side
Polygon Clipping | Sutherland–Hodgman Algorithm - GeeksforGeeks
Sutherland–Hodgman algorithm - Wikipedia
0 件のコメント:
コメントを投稿