# Intersection of two lines

I have two lines:

line1=InfiniteLine[{{0,1},{4,2}}]
line2=InfiniteLine[{{1,2},{4,8}}]


I used RegionIntersection to get intersection of these lines, but I can't get the coordinates of the point in the intersection.

RegionIntersection[line1,line2]


Also, I have other two lines and I want their intersection. Later, I want to draw line between these two intersections. For example,

line3:=InfiniteLine[{{0,2},{2,5}}]
line4:=InfiniteLine[{{7,1},{3,2}}]


If the intersection of first one is P, and second one Q, I want line PQ. With RegionIntersection I can draw P and Q, but with InfiniteLine I can't draw the line between P i Q. I need their coordinates, or exist other way? I just want to draw the line between them.

• Hi and welcome to Mathematica StackExchange. RegionIntersection[line1,line2] works fine for me. You miss a closing ] in the definition of line1 Mar 30, 2020 at 11:27
• Thanks. I will correct.
– Maja
Mar 30, 2020 at 13:18

line1 = InfiniteLine[{{0, 1}, {4, 2}}];
line2 = InfiniteLine[{{1, 2}, {4, 8}}] ;
line3 = InfiniteLine[{0, 2}, {2, 5}] ;
line4 = InfiniteLine[{7, 1}, {3, 2}];

i12 = RegionIntersection[line1, line2] ;
i34 = RegionIntersection[line3, line4] ;

coords = First /@ {i12, i34}

{{4/7, 8/7}, {-(34/11), -(63/11)}}

line5 = InfiniteLine @ coords;

Graphics[{Opacity, AbsolutePointSize,
Red, line1,
Blue, line2,
Orange, line3,
Cyan, line4,
Black, line5,
Purple, i12,
Magenta, i34},
PlotRange -> {{-8, 8}, {-8, 8}},
Axes -> True] • Thank you so much. I didn't know for First /@.
– Maja
Mar 30, 2020 at 13:13