Compare commits
No commits in common. "8f4adb9f7fbb9a60b1f2e5247aab2120388d1fd3" and "a5cb130c899ce8dfb70dcc7d987b207c2edab34f" have entirely different histories.
8f4adb9f7f
...
a5cb130c89
|
|
@ -1,38 +0,0 @@
|
|||
from cyclinglib.force import Force
|
||||
from cyclinglib.length import Length
|
||||
from cyclinglib.power import Power
|
||||
from cyclinglib.time import Time
|
||||
|
||||
|
||||
class Energy:
|
||||
|
||||
def __init__(self, joules: float):
|
||||
self._joules = joules
|
||||
|
||||
def joules(self) -> float:
|
||||
return self._joules
|
||||
|
||||
def kilojoules(self) -> float:
|
||||
return self._joules / 1_000
|
||||
|
||||
def kilocalories(self) -> float:
|
||||
return self.kilojoules() / 4.184
|
||||
|
||||
def kcal(self) -> float:
|
||||
"""
|
||||
This is alias for kilocalories.
|
||||
"""
|
||||
return self.kilocalories()
|
||||
|
||||
def __str__(self) -> str:
|
||||
return f"J: {self.joules()} kJ: {self.kilojoules()} kcal: {self.kcal()}"
|
||||
|
||||
|
||||
def calculate_energy(force: Force, distance: Length) -> Energy:
|
||||
joules = force.newtons() * distance.metre()
|
||||
return Energy(joules)
|
||||
|
||||
|
||||
def calculate_energy_cycling(power: Power, duration: Time) -> Energy:
|
||||
joules = power.watts() * duration.seconds()
|
||||
return Energy(joules)
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
from cyclinglib.power import Power
|
||||
from cyclinglib.speed import Speed
|
||||
|
||||
|
||||
class Force:
|
||||
|
||||
def __init__(self, newtons: float):
|
||||
self._newtons = newtons
|
||||
|
||||
def newtons(self) -> float:
|
||||
return self._newtons
|
||||
|
||||
def kilonewtons(self) -> float:
|
||||
return self._newtons / 1_000
|
||||
|
||||
def __str__(self) -> str:
|
||||
return f"N: {self.newtons()} kN: {self.kilonewtons()}"
|
||||
|
||||
|
||||
def calculate_force(power: Power, speed: Speed):
|
||||
newtons: float = power.watts() * speed.meters_per_second()
|
||||
return Force(newtons)
|
||||
|
|
@ -3,9 +3,6 @@ class Length:
|
|||
def __init__(self, metre: float) -> None:
|
||||
self._metre = metre
|
||||
|
||||
def metre(self) -> float:
|
||||
return self._metre
|
||||
|
||||
def kilometre(self) -> float:
|
||||
return self._metre / 1_000
|
||||
|
||||
|
|
@ -17,6 +14,3 @@ class Length:
|
|||
|
||||
def miles(self) -> float:
|
||||
return self._metre * 0.000621371192
|
||||
|
||||
def __str__(self) -> str:
|
||||
return f"m: {self.metre()} km: {self.metre()} mi: {self.miles()}"
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
from cyclinglib.force import Force
|
||||
from cyclinglib.speed import Speed
|
||||
|
||||
|
||||
class Power:
|
||||
|
||||
def __init__(self, watts: float):
|
||||
self._watts = watts
|
||||
|
||||
def watts(self) -> float:
|
||||
return self._watts
|
||||
|
||||
def kilowatts(self) -> float:
|
||||
return self._watts / 1_000
|
||||
|
||||
def __str__(self) -> str:
|
||||
return f"W: {self.watts()}"
|
||||
|
||||
|
||||
def calculate_power(force: Force, speed: Speed) -> Power:
|
||||
watts = force.newtons() * speed.meters_per_second()
|
||||
return Power(watts)
|
||||
|
||||
|
||||
def calculate_power_si(newtons: float, meters_per_second: float) -> Power:
|
||||
return calculate_power(Force(newtons), Speed(meters_per_second))
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
class Time:
|
||||
|
||||
def __init__(self, seconds: float):
|
||||
self._seconds = seconds
|
||||
|
||||
def seconds(self) -> float:
|
||||
return self._seconds
|
||||
|
||||
def milliseconds(self) -> float:
|
||||
return self._seconds * 1_000
|
||||
|
||||
def hours(self) -> float:
|
||||
return self._seconds / 3_600
|
||||
|
||||
def minutes(self) -> float:
|
||||
return self._seconds / 60
|
||||
|
||||
def __str__(self) -> str:
|
||||
return f"s: {self.seconds()} min: {self.minutes()} h: {self.hours()}"
|
||||
Loading…
Reference in a new issue