title: Intersection of two lines defined in (rho/theta ) parameterization
body: <p>Have created a c++ implementation of the Hough transform for detecting lines in images. Found lines are represented using rho, theta, as described on wikipedia:</p>
  
  <blockquote>
    <p>"The parameter r represents the distance between the line and the origin, while θ is the angle of the vector from the origin to this closest point "</p>
  </blockquote>
  
  <p>How can i find the intersection point in x, y space for two lines described using r, θ?</p>
  
  <p>For reference here are my current functions for converting in and out of hough space:</p>
  
  <pre><code>//get 'r' (length of a line from pole (corner, 0,0, distance from center) perpendicular to a line intersecting point x,y at a given angle) given the point and the angle (in radians)
  inline float point2Hough(int x, int y, float theta) {
      return((((float)x)*cosf(theta))+((float)y)*sinf(theta));
  }
  
  //get point y for a line at angle theta with a distance from the pole of r intersecting x? bad explanation! &gt;_&lt;
  inline float hough2Point(int x, int r, float theta) {
      float y;
      if(theta!=0) {
              y=(-cosf(theta)/sinf(theta))*x+((float)r/sinf(theta));
      } else {
              y=(float)r; //wth theta may == 0?!
      }
      return(y);
  }
  </code></pre>
  
  <p>sorry in advance if this is something obvious..</p>