How to calculate the number of diagonals of a polygon