DCEPC12C - Computer Graphics
Sammy is taking up a course on Computer Graphics this semester. He likes algorithms and so he likes this course too! He came across a problem. The problem is - given a 2D figure on a 2D cartesian coordinate system and another point in the same system, how to find if that point is inside that figure? A point is considered to be inside a figure if it is on the boundary or inside its boundaries. He seems stuck in this problem, can you help him?
Input
First line of input contains an integer "T", the number of test cases.
Each of the next “T” lines contains any of following type of operations:
- Type 1: It is described as “1 x1 y1 x2 y2 x3 y3 x4 y4 x y” where 1 means operation type 1 followed by (x, y) coordinates of 4 points of a simple convex quadrilateral in order, followed by the query point.
- Type 2: It is described as “2 x1 y1 x2 y2 x3 y3 x y” where 2 means operation type 2 followed by (x, y) coordinates of 3 points of a valid triangle. Followed by the query point.
- Type 3: It is described as “3 x1 y1 R x y” where 3 means operation type 3 followed by (x, y) coordinates of center of a circle and R as its radius. Followed by the query point.
All values are integers.
Output
Corresponding to every Operation type, output "YES" if the query point lies in that figure. Output "NO" otherwise.
Constraints
1 ≤ T ≤ 100
All figures drawn on 2D plane will be such that they will not have any part outside the rectangle described by these 4 points in order: (-1000, -1000), (1000, -1000), (1000, 1000), (-1000, 1000).
Query points will also be within the above described rectangle.
Example
Input: 1 1 3 4 10 11 10 2 1 1 3 3 Output: YES
Added by: | dce coders |
Date: | 2013-12-07 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | C C++ 4.3.2 CPP JAVA |