Skip to content

Commit

Permalink
Change pointsOfTriangle to return point ids, more useful
Browse files Browse the repository at this point in the history
* Previously pointsOfTriangle returned point x,y but it's more useful
  to return point ids so that it can be used for traversing the graph.
  • Loading branch information
redblobgames authored and mourner committed Aug 28, 2018
1 parent 9334203 commit 804e51d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,14 @@ <h3>Constructing triangles</h3>
<script id="triangle-to-points">
function edgesOfTriangle(t) { return [3*t, 3*t+1, 3*t+2]; }

function pointsOfTriangle(points, delaunay, t) {
function pointsOfTriangle(delaunay, t) {
return edgesOfTriangle(t)
.map(e => points[delaunay.triangles[e]]);
.map(e => delaunay.triangles[e]);
}

function forEachTriangle(points, delaunay, callback) {
for (let t = 0; t < delaunay.triangles.length / 3; t++) {
callback(t, pointsOfTriangle(points, delaunay, t));
callback(t, pointsOfTriangle(delaunay, t).map(p => points[p]));
}
}
</script>
Expand Down Expand Up @@ -246,7 +246,7 @@ <h3>Triangle circumcenters</h3>

<script>
function triangleCenter(points, delaunay, t) {
let vertices = pointsOfTriangle(points, delaunay, t);
let vertices = pointsOfTriangle(delaunay, t).map(p => points[p]);
return circumcenter(vertices[0], vertices[1], vertices[2]);
}
</script>
Expand Down

0 comments on commit 804e51d

Please sign in to comment.