📜  椭圆体体积计算程序

📅  最后修改于: 2021-04-23 05:29:34             🧑  作者: Mango

椭圆形,其所有平面横截面均为椭圆或圆形的闭合表面。椭球关于在中心相交的三个相互垂直的轴对称。它是三维封闭的几何形状,其所有平面部分均为椭圆形或圆形。
椭球具有三个独立的轴,通常由三个半轴的长度a,b,c指定。如果通过使椭圆围绕其轴之一旋转来制作椭球,则椭球的两个轴是相同的,称为旋转椭球或椭球。如果其三个轴的长度都相同,则为球形。

Standard equation of Ellipsoid :
x2 / a2 + y2 / b2 + z2 / c2 = 1
   
where a, b, c are positive real numbers.
Volume of Ellipsoid :  (4/3) * pi * r1 * r2 * r3 

下面是计算椭球体积的代码:

C++
// CPP program to find the
// volume of Ellipsoid.
#include 
using namespace std;
 
// Function to find the volume
float volumeOfEllipsoid(float r1,
                        float r2,
                        float r3)
{
    float pi = 3.14;
    return 1.33 * pi * r1 *
                  r2 * r3;
}
 
// Driver Code
int main()
{
    float r1 = 2.3, r2 = 3.4, r3 = 5.7;
    cout << "volume of ellipsoid is : "
         << volumeOfEllipsoid(r1, r2, r3);
    return 0;
}


Java
// Java program to find the
// volume of Ellipsoid.
import java.util.*;
import java.lang.*;
 
class GfG
{
     
    // Function to find the volume
    public static float volumeOfEllipsoid(float r1,
                                          float r2,
                                          float r3)
    {
        float pi = (float)3.14;
        return (float) 1.33 * pi * r1 * r2 * r3;
    }
 
    // Driver Code
    public static void main(String args[])
    {
        float r1 = (float) 2.3,
              r2 = (float) 3.4,
              r3 = (float) 5.7;
        System.out.println("volume of ellipsoid is : "
                    + volumeOfEllipsoid(r1, r2, r3));
    }
}
 
// This code is contributed by Sagar Shukla


Python
''' Python3 program to Volume of ellipsoid'''
import math
 
# Function To calculate Volume
def volumeOfEllipsoid(r1, r2, r3):
    return 1.33 * math.pi * r1 * r2 * r3
 
 
# Driver Code
r1 = float(2.3)
r2 = float(3.4)
r3 = float(5.7)
print( "Volume of ellipsoid is : ",
        volumeOfEllipsoid(r1, r2, r3) )


C#
// C# program to find the
// volume of Ellipsoid.
using System;
 
class GfG
{
     
    // Function to find the volume
    public static float volumeOfEllipsoid(float r1,
                                            float r2,
                                            float r3)
    {
        float pi = (float)3.14;
        return (float) 1.33 * pi * r1 * r2 * r3;
    }
 
    // Driver Code
    public static void Main()
    {
        float r1 = (float)2.3,
            r2 =(float) 3.4,
            r3 = (float)5.7;
        Console.WriteLine("volume of ellipsoid is : " +
                        volumeOfEllipsoid(r1, r2, r3));
    }
}
 
// This code is contributed by vt_m


PHP


Javascript


输出 :

Volume of ellipsoid is : 186.15