You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The KDtree queries should allow to return the indices of the points instead of the coords.
Do you think this implementation could be easily updated for this feature or the structure is incompatible with idices tracking?
Help make it happen!
I am not willing to submit a PR to implement this change.
The text was updated successfully, but these errors were encountered:
Hello @edwinRNDR ,
We would also be interested in this kind of feature since for us finding which index corresponds to the outputed nearest neighbors x,y,z is not stable and a pain at the moment. It would be much more efficient and stable if the lib could return the indexes.
Any chance this could be added to the lib?
Cheers
Hey. I will have a look at getting that functionality in but I have limited capacity to get this done.
In case you need a quick solution that's relatively inexpensive you can use a hash map.
importorg.openrndr.applicationimportorg.openrndr.extra.kdtree.kdTreeimportorg.openrndr.extra.noise.scatterfunmain() {
application {
program {
val p = drawer.bounds.scatter(100.0)
val kd = p.kdTree()
val indices = p.withIndex().associate { it.value to it.index }
extend {
val nearestIndices = kd.findKNearest(mouse.position, 3).map { indices[it] ?: error("mystery point") }
}
}
}
}
Thank you @edwinRNDR , we were getting unstable hashmap due to the key we were using (we tried using maps of maps with double as key and we also tried to have a list of double as key) but we didn't try a data class with the x,y,z.
We tested your map approach and it is super stable thanks to the data class hashcode stability.
Thank you for your quick response this was very helpful.
Cheers!
PS: I can help contribute to this repo to add the indices, won't have time now but in a few months I will be more free to contribute.
Motivation
The KDtree queries should allow to return the indices of the points instead of the coords.
Do you think this implementation could be easily updated for this feature or the structure is incompatible with idices tracking?
Help make it happen!
I am not willing to submit a PR to implement this change.
The text was updated successfully, but these errors were encountered: