Pentagram Challenge

pentagon-circumcircleA polygon is a plane shape (2D) with straight lines. It consists of vertices and edges.

A polygon is regular when all angles are equal and all sides are equal. For instance a regular pentagon consists of 5 vertices and 5 edges of equal size. The vertices of a regular pentagon are equally spread on a circle. This outside circle is called a circumcircle, and it connects all vertices (corner points) of the polygon. The radius of the circumcircle is also the radius of the polygon. We can use the trigonometric formulas to work out the (x,y) coordinates of each vertex of a regular pentagon. (See picture on the right).

Using this approach, we can use a Python script to calculate the (x,y) cooridnates of the 5 vertices of a regular pentagon and store them in a list of [x,y] sub-lists.

Star Shapes


pentagramA pentagram is a polygon that looks like a 5-pointed star. The outer vertices (points of the stars) form a regular pentagon. The inner vertices of the star also form a smaller “inner” regular pentagon.

We can hence use a similar approach to calculates the (x,y) coordinates of both “outer” and “inner” vertices of our pentagram.
pentagram-coordinates

Python Turtle


We have completed the code to calculate the coordinates of a regular pentagon (using the code provided above) and have created a function called drawPolygon() that uses Python Turtle to draw a polygon on screen.

Your Task


Adapt the above Python code to calculates the coordinates of all ther vertcies of a pentagram (star shape) and draw it on screen.

The output of your program should be as follows:
pentagram-star-shape

Extension Task


Use the shoelace algorithm to calculate the area of your pentagram.

Share Button
Tagged with: ,