In computational geometry, polygon triangulation is the decomposition of a polygonal area into a set of triangles. Over time, a number of algorithms have been proposed to triangulate a polygon. One of the special cases is the triangulation of the monotone polygon. It is proved that a monotone polygon can be triangulated in linear time.
A polygon
PPP is called monotone with respect to a straight line
LLL, if every line orthogonal to
LLL intersects the boundary of
PPP at most twice. For many practical purposes, this definition may be extended to allow cases when some edges of
PPP are orthogonal to
LLL.
A monotone polygon can be split into two
monotone polygonal chains. A polygonal chain is a connected series of line segments, which can be specified by a sequence of points
{A1,A2,…,An}\{A_1,A_2,\dots,A_n\}{A1,A2,…,An}. Similarly, a polygonal chain
CCC is called monotone with respect to a straight line
LLL, if every line orthogonal to
LLL intersects
CCC at most once, or some line segments of
CCC are orthogonal to
LLL.
In this problem, we denote a
directed line La,bL_{\mathbf{a,b}}La,b by a point
a\mathbf{a}a and a direction vector
b\mathbf{b}b where
La,b={a+λb∣λ∈R}L_{\mathbf{a,b}}=\{\mathbf{a}+\lambda\mathbf{b}|\lambda\in\mathbb{R}\}La,b={a+λb∣λ∈R}. We define a polygonal chain
C={A1,A2,…,An}C=\{A_1,A_2,\dots,A_n\}C={A1,A2,…,An} to be monotone with respect to a directed line
La,bL_{\mathbf{a,b}}La,b if the following condition is satisfied:
-
For any 1≤i<j≤n1 \le i < j \le n1≤i<j≤n, (OAi−a)⋅b≤(OAj−a)⋅b(\mathbf{OA_i}-\mathbf{a})\cdot\mathbf{b}\le(\mathbf{OA_j}-\mathbf{a})\cdot\mathbf{b}(OAi−a)⋅b≤(OAj−a)⋅b.
Here,
OAi\mathbf{OA_i}OAi means the coordinate of the point
AiA_iAi, and "
⋅\cdot⋅'' means the dot product of vectors.
Now given the
nnn points in a polygonal chain
CCC, please determine whether there exists a directed line
La,bL_{\mathbf{a,b}}La,b such that
CCC is monotone with respect to
La,bL_{\mathbf{a,b}}La,b.