this question is the most difficult to build a map, find a shortest path map building will come out after, say under my map building method, first of all I pos [] array will start and end point and the endpoint of each segment as a wall The vertices of the graph (remove the two points of the wall root, because it is meaningless). Then use the seg[][] array to represent the information of each line segment of each wall, seg[i][] represents the information of the i-th wall, the purpose of this array is mainly to: traverse every two points of the pos[] array Judge whether the edge can be built. If the line segment formed by these two points is blocked by the wall between (intersects with a certain line segment in the wall), the edge cannot be built, otherwise the edge is built. Here I will talk about how to judge whether the line segments ab and cd intersect?
If two line segments intersect, there is ca ⃗ × cb ⃗ \vec{ca}\times\vec{cb}c a×cb和da ⃗ × db ⃗ \ vec {da} \ times \ vec {db}d a×dbDifferent sign and da ⃗ × ca ⃗ \vec{da}\times\vec{ca}d a×c aAnd db ⃗ × cb ⃗ \vec{db}\times\vec{cb}db×cbIt is also an opposite sign. If these two conditions are met at the same time, it is the intersection. I only wrote that one condition is satisfied, but this is not a sufficient condition for judging the intersection of line segments. This is because the meaning of this question is given by the special data, I hope everyone Just know.