Approach: The square we will derive will have the same centre and axes of the hexagon. This is because the square will become smaller if we will rotate it.
The sides of the hexagonal are equal i.e. a = b + c. Now, let d be the length of the side of the inscribed square, Then the top side of the square, d = 2 * c * sin(60). And, the left side of the square, d = a + 2 * b * sin(30). Substituting for c, d = 2 * (a – b) * sin(60). Now taking d and re-arranging, we get, b / a = (2 * sin(60) – 1) / (2 * (sin(30) + sin(60))) So, b / a = 2 – √3 Now, substituting the relation of b and a in the left hand side equation of square, we get, d / a = 3 – √3 i.e. d / a = 1.268 Therefore, d = 1.268 * a
Below is the implementation of the above approach:
// C++ program to find the area of the largest square
// that can be inscribed within the hexagon
// Function to find the area
// of the square
// Side cannot be negative
if(a < 0)
// Area of the square
floatarea = pow(1.268, 2) * pow(a, 2);
// Driver code
floata = 6;
cout << squareArea(a) << endl;
// Java program to find the area of the largest square
Please Login to comment...