Area of Reuleaux Triangle
Last Updated :
01 Sep, 2022
Given an integer h which is the side of an equilateral triangle formed by the same vertices as the Reuleaux triangle, the task is to find and print the area of the Reuleaux triangle.
Examples:
Input: h = 6
Output: 25.3717
Input: h = 9
Output: 57.0864
Approach: The shape made by the intersection of the three circles ABC is the Reuleaux Triangle and the triangle formed by the same vertices i.e. ABC is an equilateral triangle with side h.
Now, Area of sector ACB, A1 = (? * h2) / 6
Similarly, Area of sector CBA, A2 = (? * h2) / 6
And, Area of sector BAC, A3 = (? * h2) / 6
So, A1 + A2 + A3 = (? * h2) / 2
Since, the area of the triangle is added thrice in the sum.
So, Area of the Reuleaux Triangle, A = (? * h2) / 2 – 2 * (Area of equilateral triangle) = (? – ?3) * h2 / 2 = 0.70477 * h2
Below is the implementation of the above approach:
C++
#include <bits/stdc++.h>
using namespace std;
float ReuleauxArea( float a)
{
if (a < 0)
return -1;
float A = 0.70477 * pow (a, 2);
return A;
}
int main()
{
float a = 6;
cout << ReuleauxArea(a) << endl;
return 0;
}
|
Java
public class GFG
{
static double ReuleauxArea( float a)
{
if (a < 0 )
return - 1 ;
double A = ( double ) 0.70477 * Math.pow(a, 2 );
return A;
}
public static void main(String args[])
{
float a = 6 ;
System.out.println(ReuleauxArea(a)) ;
}
}
|
Python3
import math as mt
def ReuleauxArea(a):
if a < 0 :
return - 1
return 0.70477 * pow (a, 2 )
a = 6
print (ReuleauxArea(a))
|
C#
using System;
public class GFG
{
static double ReuleauxArea( float a)
{
if (a < 0)
return -1;
double A = ( double )0.70477 * Math.Pow(a, 2);
return A;
}
public static void Main()
{
float a = 6;
Console.WriteLine(ReuleauxArea(a)) ;
}
}
|
PHP
<?php
function ReuleauxArea( $a )
{
if ( $a < 0)
return -1;
$A = 0.70477 * pow( $a , 2);
return $A ;
}
$a = 6;
echo ReuleauxArea( $a );
|
Javascript
<script>
function ReuleauxArea(a)
{
if (a < 0)
return -1;
var A = 0.70477 * Math.pow(a, 2);
return A;
}
var a = 6;
document.write(ReuleauxArea(a)) ;
</script>
|
Time Complexity: O(1)
Auxiliary Space: O(1)
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...