armi.utils.triangle module

Generic triangle math.

armi.utils.triangle.getTriangleArea(x1, y1, x2, y2, x3, y3)[source]

Get the area of a triangle given the verticies of a triangle using Heron’s formula.

Parameters
  • x1 (float) – x coordindate of first point defining a triangle

  • y1 (float) – y coordindate of first point defining a triangle

  • x2 (float) – x coordindate of second point defining a triangle

  • y2 (float) – y coordindate of second point defining a triangle

  • x3 (float) – x coordindate of third point defining a triangle

  • y3 (float) – y coordindate of third point defining a triangle

Notes

See https://en.wikipedia.org/wiki/Heron%27s_formula for more information.

armi.utils.triangle.getTriangleCentroid(x1, y1, x2, y2, x3, y3)[source]

Return the x and y coordinates of a triangle’s centroid.

Parameters
  • x1 (float) – x coordindate of first point defining a triangle

  • y1 (float) – y coordindate of first point defining a triangle

  • x2 (float) – x coordindate of second point defining a triangle

  • y2 (float) – y coordindate of second point defining a triangle

  • x3 (float) – x coordindate of third point defining a triangle

  • y3 (float) – y coordindate of third point defining a triangle

Returns

  • x (float) – x coordinate of triangle’s centroid

  • y (float) – y coordinate of a triangle’s centroid

armi.utils.triangle.checkIfPointIsInTriangle(x1, y1, x2, y2, x3, y3, x, y)[source]

Test if a point defined by x,y coordinates is within a triangle defined by verticies with x,y coordinates.

Parameters
  • x1 (float) – x coordindate of first point of the bounding triangle

  • y1 (float) – y coordindate of first point of the bounding triangle

  • x2 (float) – x coordindate of second point of the bounding triangle

  • y2 (float) – y coordindate of second point of the bounding triangle

  • x3 (float) – x coordindate of third point of the bounding triangle

  • y3 (float) – y coordindate of third point of the bounding triangle

  • x (float) – x coordinate of point being tested

  • y (float) – y coordinate of point being tested

Notes

This method uses the barycentric method. See http://totologic.blogspot.com/2014/01/accurate-point-in-triangle-test.html