Gear ratio can now calculate speed at given cadence.
This commit is contained in:
parent
5a154e1722
commit
07cffdea01
|
|
@ -1,7 +1,20 @@
|
||||||
|
from cyclinglib.speed import Speed
|
||||||
|
|
||||||
|
|
||||||
class GearRatio:
|
class GearRatio:
|
||||||
|
|
||||||
def __init__(self, front_teeth: int, rear_teeth: int):
|
def __init__(self, front_teeth: int, rear_teeth: int):
|
||||||
self._gear_ratio: float = front_teeth / rear_teeth
|
self._gear_ratio: float = front_teeth / rear_teeth
|
||||||
|
|
||||||
|
def speed_at_cadence(self, cadence: int,
|
||||||
|
wheel_circumference_mm: int) -> Speed:
|
||||||
|
"""
|
||||||
|
Cadence is specified in revolutions per minute.
|
||||||
|
"""
|
||||||
|
revolutions_per_second = cadence / 60
|
||||||
|
wheel_circumference_m = wheel_circumference_mm / 1_000
|
||||||
|
return Speed(wheel_circumference_m * revolutions_per_second *
|
||||||
|
self._gear_ratio)
|
||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
return f"Gear ratio: {self._gear_ratio}"
|
return f"Gear ratio: {self._gear_ratio}"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue