MCPcopy Create free account
hub / github.com/davisking/dlib / polygon_area

Function polygon_area

dlib/geometry/vector.h:1382–1399  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1380 typename array_of_dpoints
1381 >
1382 inline double polygon_area (
1383 const array_of_dpoints& pts
1384 )
1385 {
1386 if (pts.size() <= 2)
1387 return 0;
1388
1389 double val = 0;
1390
1391
1392 for (size_t i = 1; i < pts.size(); ++i)
1393 val += (double)pts[i].x()*pts[i-1].y() - pts[i].y()*pts[i-1].x();
1394
1395 const size_t end = pts.size()-1;
1396 val += (double)pts[0].x()*pts[end].y() - pts[0].y()*pts[end].x();
1397
1398 return std::abs(val)/2.0;
1399 }
1400
1401// ----------------------------------------------------------------------------------------
1402

Callers 3

py_polygon_areaFunction · 0.85
py_polygon_area2Function · 0.85
areaMethod · 0.85

Calls 2

absFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected