Search Results

Search found 1 results on 1 pages for 'user3678321'.

Page 1/1 | 1 

  • Surface Area of a Spheroid in Python

    - by user3678321
    I'm trying to write a function that calculates the surface area of a prolate or oblate spheroid. Here's a link to where I got the formulas (http://en.wikipedia.org/wiki/Prolate_spheroid & http://en.wikipedia.org/wiki/Oblate_spheroid). I think I've written them wrong, but here is my code so far; from math import pi, sqrt, asin, degrees, tanh def checkio(height, width): height = float(height) width = float(width) lst = [] if height == width: r = 0.5 * width surface_area = 4 * pi * r**2 surface_area = round(surface_area, 2) lst.append(surface_area) elif height > width: #If spheroid is prolate a = 0.5 * width b = 0.5 * height e = 1 - a / b surface_area = 2 * pi * a**2 * (1 + b / a * e * degrees(asin**-1(e))) surface_area = round(surface_area, 2) lst.append(surface_area) elif height < width: #If spheroid is oblate a = 0.5 * height b = 0.5 * width e = 1 - b / a surface_area = 2 * pi * a**2 * (1 + 1 - e**2 / e * tanh**-1(e)) surface_area = round(surface_area, 2) lst.append(surface_area, 2) return lst

    Read the article

1