0
how to calculate the perimeter of an irregular polygon
how to calculate the perimeter of an irregular polygon
3 Antworten
+ 1
It actually depends on what data you are given with.
If you are given vertices calculate the length of lines and add them.
here is how you can calculate distance between (4,0) and (6,6):
import math
p1 = [4, 0]
p2 = [6, 6]
distance = math.sqrt( ((p1[0]-p2[0])**2)+((p1[1]-p2[1])**2) )
print(distance)
0
perimeter = 0
for side_length in irregular_polygon:
perimeter += side_length
print(perimeter)