Skip to content

Commit

Permalink
Add a volume property for the Sphere
Browse files Browse the repository at this point in the history
Nothing fancy, just output the volume.
  • Loading branch information
leouieda committed Feb 22, 2024
1 parent da569d3 commit 23e0017
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions boule/_sphere.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ class Sphere:
0
>>> print(sphere.thirdflattening)
0
>>> print(f"{sphere.volume:.10f} m³")
4.1887902048 m³
"""

Expand Down Expand Up @@ -174,6 +176,15 @@ def first_eccentricity(self):
"""
return 0

@property
def volume(self):
r"""
The volume of the sphere.
Definition: :math:`V = \dfrac{4}{3} \pi r^3`.
Units: :math:`m^3`.
"""
return (4 / 3 * np.pi) * self.radius**3

def normal_gravity(self, latitude, height, si_units=False):
r"""
Normal gravity of the sphere at the given latitude and height.
Expand Down

0 comments on commit 23e0017

Please sign in to comment.