How to get 8 coordinates for octagon? I have the following data regarding octagon -
length of the octagon side.
starting point.
Now I need to know how to get the 8 coordinates of the octagon.
Fortunately, an octagon can be a relatively easy shape, because the lines are orthogonal or diagonally at 45 degrees (provided you're not going to rotate it over arbitrary angles).
So you don't need very complex calculations. For a triangle with a right angle and two sides of the same length Y
, the hypotenuse of that triangle has a length Y * sqrt(2)
.
That hypotenuse is your side X
, so Y = X / sqrt(2)
.
Picture saying more than 1000 words:
So you can calculate Y for your desired length X, and from there it's just additions and subtractions to get all the coordinates.