diff --git a/pyndulum/pendulum_equations.py b/pyndulum/pendulum_equations.py index 40654b9..552faa7 100644 --- a/pyndulum/pendulum_equations.py +++ b/pyndulum/pendulum_equations.py @@ -93,6 +93,18 @@ def bpm(len: float) -> float: """ return 60.0 / get_period(len) +def length_from_period(p: float) -> float: + """ + Calculate the length of a pendulum based on period. + + Parameters + ---------- + p : float + period [s] for a swing of the pendulum + length of the pendulum [m] + """ + return ((p / 2.0 * np.pi) ** 2) * 9.81 + def energy(m: float, len: float, theta: float) -> float: """ Calculate the energy of a pendulum. @@ -111,4 +123,4 @@ def energy(m: float, len: float, theta: float) -> float: float energy [kg . m2 /s2] of the pendulum """ - return m * 9.81 * max_height(len, theta) + return m * 9.81 * max_height(len, theta) \ No newline at end of file