title: How to limit search space using 2D rectangular buffer along a 2d line segment
body: <p>I have 2D line segments extracted from an image. So i know end point coordinates of them. also, i have some reference 2d line segments. Both line segments are now in vector form. comparing to reference and extracted lines,I have huge amount of extracted lines segments. </p>
  
  <p>What i want to do is to find conjugate line segment for each reference line from my extraction. that is I want to match line segments. But, to reduce the search area i wish to limit it in such a way that by defining a buffer zone around a reference line segment. </p>
  
  <blockquote>
    <p>(1) My first question is how can i implement this buffer case with c++ as i am lacking with geometric theories.</p>
  </blockquote>
  
  <p>Note: I dont want to use a bounding box and looking for a rectangular buffer which orient along the reference line. </p>
  
  <blockquote>
    <p>(2) my second question is, if i know the rectangular buffer limits, then which type of concept should i use to  avoid unnecessary searches of line segments.</p>
  </blockquote>
  
  <p>Actually, I am looking a geometric base method</p>
  
  <p>please do not think this as home work and i am really struggling because of my poor mathematics.
  thanks in advance.</p>
  
  <p>Please look at the example. if i take bounding box (blue box) unnecessary lines come, if it is a buffer rectangle (red), which is oriented to main reference line (dark black) few lines come. </p>
  
  <p>black line is - reference line and dashed lines are image based extracted lines</p>
  
  <p><img src="https://i.stack.imgur.com/l4Gnt.jpg" alt="enter image description here"></p>