I created an instance and listed two calculation results, the result of `planarArea` is 20423.311146823657, and the result of `Sholace formula` is 20423.328125, the difference is -0.016978176343400264, why is this?
https://codepen.io/yujinpan/pen/BaYwLPG?editors=1001
Here is my calculation.
// Shoelace formula
let total = 0;
coordinates.forEach(([x, y], index, arr) => {
const [nextX, nextY] = arr[index + 1] || arr[0];
total += (x*nextY - nextX*y)*0.5;
});
Solved! Go to Solution.
if the units are meters, then the difference is about 2 millimeters squared over a total area 20 thousand-ish meters squared.
floating point precision and/or math package differences
different methods of calculating area
shoelace doesn't know about coordinate systems
some possibilities.
if the units are meters, then the difference is about 2 millimeters squared over a total area 20 thousand-ish meters squared.
floating point precision and/or math package differences
different methods of calculating area
shoelace doesn't know about coordinate systems
some possibilities.