Code Monkey home page Code Monkey logo

Comments (8)

racc avatar racc commented on August 24, 2024

At the moment, I am storing Lines and Ellipses by their bounding Rectangle. This works, but it isn't optimal.
Also, doing things like rectangular selection of shapes doesn't work properly as the selection box hits areas where the line doesn't reside (as the bounding Rectangle is hit).

from rtree.

davidmoten avatar davidmoten commented on August 24, 2024

rtree really only has first class support for Point and Rectangle because an R-tree works under the covers on Rectangles.

For other geometries (like Circle) the search method is this method. Signature is:

public <R extends Geometry> Observable<Entry<T, S>> search(final R g,
            final Func2<? super S, ? super R, Boolean> intersects);

You can see that you have to provide your own intersects method. For Circles the Intersects class has implementations for testing intersection with other geometries. To add useful support for Line and Ellipse then we need to add static methods to the Intersects class for every pair from {Circle, Rectangle, Point, Line, Ellipse}. Contributions welcome!

from rtree.

racc avatar racc commented on August 24, 2024

Ok well Ellipse might be tricky but Line shouldn't be too hard surely 😛
...well at least theoretically it is possible to implement.

from rtree.

racc avatar racc commented on August 24, 2024

http://stackoverflow.com/questions/15514906/how-to-check-intersection-between-a-line-and-a-rectangle
http://stackoverflow.com/questions/1073336/circle-line-segment-collision-detection-algorithm

Alternatively there are libraries which can do these calculations:
e.g. http://sourceforge.net/projects/geom-java/

As you can tell I'm pretty lazy so it's unlikely that I'd seek to implement the intersection functions myself.

from rtree.

davidmoten avatar davidmoten commented on August 24, 2024

Thanks for the links. I agree Line wouldn't be hard.

from rtree.

davidmoten avatar davidmoten commented on August 24, 2024

I've just noticed that Intersects.circleIntersectsCircle is missing so I'll add that now.

from rtree.

sevar83 avatar sevar83 commented on August 24, 2024

Hi, I've just stumbled upon this library. Looks very cool! I could suggest to use JTS Geometry.getEnvelope() function obtaining rough bounding box intersections that works for all types of geometries. For a real (and slower) intersection Geometry.intersects() method could be used.

from rtree.

davidmoten avatar davidmoten commented on August 24, 2024

Hi, thanks for that. I'll probably avoid explicitly supporting more
geometries and leave them for people to apply the approach of custom
geometries mentioned in the README. The JTS libs are definitely useful in
this regard.

On Thu, 5 May 2016 00:36 sevar83 [email protected] wrote:

Hi, I've just stumbled upon this library. Looks very cool! I could suggest
to use JTS Geometry.getEnvelope() function obtaining rough bounding box
intersections that works for all types of geometries. For a real (and
slower) intersection Geometry.intersects() method could be used.


You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#31 (comment)

from rtree.

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.