For triangles we need merely modify the tests so that all vertices are considered:
if (outcode1 == '0000' and
outcode2 == '0000' and
outcode3 == '0000') then
triangle is inside
else
if (outcode1 and outcode2 and outcode3 == '0000') then
line segment potentially crosses clip region
else
line is entirely outside of clip region
endif
endif
This form of clipping is not limited to triangles or convex polygons.
Is is simple to implement. But it won't handle all of our problems...
|