Coder Social home page Coder Social logo

Comments (3)

edwinRNDR avatar edwinRNDR commented on August 20, 2024 1

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.

import org.openrndr.application
import org.openrndr.extra.kdtree.kdTree
import org.openrndr.extra.noise.scatter

fun main() {
    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") }
            }
        }
    }
}

from orx.

AlexandreBrown avatar AlexandreBrown commented on August 20, 2024

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

from orx.

AlexandreBrown avatar AlexandreBrown commented on August 20, 2024

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.

from orx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.