Horje
Biggest Reuleaux Triangle inscribed within a square inscribed in a semicircle

Given here is a semicircle 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 : x = 5  
Output : 14.0954

Input : x = 8
Output : 36.0842

 

 

Approach:We know, the side of the square inscribed within a semicircle is, a = 2r/?5. (Please refer here)
Also, in the reuleaux triangle, x = a
So, x = 2*r/?5 
So, Area of Reuleaux Triangle
 

A = 0.70477*x^2 = 0.70477*(r^2/5)

Below is the implementation of the above approach: 
 

C++

<?php
// PHP Program to find the biggest Reuleaux
// triangle inscribed within in a square
// which in turn is inscribed within a semicircle
 
// Function to find the biggest
// reuleaux triangle
function Area($r)
{
 
    // radius cannot be negative
    if ($r < 0)
        return -1;
 
    // height of the reuleaux triangle
    $x = (2 * $r) / sqrt(5);
 
    // area of the reuleaux triangle
    $A = 0.70477 * pow($x, 2);
 
    return $A ;
}
 
// Driver code
$r = 5;
 
echo Area($r);
     
// This code is contributed by Ryuga
?>

Javascript

<script>
// javascript Program to find the biggest
// Reuleaux triangle inscribed within
// in a square which in turn is
// inscribed within a semicircle
 
// Function to find the biggest reuleaux triangle
function Area(r)
{
 
    // radius cannot be negative
    if (r < 0)
        return -1;
 
    // height of the reuleaux triangle
    var x = (2 * r) /(Math.sqrt(5));
 
    // area of the reuleaux triangle
    var A = 0.70477 *(Math.pow(x, 2));
    return A;
}
 
// Driver code
var r = 5;
document.write(Area(r).toFixed(4));
 
 
// This code is contributed by Princi Singh
</script>

Output: 

14.0954

 

Time Complexity: O(1)

Auxiliary Space: O(1)




Reffered: https://www.geeksforgeeks.org


C++ Programs

Related
Biggest Reuleaux Triangle inscribed within a Square inscribed in an equilateral triangle Biggest Reuleaux Triangle inscribed within a Square inscribed in an equilateral triangle
Clockwise Spiral Traversal of Binary Tree Clockwise Spiral Traversal of Binary Tree
Reverse Middle X Characters Reverse Middle X Characters
Largest number less than or equal to N/2 which is coprime to N Largest number less than or equal to N/2 which is coprime to N
Print multiples of Unit Digit of Given Number Print multiples of Unit Digit of Given Number

Type:
Geek
Category:
Coding
Sub Category:
Tutorial
Uploaded by:
Admin
Views:
10