2

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.

Maja
  • 21
  • 2

1 Answers1

3
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[1], AbsolutePointSize[10], 
  Red, line1,
  Blue, line2, 
  Orange, line3, 
  Cyan, line4, 
  Black, line5, 
  Purple, i12, 
  Magenta, i34}, 
 PlotRange -> {{-8, 8}, {-8, 8}}, 
 Axes -> True]

enter image description here

kglr
  • 394,356
  • 18
  • 477
  • 896