Finding 2D Polygon Coordinates from a point

  • MHB
  • Thread starter Krotus
  • Start date
  • #1
Krotus
2
0
Suppose that I have the coordinates of x and y on a plane.

I am writing a piece of software where the user can select a polygon of 3, 4, 5, 6 or 8 sides. All of the polygon points are equidistant from the x, y point. In other words, if you drew a circle where the center was the x, y point, all of the points of the polygon would line on the circle.

That means, obviously, that the distance of each polygon point is equal to the imaginary circle's radius.

Given that information, what are the equations to create each type of polygon's set of points?
 

Answers and Replies

  • #2
I like Serena
Homework Helper
MHB
16,350
256
Suppose that I have the coordinates of x and y on a plane.

I am writing a piece of software where the user can select a polygon of 3, 4, 5, 6 or 8 sides. All of the polygon points are equidistant from the x, y point. In other words, if you drew a circle where the center was the x, y point, all of the points of the polygon would line on the circle.

That means, obviously, that the distance of each polygon point is equal to the imaginary circle's radius.

Given that information, what are the equations to create each type of polygon's set of points?

Hi Krotus, welcome to MHB!

Suppose the polygon will have $n$ sides.
And suppose each of the polygon points must have a distance of $r$ to point $(x,y)$.
Then the x- and y-coordinates of point $k$ of the polygon are given by:
$$\begin{cases}x + r \cos(2\pi \cdot k/n) \\ y + r\sin(2\pi \cdot k/n)\end{cases}$$
where $k$ runs from $0$ to $n-1$. Furthermore, the first point ($k=0$) will be to the right of $(x,y)$.

If you want the first point to be in a different location than to the right of $(x,y)$, we can add a fixed constant to the calls of $\cos$ and $\sin$.
 
  • #3
Krotus
2
0
Thanks! Very simple. I knew I had to be overthinking it.
 

Suggested for: Finding 2D Polygon Coordinates from a point

Replies
10
Views
577
Replies
7
Views
2K
  • Last Post
Replies
2
Views
311
  • Last Post
Replies
7
Views
1K
Replies
2
Views
700
  • Last Post
Replies
1
Views
672
Replies
8
Views
1K
  • Last Post
Replies
5
Views
1K
Replies
29
Views
580
Top