| |
- distance(point_1, point_2)
- Computes the cartesian distance between two points.
>>> distance((0,0), (5,0))
5.0
- heron(a, b, c)
- Uses the heron formula to calculate the area
of the triangle where `a`,`b` and `c` are the side
lengths.
>>> heron(3, 4, 5)
6.0
>>> heron(7, 10, 5).__round__(2)
16.25
- polygon_area(polygon)
- Calculates the area of an n-sided polygon by
decomposing it into triangles. Input must be
a list of points.
>>> polygon_area([(0,0), (0,5), (3,0), (3, 5)])
15.0
- pytagoras(a, b)
- Given the cathets finds the hypotenusas.
>>> pytagoras(3, 4)
5.0
- triangle_area(triangle)
- Wraps `heron` by allowing points inputs instead
of sides lengths inputs.
>>> triangle_area([(0,0), (0,3), (4,0)])
6.0
- triplets(list_)
- Yields items from a list in groups of 3.
>>> list(triplets(range(6)))
[(0, 1, 2), (1, 2, 3), (2, 3, 4), (3, 4, 5)]
|