My function is made to get the area of any arbitrary triangle.
Here is the way that I know works
def areaOfTriangle(vertices):
x1 = vertices[0][0]
y1 = vertices[0][1]
x2 = vertices[1][0]
y2 = vertices[1][1]
x3 = vertices[2][0]
y3 = vertices[2][1]
area = (1.0/2.0)*(x2*y3 - x3*y2 - x1*y3 + x3*y1 + x1*y2 - x2*y1)
return area
However, I think this is crap so here's what I had as a sketched out thought,
def areaOfTriangle(vertices):
coord1 = vertices[0]
coord2 = vertices[1]
coord3 = vertices[2]
for x1,y1 in coord1:
for x2, y2 in coord2:
for x3, y3 in coord3:
area = (1.0/2.0)*(x2*y3 - x3*y2 - x1*y3 + x3*y1 + x1*y2 - x2*y1)
return area
However, this apparently doesn't play too nice with lists. I thought this would work in the way that once can get keys and values from dictionaries...but lists don't have the iteritems() method. Then I thought about converting the lists into dictionaries, but the keys are unique in dicts and hence they only pop up once....which would make my function not work properly.