How do I find all quadrilaterals in between several intersecting lines? Only condition is that each side of the quadrilateral is one line.
I found this theoretical explanation but not a code for it.
So far I'm pretty much in the beginning. I have my lines (two x,y points for each line) and found all intersection of them (x,y point). If you're interested in the script, see here.
My script is based on php so far but I'm thankful for any advised, also in a different language.
Example
Here a set of lines.
line 715.341 0 757.297 600,
line 0 249.169 800 179.178,
line 0 256.196 800 186.205,
line 0 284.225 800 200.142,
line 396.716 0 481.041 600,
line 0 311.374 800 227.29,
line 0 355.76 800 229.053,
line 0 521.525 800 437.442,
line 696.134 0 611.809 600
In my example the intersection points would be the followings. Each point has a number, x and y coordinates as well as two lines ids.
Point 1. 728.309, 185.45, 0, 1
Point 2. 728.797, 192.434, 0, 2
Point 3. 729.852, 207.515, 0, 3
Point 4. 731.736, 234.465, 0, 5
Point 5. 732.11, 239.806, 0, 6
Point 6. 746.324, 443.084, 0, 7
Point 7. 426.491, 211.856, 1, 4
Point 8. 669.346, 190.609, 1, 8
Point 9. 427.466, 218.798, 2, 4
Point 10. 668.346, 197.723, 2, 8
Point 11. 430.305, 238.998, 3, 4
Point 12. 666.027, 214.223, 3, 8
Point 13. 434.065, 265.752, 4, 5
Point 14. 436.988, 286.548, 4, 6
Point 15. 463.17, 472.844, 4, 7
Point 16. 662.154, 241.778, 5, 8
Point 17. 660.845, 251.093, 6, 8
Point 18. 632.176, 455.081, 7, 8
convert -size 800x600 xc:skyblue \
-fill red -stroke red -strokewidth 2 \
-draw "line 715.341 0 757.297 600, line 0 249.169 800 179.178, line 0 256.196 800 186.205, line 0 284.225 800 200.142, line 396.716 0 481.041 600, line 0 311.374 800 227.29, line 0 355.76 800 229.053, line 0 521.525 800 437.442, line 696.134 0 611.809 600" \
-font Courier -pointsize 14 -draw "fill none stroke blue circle 728.309,185.45 726.309,183.45 circle 728.797,192.434 726.797,190.434 circle 729.852,207.515 727.852,205.515 circle 731.736,234.465 729.736,232.465 circle 732.11,239.806 730.11,237.806 circle 746.324,443.084 744.324,441.084 circle 426.491,211.856 424.491,209.856 circle 669.346,190.609 667.346,188.609 circle 427.466,218.798 425.466,216.798 circle 668.346,197.723 666.346,195.723 circle 430.305,238.998 428.305,236.998 circle 666.027,214.223 664.027,212.223 circle 434.065,265.752 432.065,263.752 circle 436.988,286.548 434.988,284.548 circle 463.17,472.844 461.17,470.844 circle 662.154,241.778 660.154,239.778 circle 660.845,251.093 658.845,249.093 circle 632.176,455.081 630.176,453.081" \
-draw "fill blue stroke blue text 738.309,190.45 '1' text 738.797,197.434 '2' text 739.852,212.515 '3' text 741.736,239.465 '4' text 742.11,244.806 '5' text 756.324,448.084 '6' text 436.491,216.856 '7' text 679.346,195.609 '8' text 437.466,223.798 '9' text 678.346,202.723 '10' text 440.305,243.998 '11' text 676.027,219.223 '12' text 444.065,270.752 '13' text 446.988,291.548 '14' text 473.17,477.844 '15' text 672.154,246.778 '16' text 670.845,256.093 '17' text 642.176,460.081 '18'" \
lines-intersection.jpg
So now the big question is, how I use the information to find all quadrilateral between the points where each side is one line...
One of the quadrilateral I'm looking for is Point 13, 4, 6 and 15: