I'm trying to create a calculator which calculates the area of a simple quadrilateral. I know that every quadrilateral can be split into two triangles, and I should be able to calculate the area in two parts no matter what. I am able to do this in math, but I don't know how to implement it to Python.
Here's my quadrilateral class:
class Quadrilateral(Shape):
def __init__(self, name):
# in clockwise order: angles[0], sides[0], angles[1], sides[1], ...
self.sides = [5] * 4
self.angles = [90] * 4
super().__init__(self, name)
Now what I need is to implement a method get_area()
which calculates the area of my quadrilateral, but I have no idea how.
Here's how I would do it with a paper and a pen:
Basically I would only need to know two angles and three sides to be able to use this technique to calculate the area, but let's not worry about that. For now, I know all the angles and all the sides, how do I calculate the area?