title: Line intersections for diagonals on a 2d plane in C#
body: <p>Assume a 2D grid with the top left cell as (0, 0). Pick any two points/coordinates and draw a diagonal and anti-diagonal on each. They may intersect inside or outside the grid.</p>
  
  <p>In the picture attached, the red lines are diagonals to the two points (300, 200) and (700, 800).</p>
  
  <p>How can I find out the coordinates for the diagonal intersections? Also, how would the formula differ if the slope of the line were negative?</p>
  
  <p>I will use this in an algorithm that needs to be highly optimized so the right answer would be the fastest possible way to compute. I'm not sure if this can be done without trignometry.</p>
  
  <p><strong>NOTE:</strong>
  Please keep in mind that the red lines are a true diagonal/anti-diagonal pair. In other words they are at 45 degree angles to the rectangle. This may or may not help select a more optimized formula than vector calculation.</p>
  
  <p><img src="https://i.stack.imgur.com/KgXe1.png" alt="enter image description here"></p>