Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
quadrilateralareascoordinates.py
def calculate_area(c):
'''
Calculates the area of any quadrivaletral
from a list of x,y coordinates in the following format:
[[x1,y1],[x2,y2],[x3,y3],[x4,y4]]
'''
first = c[0][0]*c[1][1] + c[1][0]*c[2][1] + c[2][0]*c[3][1] + c[3][0]*c[0][1]
second = c[1][0]*c[0][1] + c[2][0]*c[1][1] + c[3][0]*c[2][1] + c[0][0]*c[3][1]
area = 0.5*(first - second)
return area
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment