I am trying to find the vertices of a regular polygon using just the number of sides and 2 vertices. After the second vertex, I will make left turns to find each subsequent vertex that follows.

For example, If I have 4 sides, and 2 points, (0,0) & (0,10), how would I go about find the next to point of the square? I know the points would be (10,10) and then (10,0), but I can't think of a formula to accomplish this.

Thank you for any help, and I hope I provided enough information.

  • 1
    $\begingroup$ What's your level of mathematical expertise? Do you know trig? Vectors and linear algebra? Complex numbers? $\endgroup$ – Blue May 5 '15 at 5:17
  • 1
    $\begingroup$ Complex number would be best, rotation theorem, real smooth. $\endgroup$ – Mann May 5 '15 at 5:18
  • $\begingroup$ I have taken trig and linear algebra. $\endgroup$ – user2587878 May 5 '15 at 5:19
  • $\begingroup$ Use the fact that angle subtended at centre by each side is $(2\pi/n)$ , draw a circumscribing and inscribing circle, see the relations. $\endgroup$ – Mann May 5 '15 at 5:21
  • $\begingroup$ how do I do that without knowing the radius or center? Is there a way to find the center coordinates with just 2 points and side length? $\endgroup$ – user2587878 May 5 '15 at 5:34

For simplicity I am assuming the centre of the polygon is origin.

If two consecutive vertices are given then the angle they make at origin can be found. Call it $\theta=2\pi/n$. Now all points are obtainable from any single point by rotating repeatedly by this angle (centred at origin). As rotation is a linear transformation, this can be achieved by matrix multiplication $$ R_\theta=\pmatrix{\cos\theta & -\sin\theta\cr \sin\theta &\cos\theta\cr}$$ Write the co-ordinates of a vertex of the polygon as a column vector $v_1=\displaystyle {x_1\choose y_1}$. Matrix multiplication $v_2=R_\theta v_1, v_3=R_\theta v_2$ etc will give the co-ordinates of all the vertices.

  • $\begingroup$ How does this change if it is not centered at the origin? $\endgroup$ – user2587878 May 5 '15 at 5:59
  • $\begingroup$ If the centre is the point (vector) $v_0$ subtract it from given two points (vectors), and appeal to the known case and find the other vertices. Now add the vertex $v_0$ to all the vertices you calculated. $\endgroup$ – P Vanchinathan May 5 '15 at 6:03
  • $\begingroup$ My issues so far are, I don't know what the center is, so how do I do that? Also, with your solution, if v1 = (x1 y1), where x1 and y1 are both 0, how does that not give every subsequent v as a zero? $\endgroup$ – user2587878 May 5 '15 at 6:23
  • $\begingroup$ If you do not know the centre, the solution is not unique. Look at the flooring with square tiles. Two consecutive vertices can be thought of as belonging to two different squares (those lying on either sides of the side joining them). $\endgroup$ – P Vanchinathan May 5 '15 at 6:39
  • $\begingroup$ I found how to find both centers, and I already wrote code to deside if the points go counter clockwise. However, I still don't understand your formula. If my initial point is (0,0), won't that give me the same answer for every point with matrix multiplication? Edit: nvm, just realized after I subtract the center it will never happen I think. Thank you. $\endgroup$ – user2587878 May 5 '15 at 6:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.