Area of polygons

An example showing limits of this two methods, result is false for any fill-rule!

Two methods

1) Using triangles from any point, and with points pair as vertices.
Area is calculated with vectorial product, result is positive or negative.

2) Using trapeze, with base on x-axis and points pair as vertices. 
Area is calculated by base*(y1+y2)/2, result is positive or negative

Final result is positive or negative, it depends of order for points.

On SVG picture, positive area is yellow and negative area is red.


Get coordinates of points:
points=obj.getAttribute("points");coordo=points.split(" ");
In array coordo, you can have empty values ( CR, two or more spaces ), you must eliminate them.

p0=coordo[j].split(",");x1=p0[0];y1=p0[1]; give coordinates xi and yi

First method

area=area+(x1*y2-x2*y1)/2; if common vertice is ( 0 ; 0 )
Second method

Don't forget to take again first point to close