Anonymous user
Shoelace formula for polygonal area: Difference between revisions
Shoelace formula for polygonal area (view source)
Revision as of 09:09, 27 February 2021
, 3 years ago→{{header|Python}}
Line 1,262:
Area=np.abs(np.sum(x[i-1]*y[i]-x[i]*y[i-1])*0.5) # one line of code for the shoelace formula
# Remember that applying the Shoelace formula
# will result in a loss of precision if x,y have big offsets.
# Remove the offsets first, e.g.
# x=x-np.mean(x);y=y-np.mean(y)
# or
# x=x-x[0];y=y-y[0]
# before applying the Shoelace formula.
|