Skip to content

Commit 3170192

Browse files
authored
Merge pull request #1 from avyukth-fll/avyukth-fll-patch-1
Ellipse perimeter calculation
2 parents de8d2d7 + d2346f8 commit 3170192

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

geometry/geometry.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,11 @@ def area(self) -> float:
103103
def perimeter(self) -> float:
104104
"""
105105
>>> Ellipse(5, 10).perimeter
106-
47.12388980384689
106+
48.44222344723793
107107
"""
108-
return math.pi * (self.major_radius + self.minor_radius)
108+
a, b = self.major_radius, self.minor_radius
109+
#uses ramanujans approximation
110+
return math.pi * (3*(a + b) - ((3*a + b)*(a + 3*b))**0.5)
109111

110112

111113
class Circle(Ellipse):

0 commit comments

Comments
 (0)