# maths - find vertices when 1 vertex and center point is given in polygon

I want to know if there is any general formula to find out vertices (co-ordinates) of a polygon (3 or more equal sides) when following is given:

Co-ordinates of one of the vertices
Center point (distance between each vertex and center point is equal)


For example, what would be A and B vertices of following equilateral triangle:

(For equilateral triangle i assume that center point = centroid)

     A
/\
/  \                 Center point = (2, 5)
/____\
B      C (4, 6)


Thanks for help.

Regards

-

## migrated from stackoverflow.comApr 27 '11 at 14:53

This question came from our site for professional and enthusiast programmers.

Yep, it's just a linear transformation ;) – Blender Apr 27 '11 at 5:53
I think you need more assumptions in your hypothesis. With those assumptions alone, you still can't determine n, where n is the number of sides (or vertices) of your regular polygon. If you look closely at the answers you've been given as well as at mathworld.wolfram.com/RegularPolygon.html, you'll notice that it's assumed n is known. However, you don't have that assumption in your hypothesis, which means those formulas won't work unless n can be found to depend on the coords of one vertex and the center. (But I'm pretty sure that last part is impossible.) – Rodney Apr 27 '11 at 13:12
The problem's underdetermined. At the very least, you want to be able to form the isosceles triangle that comprises a "slice" of the regular polygon you want, and just two pieces of information isn't enough to uniquely determine that triangle. – J. M. Apr 27 '11 at 15:16

If you have a polygon with equal sides and equal distance from center to all vertices it seems to be a regular convex polygon

EDIT I've found much easier way.

Assume that center of the polygon has coordinates (x_0,y_0) and known vertice has coordinates (x_n,y_n). Also assume that we are considering n-sided polygon.

Coordinates of i-th vertce (0<i<n) can be calculated using this formulae

x_i = x_0+R*cos(a+2*Pi*i/n)
y_i = y_0+R*sin(a+2*Pi*i/n)


where

     _______________________
R = v(x_n-x_0)^2+(y_n-y_0)^2
a = acos((x_n-x_0)/R)


According to your example computations using formula above shows that

A=(4, 6)
B=(0.1339745962155614, 6.2320508075688776)
C=(1.8660254037844377, 2.7679491924311228)


You can check (e.g. using this calculator) that distances between A and B, B and C, C and A are the same and equal to 3.8729833462074166. Also yu can calculate distance between center and each vertice and see that they all will be the same.

==================

That means you can find length of the side of such polygon using this formula a=2Rsin(Pi/n), where R is a distance between center c of your poly and its known vertice p.

   _____________________________
R=v(c.x - p.x)^2 + (c.y - p.y)^2


So you will have a triangle based on center c of your poly and its first p and second s vertices. Since you know coordinates of c and p and length of all sides of this triangle (distance between c and p is R, distance between p and s is a and distance between s and c is again R) you can determine coordinates of s.

-
To get $a$, the starting angle, it is better to use $Atan2(y_n-y_0,x_n-x_0)$ Atan2 sorts out the quadrants for you, while for Acos you need to do it yourself – Ross Millikan Apr 27 '11 at 16:00
Thanks a lot for help @Konstantin Mikhaylov and @Ross Millikan. I used atan2 to find a. Thanks again. Regards – user10156 Apr 27 '11 at 23:32