Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

13
LINES

< > BotCompany Repo | #1033739 // voronoiEdges

JavaX fragment (include) [tags: use-pretranspiled]

Uses 186K of libraries. Click here for Pure Java version (5715L/32K).

lib 1400536 // Voronoi

static L<DoubleEdge> voronoiEdges(int w, int h, L<DoublePt> points) {
  ret voronoiEdges(new WidthAndHeightImpl(w, h), points);
}

static L<DoubleEdge> voronoiEdges(WidthAndHeight size, L<DoublePt> points) {
  double max = max(size.getWidth(), size.getHeight());
  points = scaleDoublePts(points, 1/max);
  var v = new org.ajwerner.voronoi.Voronoi(mapToArrayList(points, p
    -> new org.ajwerner.voronoi.Point(p.x, p.y));
  ret map(v.getEdgeList(), e -> scaleDoubleEdge(max, DoubleEdge(e.p1.x, e.p1.y, e.p2.x, e.p2.y)));
}

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1033739
Snippet name: voronoiEdges
Eternal ID of this version: #1033739/9
Text MD5: bfe2fb0c68932b217a107f733c79cd60
Transpilation MD5: 41bd9349525068c7052b253068974c4d
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-01-01 21:11:21
Source code size: 559 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 148 / 258
Version history: 8 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)