mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-05 21:24:27 +02:00
feat: luminous_flux
support added
This commit is contained in:
@@ -49,6 +49,7 @@ add_units_module(
|
||||
include/units/isq/dimensions/inductance.h
|
||||
include/units/isq/dimensions/length.h
|
||||
include/units/isq/dimensions/luminance.h
|
||||
include/units/isq/dimensions/luminous_flux.h
|
||||
include/units/isq/dimensions/luminous_intensity.h
|
||||
include/units/isq/dimensions/magnetic_flux.h
|
||||
include/units/isq/dimensions/magnetic_induction.h
|
||||
|
@@ -48,6 +48,7 @@
|
||||
#include <units/isq/dimensions/inductance.h>
|
||||
#include <units/isq/dimensions/length.h>
|
||||
#include <units/isq/dimensions/luminance.h>
|
||||
#include <units/isq/dimensions/luminous_flux.h>
|
||||
#include <units/isq/dimensions/luminous_intensity.h>
|
||||
#include <units/isq/dimensions/magnetic_flux.h>
|
||||
#include <units/isq/dimensions/magnetic_induction.h>
|
||||
|
36
src/systems/isq/include/units/isq/dimensions/luminous_flux.h
Normal file
36
src/systems/isq/include/units/isq/dimensions/luminous_flux.h
Normal file
@@ -0,0 +1,36 @@
|
||||
// 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 <units/concepts.h>
|
||||
#include <units/isq/dimensions/power.h>
|
||||
|
||||
namespace units::isq {
|
||||
|
||||
template<typename Child, Unit U, typename... Dims>
|
||||
using dim_luminous_flux = dim_power<Child, U, Dims...>;
|
||||
|
||||
template<typename T>
|
||||
concept LuminousFlux = QuantityOfT<T, dim_luminous_flux>;
|
||||
|
||||
} // namespace units::isq
|
@@ -50,6 +50,7 @@ add_units_module(
|
||||
include/units/isq/si/inductance.h
|
||||
include/units/isq/si/length.h
|
||||
include/units/isq/si/luminance.h
|
||||
include/units/isq/si/luminous_flux.h
|
||||
include/units/isq/si/luminous_intensity.h
|
||||
include/units/isq/si/magnetic_flux.h
|
||||
include/units/isq/si/magnetic_induction.h
|
||||
|
89
src/systems/si/include/units/isq/si/luminous_flux.h
Normal file
89
src/systems/si/include/units/isq/si/luminous_flux.h
Normal file
@@ -0,0 +1,89 @@
|
||||
// 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 <units/isq/si/power.h>
|
||||
#include <units/quantity.h>
|
||||
#include <units/reference.h>
|
||||
#include <units/symbol_text.h>
|
||||
// IWYU pragma: end_exports
|
||||
|
||||
#include <units/isq/si/prefixes.h>
|
||||
#include <units/unit.h>
|
||||
|
||||
namespace units::isq::si {
|
||||
|
||||
// TODO Is this correct? Should we account for steradian here? How?
|
||||
|
||||
struct lumen : named_scaled_unit<lumen, "lm", ratio(1, 683), watt> {};
|
||||
|
||||
using dim_luminous_flux = dim_power;
|
||||
|
||||
template<UnitOf<dim_luminous_flux> U, Representation Rep = double>
|
||||
using luminous_flux = power<U, Rep>;
|
||||
|
||||
#ifndef UNITS_NO_LITERALS
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
// lm
|
||||
constexpr auto operator"" _q_lm(unsigned long long l)
|
||||
{
|
||||
gsl_ExpectsAudit(std::in_range<std::int64_t>(l));
|
||||
return luminous_flux<lumen, std::int64_t>(static_cast<std::int64_t>(l));
|
||||
}
|
||||
constexpr auto operator"" _q_lm(long double l) { return luminous_flux<lumen, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
#endif // UNITS_NO_LITERALS
|
||||
|
||||
#ifndef UNITS_NO_REFERENCES
|
||||
|
||||
namespace luminous_flux_references {
|
||||
|
||||
inline constexpr auto lm = reference<dim_luminous_flux, lumen>{};
|
||||
|
||||
} // namespace luminous_flux_references
|
||||
|
||||
namespace references {
|
||||
|
||||
using namespace luminous_flux_references;
|
||||
|
||||
} // namespace references
|
||||
|
||||
#endif // UNITS_NO_REFERENCES
|
||||
|
||||
} // namespace units::isq::si
|
||||
|
||||
#ifndef UNITS_NO_ALIASES
|
||||
|
||||
namespace units::aliases::isq::si::inline luminous_flux {
|
||||
|
||||
template<Representation Rep = double>
|
||||
using lm = units::isq::si::luminous_flux<units::isq::si::lumen, Rep>;
|
||||
|
||||
} // namespace units::aliases::isq::si::inline luminous_flux
|
||||
|
||||
#endif // UNITS_NO_ALIASES
|
@@ -47,6 +47,7 @@
|
||||
#include <units/isq/si/inductance.h>
|
||||
#include <units/isq/si/length.h>
|
||||
#include <units/isq/si/luminance.h>
|
||||
#include <units/isq/si/luminous_flux.h>
|
||||
#include <units/isq/si/luminous_intensity.h>
|
||||
#include <units/isq/si/magnetic_flux.h>
|
||||
#include <units/isq/si/magnetic_induction.h>
|
||||
|
@@ -239,6 +239,12 @@ static_assert(gray::symbol == "Gy");
|
||||
static_assert(milligray::symbol == "mGy");
|
||||
static_assert(kilogray::symbol == "kGy");
|
||||
|
||||
// luminous flux
|
||||
|
||||
static_assert(683_q_lm == 1_q_W);
|
||||
|
||||
static_assert(lumen::symbol == "lm");
|
||||
|
||||
/* ************** DERIVED DIMENSIONS IN TERMS OF BASE UNITS **************** */
|
||||
|
||||
// speed
|
||||
|
Reference in New Issue
Block a user