在这里,我们将看到如何计算如下的Reuleaux三角形的面积。Reuleaux三角形内部有一个等边三角形。假设其高度为h,这个形状是由三个圆的交集组成的。
有三个圆形扇区。每个扇区的面积为−
由于等边三角形的面积被加了三次,所以我们必须减去它们。因此最终的面积为−
例子
'#include <iostream>
#include <cmath>
using namespace std;
float areaReuleaux(float h) {
if (h < 0) //if h is negative it is invalid
return -1;
float area = ((3.1415 - sqrt(3)) * h * h)/2;
return area;
}
int main() {
float height = 6;
cout << "Area of Reuleaux Triangle: " << areaReuleaux(height);
}
输出
'Area of Reuleaux Triangle: 25.3701