From c50ab524824d765ba4dc1b659fc5c0da5c787a67 Mon Sep 17 00:00:00 2001 From: unexcellent <> Date: Wed, 20 Nov 2024 11:35:43 +0100 Subject: [PATCH] feat: add AngularVelocity --- generate/generate_boilerplate.py | 4 ++++ quantio/quantities.py | 35 ++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/generate/generate_boilerplate.py b/generate/generate_boilerplate.py index c5c1930..673bd49 100644 --- a/generate/generate_boilerplate.py +++ b/generate/generate_boilerplate.py @@ -111,6 +111,10 @@ def _generat_zero_function(current_class: str) -> list[str]: "degrees": "(3.141592653589793 / 180)", "radians": "1", }, + "AngularVelocity": { + "degrees_per_second": "(3.141592653589793 / 180)", + "radians_per_second": "1", + }, "Area": { "square_miles": "1609.34**2", "square_kilometers": "10 ** (3 * 2)", diff --git a/quantio/quantities.py b/quantio/quantities.py index 254dda5..aca001e 100644 --- a/quantio/quantities.py +++ b/quantio/quantities.py @@ -73,6 +73,41 @@ def zero(cls) -> Angle: # --- End of auto generated part. --- +class AngularVelocity(_QuantityBase): + """The change in angle per time.""" + + # --- This part is auto generated. Do not change manually. --- + + BASE_UNIT = "radians_per_second" + + @property + def degrees_per_second(self) -> float: + """The angularvelocity in degrees per second.""" + return self._base_value / (3.141592653589793 / 180) + + @property + def radians_per_second(self) -> float: + """The angularvelocity in radians per second.""" + return self._base_value / 1 + + def __init__( + self, + _base_value: float = 0.0, + degrees_per_second: float = 0.0, + radians_per_second: float = 0.0, + ) -> None: + self._base_value = _base_value + self._base_value += degrees_per_second * (3.141592653589793 / 180) + self._base_value += radians_per_second * 1 + + @classmethod + def zero(cls) -> AngularVelocity: + """Create a AngularVelocity with a value of zero.""" + return AngularVelocity() + + # --- End of auto generated part. --- + + class Area(_QuantityBase): """The two-dimensional extent of an object."""