I am looking to calculate the X and Y points of each point on a polygon, given the number of sides, and the fact that all sides are equal. I would also have the width and height constraints of the entire shape. If it helps any, I would be doing this in Java (most likely using Line2D).
You should first find out the center of the circle (cx, cy) and the radius R by the width and height constraints, which is trivial. Each of the polygon points is equally distributed on the circle and their position can be calculated by:
Xi = cx + R*cos(2.0*PI*i/n)
Yi = cy + R*sin(2.0*PI*i/n)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With