MCPcopy Create free account
hub / github.com/ActiveState/code / PolygonCircumference

Function PolygonCircumference

recipes/Python/578048_IFS_fractal/recipe-578048.py:15–23  ·  view source on GitHub ↗
(corners)

Source from the content-addressed store, hash-verified

13# Circumference of Polygon
14# corners must be ordered in clockwise or counter-clockwise direction
15def PolygonCircumference(corners):
16 n = len(corners) # of corners
17 circumference = 0.0
18 for i in range(n):
19 j = (i + 1) % n
20 dx = corners[j][0] - corners[i][0]
21 dy = corners[j][1] - corners[i][1]
22 circumference += math.hypot(dx, dy)
23 return circumference
24
25##fractalName = "Barnsley Fern"
26##mat=[[0.0, 0.0, 0.0, 0.16, 0.0, 0.0, 0.01],

Callers 1

recipe-578048.pyFile · 0.85

Calls 2

rangeFunction · 0.85
hypotMethod · 0.45

Tested by

no test coverage detected