area_polygon 1.0.2 copy "area_polygon: ^1.0.2" to clipboard
area_polygon: ^1.0.2 copied to clipboard

Calculate the area of a simple 2D polygon given its vertices. A Dart port of the area-polygon npm package.

Calculate the area of a simple 2D polygon given its vertices.

This is a port of the math-utils/area-polygon library written in JavaScript.

Usage #

List<Offset> points = [
    // your points here, e.g. a 4x4 square:
    Offset(0, 0),
    Offset(0, 4),
    Offset(4, 4),
    Offset(4, 0),
];
double area = calculateArea(points); // 16
print('Area: $area');

The points must also trace the edge of the polygon. The last point is assumed to be connected to the first point.

If signed is true, this will return the signed area. This is helpful to determine the orientation of points.

Signed area is positive if the points are counter-clockwise, or negative if the points are clockwise.

1
likes
160
points
46
downloads

Publisher

verified publisheradil.hanney.org

Weekly Downloads

Calculate the area of a simple 2D polygon given its vertices. A Dart port of the area-polygon npm package.

Repository (GitHub)
View/report issues

Topics

#math #polygons #js-port

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on area_polygon