| 8 | } |
| 9 | |
| 10 | void test() { |
| 11 | /* Field testing: Kattis pointinpolygon, Kattis forest, Kattis polygongame, UVa 11030, UVa 634 */ |
| 12 | |
| 13 | polygon pts; |
| 14 | pts.push_back(point(1, 1)); |
| 15 | pts.push_back(point(1, 4)); |
| 16 | pts.push_back(point(4, 4)); |
| 17 | pts.push_back(point(4, 1)); |
| 18 | |
| 19 | assert_nearly_equal(-9.0, polygon_area_signed(pts)); |
| 20 | assert_nearly_equal(9.0, polygon_area(pts)); |
| 21 | |
| 22 | reverse(pts.begin(), pts.end()); |
| 23 | |
| 24 | assert_nearly_equal(9.0, polygon_area_signed(pts)); |
| 25 | assert_nearly_equal(9.0, polygon_area(pts)); |
| 26 | |
| 27 | pts.clear(); |
| 28 | pts.push_back(point(1, 1)); |
| 29 | pts.push_back(point(1, 4)); |
| 30 | pts.push_back(point(2, 2)); |
| 31 | pts.push_back(point(4, 1)); |
| 32 | |
| 33 | assert_nearly_equal(-3.0, polygon_area_signed(pts)); |
| 34 | assert_nearly_equal(3.0, polygon_area(pts)); |
| 35 | |
| 36 | } |
| 37 | // vim: cc=60 ts=2 sts=2 sw=2: |
nothing calls this directly
no test coverage detected