sknano.core.geometric_regions.Triangle.contains¶
-
Triangle.
contains
(point)[source][source]¶ Test region membership of point in
Triangle
.Parameters: point : array_like
Returns: True if point is within
Triangle
, False, otherwise.Notes
A point (px,py) is within the bounded region of a triangle with corner points p1=(x1,y1), p2=(x2,y2), and p3=(x3,y3), if the following is true:
(x1−x3)py+(x3−px)y1+(px−x1)y3(y1−y2)x3+(y2−y3)x1+(y3−y1)x2≥0∧(x2−x1)py+(px−x2)y1+(x1−px)y2(y1−y2)x3+(y2−y3)x1+(y3−y1)x2≥0∧(x2−x3)py+(x3−px)y2+(px−x2)y3(y1−y2)x3+(y2−y3)x1+(y3−y1)x2≤0