title: Find the presence of other turtles in a given direction upto a distance
body: <p>I wish to find out whether in a given turtle's heading there is another agent present upto a given distance.<img src="https://i.stack.imgur.com/tTnwc.png" alt="enter image description here"></p>
  
  <p>Here the Distance is "D". </p>
  
  <p><strong>Note:</strong> </p>
  
  <p>Any agent present before D in the given direction should be also considered.</p>
  
  <p>Even the direction doesn't coincide with the other's agent centre but just touches it ,even then that agent should be considered.</p>
  
  <p><strong>Problem:</strong></p>
  
  <p>No turtle-ahead procedure available. Combination of patch-ahead and turtles-on not applicable due to patch-size>> turtle-size.
  <img src="https://i.stack.imgur.com/fmtTz.png" alt="enter image description here">
  <strong>Possible approach:</strong>
  1.Represent the turtle's heading by the equation of a line.</p>
  
  <pre><code>to-report calculate-line[x y angle]
    let m tan angle
    let A m 
    let B -1 
    let C (- m * x + y) 
  report (list A B C)
  end
  to-report heading-to-angle [ h ]
    report (90 - h) mod 360
  end
  </code></pre>
  
  <blockquote>
    <p>let line-equ calculate-line (xcor) (ycor) (heading-to-angle heading)</p>
  </blockquote>
  
  <p>2.Calculate the perpendicular distance from other turtles here, Check if there are within a range that the size of other turtles.</p>
  
  <pre><code>to-report value[A X1 Y1];;A is list of coefficents of line, x1 and y1 are coordinates of red turtle
    if-else(abs((item 0 A * X1 + item 1 A * Y1 + item 2 A) / (sqrt((item 0 A ^ 2) + (item 1 A ^ 2) ))) &lt; [size] of wall )
   [ report "true"][report "false"]
  </code></pre>
  
  <p>end</p>
  
  <p>3.To check if the red turtle is within D. One could obtain a line perpendicular to black one and compute the red turtle distance from it to check if it is less than or equal to D. But then that adds more complication.(Though one can simplify rotate the turtle by 90 left or right and get the line equation.)</p>