From a0a18f35acb27d2abedafc62ca88a7075ff97294 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Sun, 23 Feb 2020 17:40:01 +0100 Subject: [PATCH] Momentum support added --- src/include/units/physical/dimensions.h | 6 ++++ src/include/units/physical/si/momentum.h | 46 ++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 src/include/units/physical/si/momentum.h diff --git a/src/include/units/physical/dimensions.h b/src/include/units/physical/dimensions.h index c8202793..25d3f5ce 100644 --- a/src/include/units/physical/dimensions.h +++ b/src/include/units/physical/dimensions.h @@ -80,6 +80,9 @@ struct dim_acceleration : derived_dimension, exp> {}; template M, DimensionOf A> struct dim_force : derived_dimension, exp> {}; +template M, DimensionOf V> +struct dim_momentum : derived_dimension, exp> {}; + template F, DimensionOf L> struct dim_energy : derived_dimension, exp> {}; @@ -148,6 +151,9 @@ concept Acceleration = physical::QuantityOf; template concept Force = physical::QuantityOf; +template +concept Momentum = physical::QuantityOf; + template concept Energy = physical::QuantityOf; diff --git a/src/include/units/physical/si/momentum.h b/src/include/units/physical/si/momentum.h new file mode 100644 index 00000000..7b9b709c --- /dev/null +++ b/src/include/units/physical/si/momentum.h @@ -0,0 +1,46 @@ +// 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 +#include + +namespace units::si { + +struct kilogram_metre_per_second : unit {}; +struct dim_momentum : physical::dim_momentum {}; + +template +using momentum = quantity; + +inline namespace literals { + +// kgmps +constexpr auto operator"" q_kgmps(unsigned long long l) { return momentum(l); } +constexpr auto operator"" q_kgmps(long double l) { return momentum(l); } + +} // namespace literals + +} // namespace units::si