Anonymous user
Shoelace formula for polygonal area: Difference between revisions
Shoelace formula for polygonal area (view source)
Revision as of 07:00, 27 December 2020
, 3 years ago→{{header|Python}}
Line 1,250:
# Even simpler:
# In python we can take an advantage of that x[-1] refers to the last element in an array, same as x[N-1].
# Introducing the index i=[0,1,2,...,N-1]; i-1=[-1,0,...,N-
# Thus x[i] is a sequence of the x-coordinate of the polygon vertices, x[i-1] is the sequence shifted by 1 index.
# Note that the shift must be negative. The positive shift x[i+1] results in an error: x[N] index out of bound.
|