Calculate the area of a quadrilateral
Based on https://en.wikipedia.org/wiki/Brahmagupta%27s_formula
see https://www.geeksforgeeks.org/maximum-area-quadrilateral/
def maxArea (a , b , c , d ):
# Calculating the semi-perimeter
# of the given quadilateral
semiperimeter = (a + b + c + d) / 2
# Applying Brahmagupta's formula to
# get maximum area of quadrilateral
return math.sqrt((semiperimeter - a) *
(semiperimeter - b) *
(semiperimeter - c) *
(semiperimeter - d))
Just access the sides and angles directly in the two lists you have:
import math
area1 = 0.5 * self.sides[0] * self.sides[1] * math.sin(math.radians(self.angles[1]))
area2 = 0.5 * self.sides[2] * self.sides[3] * math.sin(math.radians(self.angles[3]))
area = area1 + area2
Given your example as sides = [3, 5, 5, 4]
and angles = [90, 95, 75, 100]
, the area then is:
>>> import math
>>> sides = [3, 5, 5, 4]
>>> angles = [90, 95, 75, 100]
>>> area1 = 0.5 * sides[0] * sides[1] * math.sin(math.radians(angles[1]))
>>> area2 = 0.5 * sides[2] * sides[3] * math.sin(math.radians(angles[3]))
>>> area1 + area2
17.31953776581017