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).

1  
lib 1400536 // Voronoi
2  
3  
static L<DoubleEdge> voronoiEdges(int w, int h, L<DoublePt> points) {
4  
  ret voronoiEdges(new WidthAndHeightImpl(w, h), points);
5  
}
6  
7  
static L<DoubleEdge> voronoiEdges(WidthAndHeight size, L<DoublePt> points) {
8  
  double max = max(size.getWidth(), size.getHeight());
9  
  points = scaleDoublePts(points, 1/max);
10  
  var v = new org.ajwerner.voronoi.Voronoi(mapToArrayList(points, p
11  
    -> new org.ajwerner.voronoi.Point(p.x, p.y));
12  
  ret map(v.getEdgeList(), e -> scaleDoubleEdge(max, DoubleEdge(e.p1.x, e.p1.y, e.p2.x, e.p2.y)));
13  
}

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: 93 / 181
Version history: 8 change(s)
Referenced in: [show references]