You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
And the custom code's answer is correct. Here's the code for that:
polygonArea = function(verts)
area = 0.0
n = verts.len
j = n - 1
for i in range(0,n-1)
area += (verts[j][0] + verts[i][0]) * (verts[j][1] - verts[i][1])
j = i
end for
return abs(area / 2.0)
end function
The text was updated successfully, but these errors were encountered:
This came up as part of Advent of Code 2023, Day 18.
Given this polygon:
...we get different answers using the built-in mathUtil.polyArea than we do with custom code implementing the Shoelace algorithm:
And the custom code's answer is correct. Here's the code for that:
The text was updated successfully, but these errors were encountered: