Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Area of a convex polygon solution in Uncategorized category for Area of a Convex Polygon by capback250
import math
from itertools import combinations
def sides(pair):
return math.hypot(pair[1][0]-pair[0][0], pair[1][1]-pair[0][1])
def geron(list_lengs):
p = sum(list_lengs)/2
s = math.sqrt(p * (p - list_lengs[0]) * (p - list_lengs[1]) * (p - list_lengs[2]))
return s
def checkio(points):
firts_point = points[0]
s = 0
for x in range(1, len(points)-1):
lengs = []
for i in combinations((firts_point, points[x], points[x+1]), 2):
lengs.append(sides(i))
s += geron(lengs)
return s
Nov. 10, 2015