230. You have to determine whether a polygon contains a point... .....
Microsoft Interview Questions and Answers
(Continued from previous question...)
230. You have to determine whether a polygon contains a point... .....
Question:
You have to determine whether a polygon contains a point( origin ) or not. Vertex of the polygon are given in cyclic order. Polygon can be convex or concave. Write code( most important part).
maybe an answer:
1. calculate area of polygon using triangulation - call it A
2. calculate new area with including point p in polygon - call it A_p
if A > A_p
point is inside
if A == A_p
point is on line
if A < A_p
point it outside
(Continued on next question...)
Other Interview Questions
|