Skip to content

Commit 5651c28

Browse files
authored
Improve documentation for Side and ellipse perimeter
Updated docstring for Side class and added reference for ellipse perimeter calculation.
1 parent 467e638 commit 5651c28

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

‎geometry/geometry.py‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def from_radians(cls, radians: float) -> Angle:
5353
@dataclass
5454
class Side:
5555
"""
56-
A side of a two dimensional Shape such as Polygon, etc.
56+
A side of a two-dimensional shape such as Polygon, etc.
5757
adjacent_sides: a list of sides which are adjacent to the current side
5858
angle: the angle in degrees between each adjacent side
5959
length: the length of the current side in meters
@@ -118,14 +118,15 @@ def area(self) -> float:
118118
@property
119119
def perimeter(self) -> float:
120120
"""
121+
Use Ramanujan's first approximation for ellipse perimeter.
122+
https://en.wikipedia.org/wiki/Perimeter_of_an_ellipse#First_approximation
123+
121124
>>> Ellipse(5, 10).perimeter
122125
48.44210548835644
123126
>>> Ellipse(1, 10).perimeter
124-
48.44210548835644
127+
40.60552518514097
125128
"""
126129
a, b = self.major_radius, self.minor_radius
127-
# Use Ramanujan's first approximation for ellipse perimeter
128-
# https://en.wikipedia.org/wiki/Perimeter_of_an_ellipse#First_approximation
129130
return math.pi * (3 * (a + b) - ((3 * a + b) * (a + 3 * b)) ** 0.5)
130131

131132
@property

0 commit comments

Comments
 (0)