How can you design an algorithm to know if an n-vertex polygon nonintersecting ?
On what criteria is the test going to be
How can you design an algorithm to know if an n-vertex polygon nonintersecting ?
On what criteria is the test going to be
Copyright © 2021 JogjaFile Inc.
Let's say the vertices are $(x_1,y_1),\dots,(x_n,y_n)$. Write $(x_0,y_0)=(x_n,y_n)$ for easy for numbering. Then you should do the following:
$$\begin{cases} (1-t) x_{i-1} +t x_{i} = (1-s) x_{j-1} +s x_{j} \\ (1-t) y_{i-1} +t y_{i} = (1-s) y_{j-1} +s y_{j} \end{cases} $$ (You can solve it on paper and code the formula for its solution)