Finding integer coordinates for a pentagon, hexagon, heptagon, octagon, and nonagon, etc.

Wondering what the formula is for finding integer coordinates for an arbitrary "regular" polygon. By regular I mean symmetrical polygons like pentagon, hexagon, etc.

In particular, I would like to know what integer coordinates are for a:

• Pentagon
• Hexagon
• Heptagon
• Octagon
• Nonagon

For instance, the Wikipedia pentagon SVG has these coordinates:

<polygon points="294,3 585.246118,214.602691 474,556.983037 114,556.983037 2.753882,214.602691" fill="white" stroke="black" stroke-width="4"/>


They are complex and unintuitive floating point values. I would instead like to figure out how to find purely integer coordinates, so for a pentagon it would be something like:

<polygon points="10,10 20,20 30,20 20,30 20,10" fill="white" stroke="black" stroke-width="4"/>


That doesn't make a pentagon, but it has all integer coordinates.

In order to accomplish this, it probably requires specifying a viewport or aspect ratio. So maybe it is wxh as 1000x1200, or 901x817 or something. I don't know how to figure this out.

To summarize, wondering what the equation is for figuring out integer coordinates for a symmetrical polygon, specifically those 5 above.

Those don't exist, at least not in the 2-dimensional Euclidean plane. I'm 100% sure for all of the given ones except the octagon (EDIT: see at the end why the octagon is also impossible). The reason is that for 3 points $$P,Q,R$$ to be consecutive vertices of such a regular $$n$$-gon, the $$\angle PQR$$ must have size $$180°-360°/n$$.

The tangens of the inclination $$\alpha$$ any straight line with equation $$y=mx+n$$ in a right-angled $$(x,y)$$-coordinate system has with the $$x$$-axis has is given by

$$\tan \alpha = m$$

If that line goes trough 2 points with integer coordinates (say $$P=(p_x, p_y)$$ and $$Q=(q_x,q_y)$$), we get

$$\tan \alpha_{PG} = m_{PQ}=\frac{q_y-p_y}{q_x-p_x},$$

which implies that $$m_{PQ}$$ is a rational number.

The same goes for the line through $$Q$$ and $$R$$ and it's inclination $$\alpha_{QR}$$, its tangens is also a rational number.

Now, the $$\angle PQR$$ we considered before is now just the difference of those two inclinations:

$$\angle PQR = \alpha_{PQ}-\alpha_{QR}$$.

The addition theorem for the tangens-function now says:

$$\tan \angle PQR = \frac{\tan \alpha_{PQ} - \tan \alpha_{QR}}{1+\tan \alpha_{PQ}\tan \alpha_{QR}}$$

The main point is now that if $$P,Q,R$$ have interger coordinates, this expression for $$\tan \angle PQR$$ is a rational number, as all the terms are rational and they are combined with elementatary operations that are closed for rationals numbers.

But $$\tan 180°-360°/n$$ is not a rational number for $$n=5,6,7,9$$. It is rational for $$n=8$$, as $$180°-360°/8 = 135°$$, so this proof does not work here.

I'm not sure what the answer is for $$n=8$$, could be either way.

ADDITION: It's impossible for the octagon as well. If $$P,Q,R$$ are the consecutive vertices of the octagon (so $$Q$$ is the middle one of the three), then $$\angle QPR = 22.5°$$. But $$\tan 22.5°=\sqrt{2}-1$$ is irrational, so the same argument as above applies, just for a different angle.