** A regular strictly convex polygon is a polygon that has the following characteristics:**
- all interior angles are less than 180
- all sides have equal length
For a regular strictly convex polygon with:
- n edges (=n vertices)
- R circumradius
- interiorAngle=(n−2)⋅180n
- edgeLength,s=2⋅R⋅sin(πn)
- apothem,a=R⋅cos(πn)
- area=12⋅n⋅s⋅a
- perimeter=n⋅s
** Objective 1 **
-
Create a Polygon Class: where initializer takes in:
- number of edges/vertices
- circumradius
that can provide these properties:
- edges
- vertices
- interior angle
- edge length
- apothem
- area
- perimeter
that has these functionalities:
- a proper repr function
- implements equality (==) based on # vertices and circumradius (eq)
- implements > based on number of vertices only (gt)
** Objective 2 **
-
Implement a Custom Polygon sequence type:where initializer takes in:
- number of vertices for largest polygon in the sequence
- common circumradius for all polygons
that can provide these properties:
- max efficiency polygon: returns the Polygon with the highest area: perimeter ratio
that has these functionalities:
- functions as a sequence type (getitem)
- supports the len() function (len)
- has a proper representation (repr)
-
Results:
- Implement these 2 classes as a separate module. Access these modules in a jupyter-notebook (or Google Colab or Deep Note)
- Run Objective 1 module to show that the functionalities are implemented properly
- Run Objective 2 module and show which polygon is efficient for n = 25
- You are submitting link to your GitHub repo, where we can find the 2 modules and your notebook in which you have called and tested them
Implementation of a regular Polygon which takes num_eges and circumradius as input. It can give num_eges, num_vertices,interior angle, edge length, apothem, area, perimeter
Usage
p = Polygon(10, 10) # no of edges , circumradius
p.num_edges
p.perimeter
p.area
This function initializes the number of edges and the circumradius to the polygon class.
This function returns the number of edges. This is decorated as class property. Also decorated with num_edges.setter, it helps to set the edges values.
This function returns the number of edges. This is decorated as class property. Also decorated with num_vertices.setter, it helps to set the edges values. For a regular polygon, the number of edges is equal to the number of vertices.
This function returns the circumradius. This is decorated as class property. Also decorated with circumradius.setter, it helps to set the circumradius value.
This function calculates the interior angle in accordance to the equation. This is decorated as class property.
This function calculates the edge length in accordance to the equation. This is decorated as class property.
This function calculates the apothem in accordance to the equation. This is decorated as class property.
This function calculates the area in accordance to the equation. This is decorated as class property.
This function calculates the perimeter in accordance to the equation. This is decorated as class property.
This function returns the property of the Polygon class initialized
Equality function to compare whether 2 polygons are equal by comparing the number of edges and circumradius
Greater than function to compare whether which of the 2 polygons is bigger by comparing the number of vertices
Implementaion Of Custom Sequence of Polygons which takes largest polygon num of edges and circumradius as input
Usage
p = Polygon_Sequence(num_edges = 10, circumradius = 10)
#for getting the each Polygon through index
p[3]
#slicing
p[3:10]
#length
len(p)
#max efficinecy polygon
p.max_efficiency_polygon
This function initializes the largest number of edges and the circumradius to the polygon sequence class. The polygon sequence class generates a sequence of polygons greater than 2 upto the polygon with the largest number of edges
This function returns the largest number of edges. This is decorated as class property. Also decorated with largest_num_edges.setter, it helps to set the largest number of edges values.
This function returns the circumradius. This is decorated as class property. Also decorated with circumradius.setter, it helps to set the circumradius value.
This function returns the property of the Polygon sequence class initialized.
This function provides the length of polygon sequence.
This function helps to retrieve a particular value from the polygon sequence or a slice of values.
Calls the polygon class to get the properties
Caculates the maximum efficiency polygon