Blocking the View
Time limit2sMemory limit512 MB
For each test, decide whether some point of segment a moved along direction v hits segment b, treating the segments as non-intersecting.
- Level
Medium7 of 10
- Topics
- Geometry, Math, Implementation, Binary search
- Solved
- No attempts yet
Problem
Anton is developing a 2D graphics engine for video games. It has to reach the market. To display objects correctly, he needs to determine whether one object blocks the view to another object when the player looks in a particular direction.
For the prototype, Anton treats objects as non-intersecting segments on the plane. Segment blocks the view to segment in the direction of vector if there are points on and on such that the vectors and are co-directed. In other words, there is a point on that, if it starts moving along the direction of , would hit segment .
Anton is busy looking for investors, so he asks you to implement this part of the graphics engine.
Input
The first line of input contains an integer , the number of tests that follow ().
Each of the following lines contains 10 integers: , , , , , , , , , . These are the coordinates of the endpoints of the first segment, the coordinates of the endpoints of the second segment, and the coordinates of the view direction vector. The absolute value of every coordinate is at most . Each segment has positive length, and the direction vector is non-zero.
Output
For each test, print "Yes" if the first segment blocks the view to the second segment in the given direction, otherwise print "No".