ekymoz/homeRoughEditor

how did you calculate the area of the room ? can you share with us

Closed this issue · 1 comments

how did you calculate the area of the room ? can you share with us

areaRoom: function (vertex, coords, digit = 2) {
var vertexArray = coords;
var roughArea = 0;
var j = (vertexArray.length)-2;
for (var i = 0; i < vertexArray.length-1; i++) {
roughArea = roughArea + ((vertex[vertexArray[j]].x + vertex[vertexArray[i]].x) * (vertex[vertexArray[j]].y - vertex[vertexArray[i]].y));
j = i;
}
roughArea = roughArea / 2;
return Math.abs(roughArea.toFixed(digit));
}