Skip to content

Commit 922c2e1

Browse files
authored
Implement volume calculation for ellipsoid
Added a method to calculate the volume of an ellipsoid.
1 parent 76c45c1 commit 922c2e1

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/main/java/com/thealgorithms/maths/Volume.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,4 +125,16 @@ public static double volumeFrustumOfPyramid(double upperBaseArea, double lowerBa
125125
public static double volumeTorus(double majorRadius, double minorRadius) {
126126
return 2 * Math.PI * Math.PI * majorRadius * minorRadius * minorRadius;
127127
}
128+
129+
130+
/**
131+
* Calculate the volume of an ellipsoid.
132+
*
133+
* @param a first semi-axis of an ellipsoid
134+
* @param b second semi-axis of an ellipsoid
135+
* @param c third semi-axis of an ellipsoid
136+
* @return volume of the ellipsoid
137+
*/
138+
public static double volumeEllipsoid(double a, double b, double c)
139+
return 4 / 3 * Math.PI * a * b * c;
128140
}

0 commit comments

Comments
 (0)