title: Nearest neighbor search for points with directional vectors caveat
body: <p>I have a set of 3D points, each of which is associated with a direction (e.g. a unit vector). Given another point + direction I would like to figure out the closest point in the set (using standard 2-norm) that also satisfies a certain condition on direction vectors (e.g. the angle between the two direction vectors is within a certain angular amount). So far I have a KD-tree based range search on the 3D points and then check whether any of such points fit within the angular constraints, but realize this is a highly unoptimized hack. Was wondering if there's an obvious better way to do this.</p>
  
  <p>Many thanks in advance.</p>