Closed robincafolla closed 9 years ago
They are always ordered counterclockwise. I use this code in one of the demo to render a polygon on a canvas from a cell:
var halfedges = cell.halfedges,
var nHalfedges = halfedges.length;
var v = halfedges[0].getStartpoint();
ctx.beginPath();
ctx.moveTo(v.x,v.y);
for ( var iHalfedge=0; iHalfedge < nHalfedges; iHalfedge++ ) {
v = halfedges[iHalfedge].getEndpoint();
ctx.lineTo(v.x,v.y);
}
ctx.fillStyle = '#faa';
ctx.fill();
It wouldn't work if they were not ordered.
Cheers, that worked, thanks for the quick response.
Hi there,
Nice library.
I'm trying to get a cell's vertices in clockwise or counter-clockwise order. I've tried
but it doesn't seem to order them properly ( it creates duplicate ). Is there a way to do this?