[Algorithm] Area of polygon

How to calculate the area of polygon. For a triangle like:

We can calculate the area:

function cross_product(a, ,b) {
    return a.x * b.y - a.y * b.x
}
function area (a, b) {
   cross_product(a, b) / 2.0
}

This approach is able to solve all simple polygon areas problem:

猜你喜欢

转载自www.cnblogs.com/Answer1215/p/10887200.html