Skip to content

Commit

Permalink
Add the volume property for the ellipsoid (#132)
Browse files Browse the repository at this point in the history
Checked against approximate values reported at
https://en.wikipedia.org/wiki/Earth
  • Loading branch information
leouieda committed Jun 24, 2022
1 parent 4ad4953 commit 13a6428
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions boule/_ellipsoid.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ class Ellipsoid:
8.2094437949696e-02
>>> print(f"{ellipsoid.mean_radius:.4f} m")
6371008.7714 m
>>> print(f"{ellipsoid.volume * 1e-9:.5e} km³")
1.08321e+12 km³
>>> print(f"{ellipsoid.gravity_equator:.10f} m/s²")
9.7803253359 m/s²
>>> print(f"{ellipsoid.gravity_pole:.10f} m/s²")
Expand Down Expand Up @@ -217,6 +219,15 @@ def mean_radius(self):
"""
return 1 / 3 * (2 * self.semimajor_axis + self.semiminor_axis)

@property
def volume(self):
r"""
The volume bounded by the ellipsoid.
Definition: :math:`V = \dfrac{4}{3} \pi a^2 c`.
Units: :math:`m^3`.
"""
return (4 / 3 * np.pi) * self.semimajor_axis**2 * self.semiminor_axis

@property
def _emm(self):
"Auxiliary quantity used to calculate gravity at the pole and equator"
Expand Down

0 comments on commit 13a6428

Please sign in to comment.