I have a list of 24 points, in which two consecutive points (1st and 2nd, 3rd and 4th, …) are supposed to form a line:
p1={{243.8, 77.}, {467.4, 12.}, {291.8, 130.}, {476., 210.5}, {103.2,
327.}, {245.2, 110.5}, {47.4, 343.}, {87.4, 108.5}, {371.,
506.5}, {384.6, 277.}, {264.6, 525.5}, {353.8, 294.5}, {113.2,
484.5}, {296., 304.5}, {459.6, 604.5}, {320.2, 466.5}, {288.2,
630.5}, {199.6, 446.5}, {138.8, 615.5}, {81.8, 410.}, {232.4,
795.}, {461.8, 727.}, {27.4, 671.5}, {206.8, 763.5}};
I also have another list of 24 points with the same property:
p2={{356.8, 32.}, {363.2, 120.}, {346., 245.}, {393.8, 158.}, {163.8,
211.5}, {230.2, 250.}, {54.6, 225.}, {139.6, 220.}, {366.,
394.5}, {451.8, 372.}, {241., 398.}, {321., 411.5}, {163.2,
347.}, {213.2, 406.5}, {332.4, 596.5}, {402.4, 528.5}, {176.,
585.5}, {256., 530.5}, {38.2, 553.}, {122.4, 507.}, {345.2,
774.5}, {345.2, 688.}, {104.6, 728.}, {161.8, 647.}};
My goal is to find the intersections between a line in p1
and a line in p2
as shown in the graph below. I really don't know how to start with this, and worse, a line on *. How can I solve this?p1
does not match up with the intersecting line in p2
in terms of order in each list. This could be observed by different colors of 2 intersecting lines, and makes it harder for element-by-element manipulation
Join[Partition[p1, 2], Partition[p2, 2]] // ListLinePlot
*I found out that this is thankfully not true, as seen below when line i in p1
and line i in p2
are plotted together, and also by Öskå in a comment to eldo's answer.
Row@Table[
ListLinePlot[{Partition[p1, 2][[i]], Partition[p2, 2][[i]]}], {i, 1,
Length@Partition[p1, 2]}]
{x, y} /. Solve[Apply[And, Element[{x, y}, Line[Partition[#, 2]]] & /@ {p1, p2}], {x, y}]
$\endgroup$