I tried to implement it myself but caught some bugs that I didn't debug yet. How would you implement this function: check if a whole ((ax1, ay1), (ax2, ay2)) segment is part of ((bx1, by1), (bx2, by2)) segment?
# | User | Rating |
---|---|---|
1 | tourist | 3624 |
2 | Um_nik | 3468 |
3 | wxhtxdy | 3329 |
4 | V--o_o--V | 3309 |
5 | Petr | 3297 |
6 | mnbvmar | 3255 |
7 | LHiC | 3250 |
8 | TLE | 3186 |
9 | Vn_nV | 3182 |
10 | dotorya | 3165 |
# | User | Contrib. |
---|---|---|
1 | Radewoosh | 195 |
2 | Errichto | 181 |
3 | neal | 159 |
4 | Ashishgup | 157 |
4 | PikMike | 157 |
6 | Petr | 156 |
7 | rng_58 | 154 |
7 | majk | 154 |
9 | Um_nik | 153 |
10 | Vovuh | 152 |
I tried to implement it myself but caught some bugs that I didn't debug yet. How would you implement this function: check if a whole ((ax1, ay1), (ax2, ay2)) segment is part of ((bx1, by1), (bx2, by2)) segment?
Name |
---|
Find eq of line passing through (bx1,by1) (bx2,by2) which is (y-by1)*(bx2-bx1)=(by2-by1)*(x-bx1)....put ax1 at x and ay1 at y..if LHS==RHS then further check for ax2 and ay2 and if LHS=RHS then we can be sure that these points lie on the line passing through (bx1,by1) (bx2,by2).To check for part of we need to check ax1>=bx1 and ax2<=bx2 if we sort the segments such that (ax1<=ax2 and bx1<=bx2).
2.If yes it becomes a one dimensional problem (be aware of vertical lines)