2
$\begingroup$

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.

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

1 Answer 1

2
$\begingroup$
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

$\endgroup$
1
  • $\begingroup$ Thank you so much. I didn't know for First /@. $\endgroup$
    – Maja
    Mar 30, 2020 at 13:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.