Find all points with whole- number's coordinates inside the area of polygon

535 Views Asked by At

I've got the polygon with n angles. I know the coordinates of its apexes (their coordinates are integers), but I don't know the total area of that polygon.

Is there any way to count how many points with whole- number's coordinates are inside the area of that polygon? I read about Pick's theorem, but it will be not useful - I don't know the area...

Ilustration - http://informatyka.wroc.pl/sites/default/files/user_files/u102/Pick.png

1

There are 1 best solutions below

0
On BEST ANSWER

You can compute the area enclosed by $(x_1,y_1), \ldots, (x_n,y_n)$ as

$$ A=\left|\frac12\sum_{k=1}^n (x_ky_{k-1}-y_kx_{k-1})\right|$$ (with $x_0=x_n, y_0=y_n$ understood). To apply Pick, ou also need the number of lattice points on edges. There are $\gcd(y_k-y_{k-1},x_k-x_{x-1})-1$ such points (excluding the end points) on the edge from $(x_{k-1},y_{k-1})$ to $(x_k,y_k)$.