Biggest Reuleaux Triangle within a Square which is inscribed within a Circle
Last Updated :
28 Jul, 2022
Given here is a circle of radius r, which inscribes a square which in turn inscribes a reuleaux triangle. The task is to find the maximum possible area of this reuleaux triangle.
Examples:
Input: r = 6
Output: 50.7434
Input: r = 11
Output: 170.554
Approach: From the figure, it is very clear that, if the side of the square is a, then
a?2 = 2r
a = ?2r
Also, in reuleaux triangle, h = a = ?2r, please refer Biggest Reuleaux Triangle within A Square.
So, Area of the Reuleaux Triangle is, A = 0.70477*h^2 = 0.70477*2*r^2
C++
#include <bits/stdc++.h>
using namespace std;
float ReuleauxArea( float r)
{
if (r < 0)
return -1;
float A = 0.70477 * 2 * pow (r, 2);
return A;
}
int main()
{
float r = 6;
cout << ReuleauxArea(r) << endl;
return 0;
}
|
Java
import java.util.*;
class GFG
{
static double ReuleauxArea( double r)
{
if (r < 0 )
return - 1 ;
double A = 0.70477 * 2 * Math.pow(r, 2 );
return A;
}
public static void main(String args[])
{
double r = 6 ;
System.out.println(ReuleauxArea(r));
}
}
|
Python3
import math as mt
def ReuleauxArea(r):
if (r < 0 ):
return - 1
A = 0.70477 * 2 * pow (r, 2 )
return A
r = 6
print (ReuleauxArea(r))
|
C#
using System;
class GFG
{
static double ReuleauxArea( double r)
{
if (r < 0)
return -1;
double A = 0.70477 * 2 * Math.Pow(r, 2);
return A;
}
public static void Main()
{
double r = 6;
Console.WriteLine(ReuleauxArea(r));
}
}
|
PHP
<?php
function ReuleauxArea( $r )
{
if ( $r < 0)
return -1;
$A = 0.70477 * 2 * pow( $r , 2);
return $A ;
}
$r = 6;
echo ReuleauxArea( $r ) . "\n" ;
?>
|
Javascript
<script>
function ReuleauxArea(r)
{
if (r < 0)
return -1;
var A = 0.70477 * 2 * Math.pow(r, 2);
return A;
}
var r = 6;
document.write(ReuleauxArea(r));
</script>
|
Time Complexity: O(1)
Auxiliary Space: O(1)
Share your thoughts in the comments
Please Login to comment...