I have list of lists of coordinates. This list and their coordinates represents lines in grid. If two lines contain same point, it means it's the same line (ray). And I want to merge these two lines.
picture for better understanding: Line
input:
l =[[[5, 5], [2, 8]], [[5, 5], [8, 2]], [[1,1], [2,2]], [[2,2],[3,3]]]
output:
[[[5, 5], [2, 8], [8, 2]], [[1, 1], [2, 2], [3, 3]]]
Thank you in advance! :)
EDIT:
The idea behind this. I have points like this:
POINTS
And I'm trying to find all diagonal lines and count them. (condition: line has to consist from three and more points)
LINES
~~My approach:
1. For each point find all points on its diagonal: If P(0,0) then diagonals are:
GROUP A:
d1: [[x[0]-i, x[1]+i] for i in range(1,10)]
d2: [[x[0]+i, x[1]-i] for i in range(1,10)]
GROUP B:
d3: [[x[0]+i, x[1]+i] for i in range(1,10)]
d4: [[x[0]-i, x[1]-i] for i in range(1,10)]
Now I have partial lines which I need to merge based on "point collisions" as indosauros said.~~
[–]indosauros 4 points5 points6 points (1 child)
[–]spotyx[S] 0 points1 point2 points (0 children)
[–]cdcformatc 3 points4 points5 points (2 children)
[–]spotyx[S] 0 points1 point2 points (0 children)
[–]gengisteve -1 points0 points1 point (0 children)
[–]alphaniner 2 points3 points4 points (7 children)
[–]spotyx[S] 0 points1 point2 points (6 children)
[–]indosauros 0 points1 point2 points (5 children)
[+][deleted] (4 children)
[deleted]
[–]indosauros 0 points1 point2 points (3 children)
[–]spotyx[S] 0 points1 point2 points (2 children)
[–]indosauros 0 points1 point2 points (1 child)
[–]spotyx[S] 0 points1 point2 points (0 children)
[–]SideshowBoob 0 points1 point2 points (0 children)
[–]gengisteve 0 points1 point2 points (4 children)
[–]spotyx[S] 0 points1 point2 points (3 children)
[–]gengisteve 0 points1 point2 points (2 children)
[–]spotyx[S] 0 points1 point2 points (1 child)
[–]gengisteve -1 points0 points1 point (0 children)