title: Finding specific shapes in point clouds quickly
body: <p>I've got a point cloud, and would like to detect occurrences of certain patterns of points in my code.</p>
  
  <p>Let's say I have 1000 points in 3d space, and I want to detect all instances of 3 points which form an 'L' shape where each segment of the L has a specific length. The point cloud may not have exact matches, but may be very close (i.e. in the point cloud, the length of a segment of 'L' may be slightly longer/shorter than the ideal)</p>
  
  <p>My initial idea was something like this:</p>
  
  <ol>
  <li>record the distance between all the points in the shape we are trying to detect</li>
  <li>create an empty 'potential shape'</li>
  <li>for each point in our potential shape, examine all points that are at/near the distances found in part 1)</li>
  <li>If we find a point, add it to our potential shape, and repeat part 3) until we have all the points. Then check the angles between the points to verify that the shape is indeed correct. If not correct, we go on to the next point and start again</li>
  </ol>
  
  <p>The problem is that this approach has a terrible worst case running time. Ideally, I would like to have some kind of data structure to speed up my queries for 'Find all points that are between distanceMin and distanceMax away from the given point. Can someone point me to some useful data structures that might help.</p>
  
  <p>I was thinking of putting all the points in an octree to speed up access time.</p>
  
  <p>Any other advice on how to improve the running time? Heuristics to speed things up?</p>
  
  <p>Note: The shapes I'm trying to find are variable. They will not always be an 'L'. I tried looking at hough transforms, but they seem to be useful only for detecting specific predetermined shapes like lines/circles.</p>