Comments (5)
@eranimo , this request is pretty old, but as ticket is still open, I document it for documentation's sake.
I wrapped this library in a higher level one using a cell class, where I created links to previous and next edges, this greatly facilitates circular drawing algorithms such as SVG paths creation
I import the cells in a new class
from_rhill_cell(c){
this.seed = c.site
this.edges = []
for(let i=0;i<c.halfedges.length;i++){
const he = c.halfedges[i]
let [v1,v2] = ccw_vertices(he)
let edge = {v1:v1,v2:v2}
edge.l = he_length(he)
edge.c = center(edge.v1,edge.v2)
edge.a = c.halfedges[i].angle
this.edges.push(edge)
}
}
then I create links to neighbors, on edge level though, not on vertex level, but if you need a neighboring vertex you simply then need to loop through edges, take prev next edge and using v1 only
add_prev_next(edges){
for(let i=0;i<edges.length;i++){
let edge = edges[i]
edge.prev = (i==0)?edges.slice(-1)[0]:edges[i-1]
edge.next = (i==edges.length-1)?edges[0]:edges[i+1]
}
}
more here in case of interest of the details in the full integration
from javascript-voronoi.
When you say "adjacent vertices", do you mean the vertices linked through the same edges?
from javascript-voronoi.
yes, all the vertices linked through the edges that end/start from this vertex.
Like : http://en.wikipedia.org/wiki/Adjacency_list
from javascript-voronoi.
That would be possible with a somewhat complicated algortihm, using the fact that from a cell's halfedge one can get the other cell sharing the halfedge, and from there finding which other halfedge shares the vertex, etc. until all cells sharing the vertex have been processed.
Theoritically I could put code in the core algorithm in order for each vertex to keep a list of back references to all edges which refer to the vertex, but thinking of the impact on performance I would rather not do that.
from javascript-voronoi.
@gorhill you could make it a function on the Edge class. If you want to loop over all edges it's required to have this sort of functionality. I'm doing something similar to what you suggested but it's not working because I can't look up the edges by vertex reliably -- some times they're not found
from javascript-voronoi.
Related Issues (20)
- Duplicate vertices on bounding box HOT 6
- Feature request: segment as site HOT 1
- publish to npm HOT 2
- main branch version tag is missing HOT 1
- Get Cell vertices ordered clockwise or counter clockwise HOT 2
- closeCells() fails with "this makes no sense!" exception HOT 2
- point intersection fails with some cells due to 0 length edges HOT 1
- No edge or halfedges are created HOT 4
- How could I get the center point in the polygon?
- Add ``Point`` as a public object in documentation HOT 2
- ES2017 HOT 1
- Can't directly deal with Northern Hemisphere latitudes HOT 1
- Site Cell missmatch? HOT 3
- How would one check if a point is within a given cell?
- mixing text and floats can cause wrong operations on user's code HOT 8
- Uncaught TypeError: Cannot read property 'rbRed' of null (line 316)
- Readme uses incorrect order for compute()
- Tip: You can pass through extra data with your sites coords, that is then in cells sites output. HOT 1
- LICENSE HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from javascript-voronoi.