Talk:Line–line intersection

message: I am being bold in updating, and hopefully not making a total donkeys butt of myself at the same time. --Chase-san (talk) 06:49, 10 January 2008 (UTC)
thread_title:  Be Bold 

message: So what happens when the denominator is zero? Article's still lacking some information. -- Mike Kamermans, Nov. 2010  —Preceding unsigned comment added by 77.167.120.32 (talk) 21:25, 15 November 2010 (UTC)
replies: text: I think that will only happen in truly degenerate cases. Up to rotational and reflective symmetry, I think it only happens when x_1=x_2 and x_3=x_4. This corresponds to parallel lines which either don't intersect (or intersect at infinity, if you like that point of view) or they are coincident, in which case all points on one line are on the other. You are right, this needs to be added. In projective space, this all works out naturally, btw., since it allows us to represent the point at infinity and coincident lines. See Projective_plane#Lines_joining_points_and_intersection_of_lines_.28using_duality.29. —Ben FrantzDale (talk) 22:11, 15 November 2010 (UTC)

text: When the denominator is zero it always means that the lines are parallel. Here's my proof: Let the denominator equal zero: (x1 - x2)(y3 - y4) - (y1 - y2)(x3 - x4) = 0. Now rearrange the terms: (y2 - y1)/(x2 - x1) = (y4 - y3)/(x4 - x3). Now notice that the term on the left is the slope of line 1 and the term on the right is the slope of line 2. This equation says that the slopes of the lines are equal, and therefore they must be parallel. If you guys concur I'll add this to the page. --Chrisanderman (talk) 01:48, 13 December 2011 (UTC)
thread_title:  zero denominator 

message: We really need the match for a case where the end points of the lines are specified in terms of x, y and z coordinates, not just x and y. But I'd keep the 2D case too, as that's no doubt simpler and will be sufficient for most peoples needs. Drkirkby (talk) 12:28, 13 November 2011 (UTC)
replies: text: It is covered in the n-line intersection section. —Ben FrantzDale (talk) 12:44, 14 November 2011 (UTC)
thread_title:  It would be better if the 3D case was covered too.  

message: This was added to the article and I removed it for discussion here.
Note: The equation above do not return the intersection of two lines. There may be some unknown additional step needed to get the correct intersection point, or the determinant may be written incorrectly. Here is a version that works correctly. This corresponds to the simplified version in the citation. This code is for MatLab.
x = [0 0; 6 6];  %# Starting points in first row, ending points in second row
y = [0 6; 6 0];
The equations from the above source can then be coded up as follows:
dx = diff(x);  %# Take the differences down each column
dy = diff(y);
den = dx(1)*dy(2)-dy(1)*dx(2);  %# Precompute the denominator
ua = (dx(2)*(y(1)-y(3))-dy(2)*(x(1)-x(3)))/den;
ub = (dx(1)*(y(1)-y(3))-dy(1)*(x(1)-x(3)))/den;
And you can now compute the intersection point of the two lines:
xi = x(1)+ua*dx(1);
yi = y(1)+ua*dy(1);
For the example in the question, the above code gives xi = 3 and yi = 3, as expected. If you want to check that the intersection point lies between the endpoints of the lines (i.e. they are finite line segments), you just have to check that the values ua and ub both lie between 0 and 1:
isInSegment = all(([ua ub] >= 0) & ([ua ub] <= 1));
A couple more points from the tutorial I linked to above:
If the denominator den is 0 then the two lines are parallel.
If the denominator and numerator for the equations for ua and ub are 0 then the two lines are coincident.
-- 06:46, 26 January 2014‎ 69.230.99.150
I am leaving it to others to straighten out any problems. Bill Cherowitzo  (talk) 05:34, 27 January 2014 (UTC)
thread_title:  Comment 

message: Yes 103.246.41.143 (talk) 05:41, 8 May 2022 (UTC)
thread_title:  Pine intersect at point o 

message: Converting one of the point-vector pairs to two planes intersection as the line representation, gives two line-plane intersections to test.  — Preceding unsigned comment added by Goofyseeker311 (talk • contribs) 11:36, 11 October 2023 (UTC)
thread_title:  Alternative solution