Given an even number N which represents the number of sides of a regular polygon with N vertices, the task is to find the square of the minimum size such that given Polygon can completely embed in the square.
A Polygon is a convex figure and has equal sides and equal angles. All sides have length 1.
Embedding: Place Polygon in the square in such way that each point which lies inside or on a border of N should also lie inside or on a border of the square.
Input: N = 4
Regular polygon with 4 Sides is square with side 1.
Given polygon can easily embed on the square with side 1.
Input: N = 6
Regular polygon with 6 Sides is Hexagon with side 1.
Given polygon can easily embed on the square with side 1.931851653.
Approach: The idea is to observe that on a 3-D plane, when a polygon is embedded in a square, it might be rotated. A similar approach has been discussed in Hexagon problem and Octagon problem . Therefore, we take the projection of each side on both the axis using the mathematical functions sin() and cos(). The overall sum of all the projections is the minimum side of the square required in this problem.
Below is the implementation of the above approach:
Time Complexity: O(N), where N is number of sides of polygon.
- Polygon with maximum sides that can be inscribed in an N-sided regular polygon
- Number of triangles formed by joining vertices of n-sided polygon with two common sides and no common sides
- Area of Triangle using Side-Angle-Side (length of two sides and the included angle)
- Side of a regular n-sided polygon circumscribed in a circle
- Area of a n-sided regular polygon with given side length
- Number of ways to arrange 2*N persons on the two sides of a table with X and Y persons on opposite sides
- Count right angled triangles in a matrix having two of its sides parallel to sides of the matrix
- Number of ways a convex polygon of n+2 sides can split into triangles by connecting vertices
- Check if it is possible to create a polygon with given n sides
- Length of remaining two sides of a Triangle from a given side and its adjacent angles
- Check if given polygon is a convex polygon or not
- Number of triangles formed by joining vertices of n-sided polygon with one side common
- Regular polygon using only 1s in a binary numbered circle
- Program to find the Interior and Exterior Angle of a Regular Polygon
- Program to find the Circumcircle of any regular polygon
- Program to find the Perimeter of a Regular Polygon
- Program to find Area of Triangle inscribed in N-sided Regular Polygon
- Area of a n-sided regular polygon with given Radius
- Length of Diagonal of a n-sided regular polygon
- Apothem of a n-sided regular polygon
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.