[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:

posted @ 2019-05-18 21:38  Zhentiw  阅读(323)  评论(0)    收藏  举报