## Inspiration

I started with a question: Given a center point and a side length, how do I find the vertices of a regular pentagon? During the process, I discovered a pattern that led me to a general formula.

## What it does

I developed a general formula and method to draw any regular pentagon, centered at any point, with any side length.

## How I built it

I derived all the math and theory on paper first, then translated the pieces into helper methods in a suite of geometric generating code. I plot all the shapes on a matplotlib.pyplot Axes object with all the labels, ticks, and spines removed.

The key behind the method relies on the fact that regular polygons are radially symmetric. Therefore, all the vertices lie on the circle that circumscribes the polygon. If the radius of the circle can be determined (it can ;) then all the vertices of the polygon can be calculated by moving around the circle.

## Challenges I ran into

I ran into some problems extending my method to the general regular polygon. I wanted all my polygons to "lie flat" on a side, but different polygons need to be rotated different amounts. It took a while to derive the conditions and appropriate rotations.

I also had some trouble calculating a general transformation matrix to rotate a vector matrix.

## Accomplishments that I'm proud of

I'm proud of my idea to calculate vertices by extending around a circle. I'm also proud that my rotation method is general and thus, all the code is very short. I'm also proud of the ideas I had to use my formula to create interesting graphics.

I plotted polygons with number of sides = 3-30. I plotted a polygon, rotated it, plotted again all the way around a circle. I plotted a polygon in blue, increase the size, plotted in red, then green, then blue, over and over.

## What I learned

I learned that some programs draw "circles" by drawing regular polygons with an extremely high number of sides. I also learned about Moire patterns.

## What's next for Polygons

I want to continue to develop code to generally manipulate vectors in a 2-D space. I want to extend my code to include more geometric transformations, as well as to extend some of these concepts to a higher-dimensional space.

Log inorsign up for Devpostto join the conversation.