Find if a point is within a triangle: Difference between revisions

Line 606:
This routine works by taking each line in the triangle and determining which side of the line the point is on. This is done using the "determinant" of the three points. If a point is on the same side of all sides in the triangle, the point is inside the triangle. Conversely, if a point isn't on the same side, it is out of side the triangle. Since there are only three points in a triangle, this applies no matter the order in which the points are presented, as long as the points are traversed in order. Points that fall on a line are treated as though they have the same "inside" sense when combined with other lines.
 
[[File:PintInTriangle.png|thumbframe|leftnone]]
 
<syntaxhighlight lang="Delphi">
465

edits