mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-03 04:14:27 +02:00
refactor: _chrono.h_, _math.h_, and _random.h_ move to utlitity
CMake module
This commit is contained in:
@@ -23,5 +23,5 @@
|
||||
cmake_minimum_required(VERSION 3.2)
|
||||
|
||||
add_library(glide_computer STATIC include/geographic.h glide_computer.cpp include/glide_computer.h)
|
||||
target_link_libraries(glide_computer PRIVATE mp-units::core-fmt PUBLIC mp-units::si example_utils)
|
||||
target_link_libraries(glide_computer PRIVATE mp-units::core-fmt PUBLIC mp-units::si mp-units::utility example_utils)
|
||||
target_include_directories(glide_computer PUBLIC include)
|
||||
|
@@ -30,11 +30,11 @@ function(add_example target)
|
||||
target_link_libraries(${target} PRIVATE ${ARGN})
|
||||
endfunction()
|
||||
|
||||
add_example(kalman_filter-example_1 mp-units::core-fmt mp-units::si)
|
||||
add_example(kalman_filter-example_2 mp-units::core-fmt mp-units::si)
|
||||
add_example(kalman_filter-example_3 mp-units::core-fmt mp-units::si)
|
||||
add_example(kalman_filter-example_4 mp-units::core-fmt mp-units::si)
|
||||
add_example(kalman_filter-example_5 mp-units::core-fmt mp-units::si)
|
||||
add_example(kalman_filter-example_6 mp-units::core-fmt mp-units::si)
|
||||
add_example(kalman_filter-example_7 mp-units::core-fmt mp-units::si)
|
||||
add_example(kalman_filter-example_8 mp-units::core-fmt mp-units::si)
|
||||
add_example(kalman_filter-example_1 mp-units::core-fmt mp-units::si mp-units::utility)
|
||||
add_example(kalman_filter-example_2 mp-units::core-fmt mp-units::si mp-units::utility)
|
||||
add_example(kalman_filter-example_3 mp-units::core-fmt mp-units::si mp-units::utility)
|
||||
add_example(kalman_filter-example_4 mp-units::core-fmt mp-units::si mp-units::utility)
|
||||
add_example(kalman_filter-example_5 mp-units::core-fmt mp-units::si mp-units::utility)
|
||||
add_example(kalman_filter-example_6 mp-units::core-fmt mp-units::si mp-units::utility)
|
||||
add_example(kalman_filter-example_7 mp-units::core-fmt mp-units::si mp-units::utility)
|
||||
add_example(kalman_filter-example_8 mp-units::core-fmt mp-units::si mp-units::utility)
|
||||
|
@@ -41,10 +41,13 @@ add_subdirectory(core)
|
||||
add_subdirectory(core-fmt)
|
||||
add_subdirectory(core-io)
|
||||
add_subdirectory(systems)
|
||||
add_subdirectory(utility)
|
||||
|
||||
# project-wide wrapper
|
||||
add_library(mp-units INTERFACE)
|
||||
target_link_libraries(mp-units INTERFACE mp-units::core mp-units::core-io mp-units::core-fmt mp-units::systems)
|
||||
target_link_libraries(
|
||||
mp-units INTERFACE mp-units::core mp-units::core-io mp-units::core-fmt mp-units::systems mp-units::utility
|
||||
)
|
||||
add_library(mp-units::mp-units ALIAS mp-units)
|
||||
install(TARGETS mp-units EXPORT mp-unitsTargets)
|
||||
|
||||
|
@@ -37,17 +37,11 @@ check_libcxx_in_use(${projectPrefix}LIBCXX)
|
||||
add_library(
|
||||
mp-units-core
|
||||
INTERFACE
|
||||
# include/units/chrono.h
|
||||
include/units/customization_points.h
|
||||
include/units/dimension.h
|
||||
# include/units/generic/angle.h
|
||||
include/units/generic/dimensionless.h
|
||||
# include/units/generic/solid_angle.h
|
||||
include/units/math.h
|
||||
include/units/quantity.h
|
||||
# include/units/quantity_point.h
|
||||
include/units/quantity_point.h
|
||||
include/units/quantity_spec.h
|
||||
include/units/random.h
|
||||
include/units/reference.h
|
||||
include/units/system_reference.h
|
||||
include/units/unit.h
|
||||
|
27
src/utility/CMakeLists.txt
Normal file
27
src/utility/CMakeLists.txt
Normal file
@@ -0,0 +1,27 @@
|
||||
# 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.
|
||||
|
||||
cmake_minimum_required(VERSION 3.19)
|
||||
|
||||
add_units_module(utility DEPENDENCIES mp-units::core mp-units::isq mp-units::si mp-units::angular HEADERS include/units/chrono.h
|
||||
include/units/math.h
|
||||
include/units/random.h)
|
@@ -22,6 +22,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/angular/angular.h>
|
||||
#include <units/bits/external/hacks.h>
|
||||
#include <units/isq/space_and_time.h>
|
||||
#include <units/quantity.h>
|
||||
@@ -354,4 +355,62 @@ template<weak_quantity_of<dimensionless> Q>
|
||||
|
||||
} // namespace isq
|
||||
|
||||
namespace angular {
|
||||
|
||||
template<quantity_of<angle> Q>
|
||||
requires treat_as_floating_point<typename Q::rep>
|
||||
[[nodiscard]] inline quantity_of<dimensionless[one]> auto sin(const Q& q) noexcept
|
||||
requires requires { sin(q.number()); } || requires { std::sin(q.number()); }
|
||||
{
|
||||
using std::sin;
|
||||
return quantity{sin(q[radian].number())};
|
||||
}
|
||||
|
||||
template<quantity_of<angle> Q>
|
||||
requires treat_as_floating_point<typename Q::rep>
|
||||
[[nodiscard]] inline quantity_of<dimensionless[one]> auto cos(const Q& q) noexcept
|
||||
requires requires { cos(q.number()); } || requires { std::cos(q.number()); }
|
||||
{
|
||||
using std::cos;
|
||||
return quantity{cos(q[radian].number())};
|
||||
}
|
||||
|
||||
template<quantity_of<angle> Q>
|
||||
requires treat_as_floating_point<typename Q::rep>
|
||||
[[nodiscard]] inline quantity_of<dimensionless[one]> auto tan(const Q& q) noexcept
|
||||
requires requires { tan(q.number()); } || requires { std::tan(q.number()); }
|
||||
{
|
||||
using std::tan;
|
||||
return quantity{tan(q[radian].number())};
|
||||
}
|
||||
|
||||
template<weak_quantity_of<dimensionless> Q>
|
||||
requires treat_as_floating_point<typename Q::rep>
|
||||
[[nodiscard]] inline quantity_of<angle[radian]> auto asin(const Q& q) noexcept
|
||||
requires requires { asin(q.number()); } || requires { std::asin(q.number()); }
|
||||
{
|
||||
using std::asin;
|
||||
return asin(quantity_cast<one>(q).number()) * angle[radian];
|
||||
}
|
||||
|
||||
template<weak_quantity_of<dimensionless> Q>
|
||||
requires treat_as_floating_point<typename Q::rep>
|
||||
[[nodiscard]] inline quantity_of<angle[radian]> auto acos(const Q& q) noexcept
|
||||
requires requires { acos(q.number()); } || requires { std::acos(q.number()); }
|
||||
{
|
||||
using std::acos;
|
||||
return acos(quantity_cast<one>(q).number()) * angle[radian];
|
||||
}
|
||||
|
||||
template<weak_quantity_of<dimensionless> Q>
|
||||
requires treat_as_floating_point<typename Q::rep>
|
||||
[[nodiscard]] inline quantity_of<angle[radian]> auto atan(const Q& q) noexcept
|
||||
requires requires { atan(q.number()); } || requires { std::atan(q.number()); }
|
||||
{
|
||||
using std::atan;
|
||||
return atan(quantity_cast<one>(q).number()) * angle[radian];
|
||||
}
|
||||
|
||||
} // namespace angular
|
||||
|
||||
} // namespace units
|
Reference in New Issue
Block a user