สูตร
เส้นทแยงมุมของรูปห้าเหลี่ยมสมมาตร ที่มีด้าน = s
Diagonal = (1 + √5) / 2 × s ≈ 1.618 × s (Golden Ratio × s)
โปรแกรมตัวอย่าง
#include <iostream>
#include <cmath>
using namespace std;
int main() {
float side = 5;
if (side < 0) return -1;
float diagonal = (1 + sqrt(5)) / 2 * side;
cout << "Diagonal of regular pentagon = " << diagonal;
return 0;
}
ผลลัพธ์
Diagonal of regular pentagon = 8.09