 <p>You can read a reasonable answer from this implementation found in some webpage</p> <pre><code>Point * intersection2(Point * _line1, Point * _line2) { Point p1,p2,p3,p4; p1=_line1[0]; p3=_line2[0]; p2=_line1[1]; p4=_line2[1]; // Store the values for fast access and easy // equations-to-code conversion double x1 = p1.x, x2 = p2.x, x3 = p3.x, x4 = p4.x; double y1 = p1.y, y2 = p2.y, y3 = p3.y, y4 = p4.y; double A1 = y2-y1; double B1 = x1-x2; double C1 = (A1*x1)+(B1*y1); double A2 = y4-y3; double B2 = x3-x4; double C2 = A2*x3+B2*y3; double det = A1*B2 - A2*B1; if (det==0){ return NULL; }else{ // Return the point of intersection Point * ret = new CvPoint2D64f (); ret-&gt;x = (B2*C1 - B1*C2)/det; ret-&gt;y = (A1*C2 - A2*C1)/det; return ret; } </code></pre> <p>}</p> <p>Reference. C++ Example: Geometry Concepts Line Intersection and its Applications, 2D drawing By lbackstrom from site ucancode</p>