Giter VIP home page Giter VIP logo

Comments (8)

mourner avatar mourner commented on July 24, 2024

It's a pretty uncommon use case, but I'd like to make RBush support it too. Can you set up the most minimal test case that reproduces the problem so that I can look into fixing it faster?

from rbush.

mourner avatar mourner commented on July 24, 2024

hey @Pieter-Jan, any updates?

from rbush.

Pieter-Jan avatar Pieter-Jan commented on July 24, 2024

Hey @mourner thanks for taking interest in this issue!

I read some more about R-trees and realised that my problem is very hard to support by an R-tree. I was unable to create a "minimal" situation where this issue started occurring in Rbush but I did notice that jsts' strtree dynamically enlarges the number of children for the "nodes" when I feed the same data (this takes a lot of time). I am not sure what they do next because the performance is still beter than a complete search. This suprises me, because the bounding box of an infinitely long line is infinite as well.

To give you a perspective, I am trying to come up with a way to improve the performance of "snapping to objects" in a drawing tool (like powerpoint, ...) where there are >1000 objects.

from rbush.

mourner avatar mourner commented on July 24, 2024

@Pieter-Jan nice use case! I think the best way to approach this would be to have 2 separate 1D binary search trees — one for X axis and one for Y axis. Search for the nearest neighbor is trivial in such case, and you would just do 2 o(log N) lookups that would be pretty much instant (even with a million objects) to find the snapping lines.

from rbush.

IvanSanchez avatar IvanSanchez commented on July 24, 2024

I think there might be an edge case when a bbox is infinite on only one side of one axis, i.e. { minx: 0, maxx: Infinity, miny: -10, maxy: 10 }.

Granted, it's not what the initial query is about, but might be important to take into account when approaching similar problems.

from rbush.

Pieter-Jan avatar Pieter-Jan commented on July 24, 2024

Hey @mourner Yes that would be great! Unfortunately I realised recently that we should support snap lines in any direction so I am still looking for a better solution :).

from rbush.

mourner avatar mourner commented on July 24, 2024

@Pieter-Jan maybe you should still try the 1D BSP approach, but have a BSP for every unique angle value. It's unlikely that angles will vary too much on one scene.

from rbush.

mourner avatar mourner commented on July 24, 2024

I'm sure you can do away with a linear loop though. Doing a 1000 point to line distance calculations per frame is nothing for a modern browser.

from rbush.

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.