Closed CarpeNecopinum closed 4 years ago
Wondering how I managed to seemingly decrease test coverage by submitting a fully covered method and a test for a previously non-covered method. ¯\(ツ)/¯ Hope that isn't a deal-breaker.
Looks good to me :) @sjkelly, any comments?!
Just noticed my 3d variant can't do non-convex polygons, so I WIPed this PR until I get around to fixing that and adding a test for it. Okay, done.
While the signature of
area(contour)
accepts points of any dimension as polygon to compute the area of, the implementation doesn't generalize to dimensions larger than 2.In particular, computing the area of a 3d polygon returns a 3d point as "area" (due to the cross-product returning a vector rather than a scalar for 3d):
This PR thus constrains the existing implementation to 2d points and implements a variant of the algorithm that works for (approximately planar) 3d polygons as well (for non-planar polygons the area depends on the triangulation, so there is no general answer).
I also added 2 test cases.