Finding 2D Polygon Coordinates from a point

Click For Summary
SUMMARY

The discussion focuses on calculating the coordinates of a regular polygon with 3, 4, 5, 6, or 8 sides, centered around a given point (x, y) on a plane. The coordinates of each vertex are determined using the equations: x + r cos(2πk/n) and y + r sin(2πk/n), where r is the radius, n is the number of sides, and k ranges from 0 to n-1. The first vertex is positioned to the right of the center point, but can be adjusted by modifying the cosine and sine functions. This method provides a straightforward solution for generating polygon coordinates based on user-defined parameters.

PREREQUISITES
  • Understanding of trigonometric functions (sine and cosine)
  • Familiarity with Cartesian coordinates
  • Basic knowledge of polygons and their properties
  • Experience with programming concepts for software development
NEXT STEPS
  • Implement the polygon coordinate generation in a programming language such as Python or JavaScript
  • Explore advanced geometric algorithms for irregular polygons
  • Learn about graphical libraries for visualizing polygons, such as p5.js or Matplotlib
  • Investigate user interface design for allowing user selection of polygon parameters
USEFUL FOR

Software developers, mathematicians, and anyone interested in computational geometry or graphical applications that require polygon manipulation and visualization.

Krotus
Messages
2
Reaction score
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?
 
Physics news on Phys.org
Krotus said:
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$.
 
Thanks! Very simple. I knew I had to be overthinking it.
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
2K
Replies
13
Views
4K
Replies
8
Views
3K
Replies
20
Views
4K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 1 ·
Replies
1
Views
3K
Replies
6
Views
1K
Replies
1
Views
2K
  • · Replies 6 ·
Replies
6
Views
1K
  • · Replies 3 ·
Replies
3
Views
6K