# Draw the lines detected by cv::HoughLines

On this site(tutorial), it show us how to draw the lines detected by cv::HoughLines,but I can't understand how could it find out the Point between the lines.

```
for( size_t i = 0; i < lines.size(); i++ )
{
float rho = lines[i][0], theta = lines[i][1];
Point pt1, pt2;
double a = cos(theta), b = sin(theta);
double x0 = a*rho, y0 = b*rho;
pt1.x = cvRound(x0 + 1000*(-b)); //??
pt1.y = cvRound(y0 + 1000*(a)); //??
pt2.x = cvRound(x0 - 1000*(-b)); //??
pt2.y = cvRound(y0 - 1000*(a)); //??
line( cdst, pt1, pt2, Scalar(0,0,255), 3, CV_AA);
}
```

Another codes from the openCV2 cookbook.I could understand why the codes from the cookbook work but it is more verbose.

```
for(auto const &data : lines){
float const rho = data[0];
float const theta = data[1];
if((theta < PI/4. || theta > 3. * PI/4.)){
cv::Point pt1(rho / std::cos(theta), 0);
cv::Point pt2( (rho - result.rows * std::sin(theta))/std::cos(theta), result.rows);
cv::line(result, pt1, pt2, cv::Scalar(255), 1);
}else if{
cv::Point pt1(0, rho / std::sin(theta));
cv::Point pt2(result.cols, (rho - result.cols * std::cos(theta))/std::sin(theta));
cv::line(result, pt1, pt2, cv::Scalar(255), 1);
}
}
```