From a92a315bda6be247ed6df1ec2c0dfe772b897d1c Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Thu, 1 Sep 2022 12:05:20 +0200 Subject: [PATCH] feat: angular acceleration support added --- src/systems/isq/CMakeLists.txt | 1 + .../isq/include/units/isq/dimensions.h | 1 + .../isq/dimensions/angular_acceleration.h | 40 ++++++++++ src/systems/si/CMakeLists.txt | 1 + .../units/isq/si/angular_acceleration.h | 76 +++++++++++++++++++ src/systems/si/include/units/isq/si/si.h | 1 + test/unit_test/static/si_test.cpp | 6 ++ 7 files changed, 126 insertions(+) create mode 100644 src/systems/isq/include/units/isq/dimensions/angular_acceleration.h create mode 100644 src/systems/si/include/units/isq/si/angular_acceleration.h diff --git a/src/systems/isq/CMakeLists.txt b/src/systems/isq/CMakeLists.txt index bb575c65..029ebfe2 100644 --- a/src/systems/isq/CMakeLists.txt +++ b/src/systems/isq/CMakeLists.txt @@ -28,6 +28,7 @@ add_units_module( HEADERS include/units/isq/dimensions/absorbed_dose.h include/units/isq/dimensions/acceleration.h include/units/isq/dimensions/amount_of_substance.h + include/units/isq/dimensions/angular_acceleration.h include/units/isq/dimensions/angular_velocity.h include/units/isq/dimensions/area.h include/units/isq/dimensions/capacitance.h diff --git a/src/systems/isq/include/units/isq/dimensions.h b/src/systems/isq/include/units/isq/dimensions.h index 4983390c..5d226fcb 100644 --- a/src/systems/isq/include/units/isq/dimensions.h +++ b/src/systems/isq/include/units/isq/dimensions.h @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include diff --git a/src/systems/isq/include/units/isq/dimensions/angular_acceleration.h b/src/systems/isq/include/units/isq/dimensions/angular_acceleration.h new file mode 100644 index 00000000..a5d38a23 --- /dev/null +++ b/src/systems/isq/include/units/isq/dimensions/angular_acceleration.h @@ -0,0 +1,40 @@ +// The MIT License (MIT) +// +// Copyright (c) 2018 Mateusz Pusz +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +#pragma once + +#include +#include +#include + +namespace units::isq { + +template +struct dim_angular_acceleration; + +template A, DimensionOfT T> +struct dim_angular_acceleration : derived_dimension, exponent> {}; + +template +concept AngularAcceleration = QuantityOfT; + +} // namespace units::isq diff --git a/src/systems/si/CMakeLists.txt b/src/systems/si/CMakeLists.txt index 052d6d3c..f4a59f96 100644 --- a/src/systems/si/CMakeLists.txt +++ b/src/systems/si/CMakeLists.txt @@ -28,6 +28,7 @@ add_units_module( HEADERS include/units/isq/si/absorbed_dose.h include/units/isq/si/acceleration.h include/units/isq/si/amount_of_substance.h + include/units/isq/si/angular_acceleration.h include/units/isq/si/angular_velocity.h include/units/isq/si/area.h include/units/isq/si/capacitance.h diff --git a/src/systems/si/include/units/isq/si/angular_acceleration.h b/src/systems/si/include/units/isq/si/angular_acceleration.h new file mode 100644 index 00000000..4899448b --- /dev/null +++ b/src/systems/si/include/units/isq/si/angular_acceleration.h @@ -0,0 +1,76 @@ +// The MIT License (MIT) +// +// Copyright (c) 2018 Mateusz Pusz +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +#pragma once + +// IWYU pragma: begin_exports +#include +#include +#include +// IWYU pragma: end_exports + +#include +#include +#include +#include + +namespace units::isq::si { + +struct radian_per_second_sq : derived_unit {}; + +struct dim_angular_acceleration : + isq::dim_angular_acceleration, dim_time> {}; + +template U, Representation Rep = double> +using angular_acceleration = quantity; + +#ifndef UNITS_NO_LITERALS + +inline namespace literals { + +// rad/s2 +constexpr auto operator"" _q_rad_per_s2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return angular_acceleration(static_cast(l)); +} +constexpr auto operator"" _q_rad_per_s2(long double l) +{ + return angular_acceleration(l); +} + +} // namespace literals + +#endif // UNITS_NO_LITERALS + +} // namespace units::isq::si + +#ifndef UNITS_NO_ALIASES + +namespace units::aliases::isq::si::inline angular_acceleration { + +template +using rad_per_s2 = units::isq::si::angular_acceleration; + +} // namespace units::aliases::isq::si::inline angular_acceleration + +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/si.h b/src/systems/si/include/units/isq/si/si.h index 369d6f3d..683047fb 100644 --- a/src/systems/si/include/units/isq/si/si.h +++ b/src/systems/si/include/units/isq/si/si.h @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include diff --git a/test/unit_test/static/si_test.cpp b/test/unit_test/static/si_test.cpp index 05776df7..2299a0f5 100644 --- a/test/unit_test/static/si_test.cpp +++ b/test/unit_test/static/si_test.cpp @@ -404,4 +404,10 @@ static_assert(detail::unit_text() == "J/mol"); static_assert(1_q_rad / 1_q_s == 1_q_rad_per_s); static_assert(detail::unit_text() == "rad/s"); +// angular acceleration + +static_assert(1_q_rad_per_s / 1_q_s == 1_q_rad_per_s2); +static_assert(detail::unit_text() == + basic_symbol_text("rad/s²", "rad/s^2")); + } // namespace