Shoelace formula for polygonal area: Difference between revisions
Content added Content deleted
m (→{{header|Python}}: Minor rearrangement for symmetry, legibility) |
|||
Line 910: | Line 910: | ||
30.0 |
30.0 |
||
>>> </lang> |
>>> </lang> |
||
Or, defined in terms of '''reduce''' and '''cycle''': |
Or, defined in terms of '''reduce''' and '''cycle''': |
||
Line 924: | Line 925: | ||
'''Area of polygon with vertices |
'''Area of polygon with vertices |
||
at (x, y) points in xys.''' |
at (x, y) points in xys.''' |
||
def go(a, tpl): |
def go(a, tpl): |
||
⚫ | |||
l, r = a |
l, r = a |
||
⚫ | |||
return (l + x * dy, r + y * dx) |
return (l + x * dy, r + y * dx) |
||
(nl, nr) = reduce( |
(nl, nr) = reduce( |
||
go, |
go, |