Can anyone give me x,y coordinates for an octagon?

10.4k Views Asked by At

I am looking to draw a octagon and I need $(x, y)$ coordinates.

4

There are 4 best solutions below

5
On BEST ANSWER

These are most easily done using a rotation matrix: $$R = \left[\begin{array}{cc} \cos\theta & -\sin\theta \\ \sin\theta & \cos\theta \end{array}\right]$$ So that if you have a coordinate $\left[\begin{array}{c} x \\ y\end{array}\right]$, the vector $$R\left[\begin{array}{c} x \\ y\end{array}\right] = \left[\begin{array}{c} x\cos\theta - y\sin\theta \\ x\sin\theta +y\cos\theta\end{array}\right]$$ is $\left[\begin{array}{c} x \\ y\end{array}\right]$ rotated $\theta$ radians counterclockwise around the origin.

Now suppose one vertex of your octagon is at $(1,0)$. To get the second vertex, you should rotate this by $\frac{2\pi}{8} = \frac{\pi}{4}$. And to get the third vertex, you rotate the second by $\frac{\pi}{4}$ and so on. This is a general solution that you can utilize to find the coordinates (e.g. using a computer) for any regular $n$-gon.

An regular octagon is special in the sense that you will get the simple expression $$(1,0),(\frac{\sqrt{2}}{2}, \frac{\sqrt{2}}{2}), (0,1), (-\frac{\sqrt{2}}{2}, \frac{\sqrt{2}}{2}), (-1,0), (-\frac{\sqrt{2}}{2}, -\frac{\sqrt{2}}{2}), (0, -1), (\frac{\sqrt{2}}{2}, -\frac{\sqrt{2}}{2})$$ for its coordinates.

Edit: To get the coordinates for a "real" stop sign, you will need to start from the point $(\cos \frac{\pi}{8}, \sin\frac{\pi}{8})$.

1
On

So, it the side length is $1$, and each edge is at a $135$ degree angle from each other, then the width of the total octagon is $1+\sqrt{2}$ Does this give you enough information to start calculating the points?

0
On

I would say that x,y koordinates of an regular n-gon:

$x=\cos(\frac{2k\pi}{n}),\,\,\, y=\sin(\frac{2k\pi}{n}),\,\,\, k = 1,2,3\cdots n$

So for octagon n = 8.

0
On

To draw a regular octogon, solve $x^8 = 1$. Then, if required, apply any homothetic transformation and/or rotation to the obtained set of points.

Cheers.