d3/d3-polygon

Why is Polygon.hull() result not counterclockwise ?

Kcnarf opened this issue · 2 comments

The test below shows that the expected result is clockwise, not counterclockwise as mention in the documentation.

test.deepEqual(polygon.polygonHull([[200, 200], [760, 300], [500, 500]]), [[760, 300], [200, 200], [500, 500]]);

Is it due to the fact that the y-axis direction of SVGs is going down the screen, and hence inverting some common computation results ?

Yes; D3 uses the default coordinate system of Canvas and SVG, which is +x pointing right and +y pointing down.

Fine. Thanks for your clarification.

I will refactor the d3-weighted-voronoi (and subsequently d3-voronoi-map/d3-voronoi-treemap) plugin in order to fulfill this convention.