# cross point of intersecting lines [duplicate]

What is the easiest way to find the crossing point of two intersecting lines passing lets say through points line1 = {p1,p2}, line2 = {p3,p4}?

## marked as duplicate by Mr.Wizard♦Jul 9 '15 at 16:34

• Welcome to Mathematica.SE! I suggest that: 1) You take the introductory Tour now! 2) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! 3) As you receive help, try to give it too, by answering questions in your area of expertise. – bbgodfrey Apr 7 '15 at 17:48
• findInter[{p1_, p2_}, {p3_, p4_}] := t p1 + (1 - t) p2 /. Solve[t p1 + (1 - t) p2 == t1 p3 + (1 - t1) p4, {t, t1}][]; findInter[{{1, 0}, {-1, 0}}, {{0, 1}, {1, 2}}] – Dr. belisarius Apr 7 '15 at 18:03
• f[t_, l_] := First@l - Subtract @@ l t; findInter[l1_, l2_] := f[t, l1] /. Solve[f[t, l1] == f[t1, l2]]; findInter[{{1, 0}, {-1, 0}}, {{0, 1}, {1, 2}}] – Dr. belisarius Apr 7 '15 at 18:58
• Duplicate: "Find intersection of pairs of straight lines." – Alexey Popkov Jun 1 '15 at 20:31

Given

line1 = {p1, p2}; line2 = {p3, p4};


you could define two points on these lines:

l1 = {1 - u1, u1}.line1;
l2 = {1 - u2, u2}.line2;


and just solve for the intersection:

l1 /. Solve[l1 == l2, {u1, u2}]


Alternatively (and more elegantly) you could use projective geometry, where Cross[p1,p2] is the line between two points p1 and p2 and Cross[l1,l2] is the intersection between two lines l1 and l2:

euclidean2homogenous = Append[#, 1] &;
homogenous2euclidean = #[[;; -2]]/#[[-1]] &;

line1 = Cross[euclidean2homogenous@p1, euclidean2homogenous@p2];
line2 = Cross[euclidean2homogenous@p3, euclidean2homogenous@p4];

intersection = Cross[line1, line2]

homogenous2euclidean[intersection]

• Dear niki thank you very much. Great help for a newbie. – na4 Apr 7 '15 at 19:53