Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Clever way to do this?

Options
  • 07-06-2015 8:59am
    #1
    Registered Users Posts: 3,608 ✭✭✭


    I have a cloud of points in 3D space. Pairs of these points are connected to form a cloud of lines. There are some cases where the end point of one line lies directly on another line segment and I want to identify all of these cases.

    I've written a function which can check if a point lies on a line segment. I then take each line in term and loop through all of the points, checking if any are on that line. Then I move to the next line and so on. Something like the following pseudo code:
    For each line in lines
         For each point in points
              Check if point is on line
    

    This is fine for a limited set of points/lines but it takes a very long time to run on the entire point cloud because I'm checking every single point against every single line. Can anyone think of a clever way to implement this for faster speed of execution?

    Thanks


Comments

  • Registered Users Posts: 2,022 ✭✭✭Colonel Panic


    The key here is spacial partitioning, for 3D points, you could look at an octree.


  • Registered Users Posts: 3,608 ✭✭✭breadmonkey


    Thanks for that. It looks interesting but will take me a while to get my head around it. Might be back with some questions!


  • Registered Users Posts: 2,022 ✭✭✭Colonel Panic


    Thanks for that. It looks interesting but will take me a while to get my head around it. Might be back with some questions!

    Get you head around how to insert date into a binary tree first before you add another 6 children per node to the mix!


Advertisement