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 \((p_x, p_y)\) is within the bounded region of a triangle with corner points \(p_1=(x_1, y_1)\), \(p_2=(x_2, y_2)\), and \(p_3=(x_3, y_3)\), if the following is true:
\[\frac{(x_1 - x_3) p_y + (x_3 - p_x) y_1 + (p_x - x_1) y_3}{ (y_1-y_2) x_3 + (y_2 - y_3) x_1 + (y_3 - y_1) x_2}\ge 0\land\]\[\frac{(x_2 - x_1) p_y + (p_x - x_2) y_1 + (x_1 - p_x) y_2}{ (y_1 - y_2) x_3 + (y_2 - y_3) x_1 + (y_3 - y_1) x_2}\ge 0\land\]\[\frac{(x_2 - x_3) p_y + (x_3 - p_x) y_2 + (p_x - x_2) y_3}{ (y_1 - y_2) x_3 + (y_2 - y_3) x_1 + (y_3 - y_1) x_2}\le 0\]