To find the volume of a regular polygon circumscribed around a sphere, we need to know the side length of the polygon and the radius of the sphere. Here's a C# method that calculates the volume using the formula:
main.cs41 chars2 lines
Where V is the volume, Pi is the mathematical constant pi (~3.14), R is the radius of the sphere, N is the number of sides of the polygon, and Tan() is the tangent function.
main.cs257 chars8 lines
You can call this method with the number of sides of your regular polygon and the radius of your sphere to get the volume of the polygon:
main.cs239 chars5 lines
Output:
main.cs94 chars2 lines
gistlibby LogSnag