Quantcast
Channel: bugs, errors - openFrameworks
Viewing all articles
Browse latest Browse all 636

ofPolyline.getArea() calculation

$
0
0

@konstantin wrote:

I’m getting negative values trying to get area of a polyline - the algorithm works fine on paper, but produces negative values when running. Am I missing something fundamental?

        // area
        for(int i=0;i<(int)points.size()-1;i++){
            area += points[i].x * points[i+1].y - points[i+1].x * points[i].y;
        }
        area += points[points.size()-1].x * points[0].y - points[0].x * points[points.size()-1].y;
        area *= 0.5;

Posts: 3

Participants: 3

Read full topic


Viewing all articles
Browse latest Browse all 636

Trending Articles