mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-26 01:51:41 +00:00
[wpimath] Move math functionality into new wpimath library (#2629)
The wpimath library is a new library designed to separate the reusable math functionality from the common utility library (wpiutil) and the hardware-dependent library (wpilibc/j). Package names / include file names were NOT changed to minimize breakage. In a future year it would be good to revamp these for a more uniform user experience and to reduce the risk of accidental naming conflicts. While theoretically all of this functionality could be placed into wpiutil, several pieces of this library (e.g. DARE) are very time-consuming to compile, so it's nice to avoid this expense for users who only want cscore or ntcore. It also allows for easy future separation of build tasks vs number of workers on memory-constrained machines. This moves the following functionality from wpiutil into wpimath: - Eigen - ejml - Drake - DARE - wpiutil.math package (Matrix etc) - units And the following functionality from wpilibc/j into wpimath: - Geometry - Kinematics - Spline - Trajectory - LinearFilter - MedianFilter - Feed-forward controllers
This commit is contained in:
@@ -1,152 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
/// @file
|
||||
/// Provides Drake's assertion implementation. This is intended to be used
|
||||
/// both within Drake and by other software. Drake's asserts can be armed
|
||||
/// and disarmed independently from the system-wide asserts.
|
||||
|
||||
#ifdef DRAKE_DOXYGEN_CXX
|
||||
/// @p DRAKE_ASSERT(condition) is similar to the built-in @p assert(condition)
|
||||
/// from the C++ system header @p <cassert>. Unless Drake's assertions are
|
||||
/// disarmed by the pre-processor definitions listed below, @p DRAKE_ASSERT
|
||||
/// will evaluate @p condition and iff the value is false will trigger an
|
||||
/// assertion failure with a message showing at least the condition text,
|
||||
/// function name, file, and line.
|
||||
///
|
||||
/// By default, assertion failures will :abort() the program. However, when
|
||||
/// using the pydrake python bindings, assertion failures will instead throw a
|
||||
/// C++ exception that causes a python SystemExit exception.
|
||||
///
|
||||
/// Assertions are enabled or disabled using the following pre-processor macros:
|
||||
///
|
||||
/// - If @p DRAKE_ENABLE_ASSERTS is defined, then @p DRAKE_ASSERT is armed.
|
||||
/// - If @p DRAKE_DISABLE_ASSERTS is defined, then @p DRAKE_ASSERT is disarmed.
|
||||
/// - If both macros are defined, then it is a compile-time error.
|
||||
/// - If neither are defined, then NDEBUG governs assertions as usual.
|
||||
///
|
||||
/// This header will define exactly one of either @p DRAKE_ASSERT_IS_ARMED or
|
||||
/// @p DRAKE_ASSERT_IS_DISARMED to indicate whether @p DRAKE_ASSERT is armed.
|
||||
///
|
||||
/// This header will define both `constexpr bool drake::kDrakeAssertIsArmed`
|
||||
/// and `constexpr bool drake::kDrakeAssertIsDisarmed` globals.
|
||||
///
|
||||
/// One difference versus the standard @p assert(condition) is that the
|
||||
/// @p condition within @p DRAKE_ASSERT is always syntax-checked, even if
|
||||
/// Drake's assertions are disarmed.
|
||||
///
|
||||
/// Treat @p DRAKE_ASSERT like a statement -- it must always be used
|
||||
/// in block scope, and must always be followed by a semicolon.
|
||||
#define DRAKE_ASSERT(condition)
|
||||
/// Like @p DRAKE_ASSERT, except that the expression must be void-valued; this
|
||||
/// allows for guarding expensive assertion-checking subroutines using the same
|
||||
/// macros as stand-alone assertions.
|
||||
#define DRAKE_ASSERT_VOID(expression)
|
||||
/// Evaluates @p condition and iff the value is false will trigger an assertion
|
||||
/// failure with a message showing at least the condition text, function name,
|
||||
/// file, and line.
|
||||
#define DRAKE_DEMAND(condition)
|
||||
/// Silences a "no return value" compiler warning by calling a function that
|
||||
/// always raises an exception or aborts (i.e., a function marked noreturn).
|
||||
/// Only use this macro at a point where (1) a point in the code is truly
|
||||
/// unreachable, (2) the fact that it's unreachable is knowable from only
|
||||
/// reading the function itself (and not, e.g., some larger design invariant),
|
||||
/// and (3) there is a compiler warning if this macro were removed. The most
|
||||
/// common valid use is with a switch-case-return block where all cases are
|
||||
/// accounted for but the enclosing function is supposed to return a value. Do
|
||||
/// *not* use this macro as a "logic error" assertion; it should *only* be used
|
||||
/// to silence false positive warnings. When in doubt, throw an exception
|
||||
/// manually instead of using this macro.
|
||||
#define DRAKE_UNREACHABLE()
|
||||
#else // DRAKE_DOXYGEN_CXX
|
||||
|
||||
// Users should NOT set these; only this header should set them.
|
||||
#ifdef DRAKE_ASSERT_IS_ARMED
|
||||
# error Unexpected DRAKE_ASSERT_IS_ARMED defined.
|
||||
#endif
|
||||
#ifdef DRAKE_ASSERT_IS_DISARMED
|
||||
# error Unexpected DRAKE_ASSERT_IS_DISARMED defined.
|
||||
#endif
|
||||
|
||||
// Decide whether Drake assertions are enabled.
|
||||
#if defined(DRAKE_ENABLE_ASSERTS) && defined(DRAKE_DISABLE_ASSERTS)
|
||||
# error Conflicting assertion toggles.
|
||||
#elif defined(DRAKE_ENABLE_ASSERTS)
|
||||
# define DRAKE_ASSERT_IS_ARMED
|
||||
#elif defined(DRAKE_DISABLE_ASSERTS) || defined(NDEBUG)
|
||||
# define DRAKE_ASSERT_IS_DISARMED
|
||||
#else
|
||||
# define DRAKE_ASSERT_IS_ARMED
|
||||
#endif
|
||||
|
||||
namespace drake {
|
||||
namespace internal {
|
||||
// Abort the program with an error message.
|
||||
[[noreturn]]
|
||||
void Abort(const char* condition, const char* func, const char* file, int line);
|
||||
// Report an assertion failure; will either Abort(...) or throw.
|
||||
[[noreturn]]
|
||||
void AssertionFailed(
|
||||
const char* condition, const char* func, const char* file, int line);
|
||||
} // namespace internal
|
||||
namespace assert {
|
||||
// Allows for specialization of how to bool-convert Conditions used in
|
||||
// assertions, in case they are not intrinsically convertible. See
|
||||
// symbolic_formula.h for an example use. This is a public interface to
|
||||
// extend; it is intended to be specialized by unusual Scalar types that
|
||||
// require special handling.
|
||||
template <typename Condition>
|
||||
struct ConditionTraits {
|
||||
static constexpr bool is_valid = std::is_convertible<Condition, bool>::value;
|
||||
static bool Evaluate(const Condition& value) {
|
||||
return value;
|
||||
}
|
||||
};
|
||||
} // namespace assert
|
||||
} // namespace drake
|
||||
|
||||
#define DRAKE_UNREACHABLE() \
|
||||
::drake::internal::Abort( \
|
||||
"Unreachable code was reached?!", __func__, __FILE__, __LINE__)
|
||||
|
||||
#define DRAKE_DEMAND(condition) \
|
||||
do { \
|
||||
typedef ::drake::assert::ConditionTraits< \
|
||||
typename std::remove_cv<decltype(condition)>::type> Trait; \
|
||||
static_assert(Trait::is_valid, "Condition should be bool-convertible."); \
|
||||
if (!Trait::Evaluate(condition)) { \
|
||||
::drake::internal::AssertionFailed( \
|
||||
#condition, __func__, __FILE__, __LINE__); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#ifdef DRAKE_ASSERT_IS_ARMED
|
||||
// Assertions are enabled.
|
||||
namespace drake {
|
||||
constexpr bool kDrakeAssertIsArmed = true;
|
||||
constexpr bool kDrakeAssertIsDisarmed = false;
|
||||
} // namespace drake
|
||||
# define DRAKE_ASSERT(condition) DRAKE_DEMAND(condition)
|
||||
# define DRAKE_ASSERT_VOID(expression) do { \
|
||||
static_assert( \
|
||||
std::is_convertible<decltype(expression), void>::value, \
|
||||
"Expression should be void."); \
|
||||
expression; \
|
||||
} while (0)
|
||||
#else
|
||||
// Assertions are disabled, so just typecheck the expression.
|
||||
namespace drake {
|
||||
constexpr bool kDrakeAssertIsArmed = false;
|
||||
constexpr bool kDrakeAssertIsDisarmed = true;
|
||||
} // namespace drake
|
||||
# define DRAKE_ASSERT(condition) static_assert( \
|
||||
::drake::assert::ConditionTraits< \
|
||||
typename std::remove_cv<decltype(condition)>::type>::is_valid, \
|
||||
"Condition should be bool-convertible.");
|
||||
# define DRAKE_ASSERT_VOID(expression) static_assert( \
|
||||
std::is_convertible<decltype(expression), void>::value, \
|
||||
"Expression should be void.")
|
||||
#endif
|
||||
|
||||
#endif // DRAKE_DOXYGEN_CXX
|
||||
@@ -1,18 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
namespace drake {
|
||||
namespace internal {
|
||||
|
||||
/// This is what DRAKE_ASSERT and DRAKE_DEMAND throw when our assertions are
|
||||
/// configured to throw.
|
||||
class assertion_error : public std::runtime_error {
|
||||
public:
|
||||
explicit assertion_error(const std::string& what_arg)
|
||||
: std::runtime_error(what_arg) {}
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
} // namespace drake
|
||||
@@ -1,112 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
// ============================================================================
|
||||
// N.B. The spelling of the macro names between doc/Doxyfile_CXX.in and this
|
||||
// file must be kept in sync!
|
||||
// ============================================================================
|
||||
|
||||
/** @file
|
||||
Provides careful macros to selectively enable or disable the special member
|
||||
functions for copy-construction, copy-assignment, move-construction, and
|
||||
move-assignment.
|
||||
|
||||
http://en.cppreference.com/w/cpp/language/member_functions#Special_member_functions
|
||||
|
||||
When enabled via these macros, the `= default` implementation is provided.
|
||||
Code that needs custom copy or move functions should not use these macros.
|
||||
*/
|
||||
|
||||
/** DRAKE_NO_COPY_NO_MOVE_NO_ASSIGN deletes the special member functions for
|
||||
copy-construction, copy-assignment, move-construction, and move-assignment.
|
||||
Drake's Doxygen is customized to render the deletions in detail, with
|
||||
appropriate comments. Invoke this this macro in the public section of the
|
||||
class declaration, e.g.:
|
||||
<pre>
|
||||
class Foo {
|
||||
public:
|
||||
DRAKE_NO_COPY_NO_MOVE_NO_ASSIGN(Foo)
|
||||
|
||||
// ...
|
||||
};
|
||||
</pre>
|
||||
*/
|
||||
#define DRAKE_NO_COPY_NO_MOVE_NO_ASSIGN(Classname) \
|
||||
Classname(const Classname&) = delete; \
|
||||
void operator=(const Classname&) = delete; \
|
||||
Classname(Classname&&) = delete; \
|
||||
void operator=(Classname&&) = delete;
|
||||
|
||||
/** DRAKE_DEFAULT_COPY_AND_MOVE_AND_ASSIGN defaults the special member
|
||||
functions for copy-construction, copy-assignment, move-construction, and
|
||||
move-assignment. This macro should be used only when copy-construction and
|
||||
copy-assignment defaults are well-formed. Note that the defaulted move
|
||||
functions could conceivably still be ill-formed, in which case they will
|
||||
effectively not be declared or used -- but because the copy constructor exists
|
||||
the type will still be MoveConstructible. Drake's Doxygen is customized to
|
||||
render the functions in detail, with appropriate comments. Invoke this this
|
||||
macro in the public section of the class declaration, e.g.:
|
||||
<pre>
|
||||
class Foo {
|
||||
public:
|
||||
DRAKE_DEFAULT_COPY_AND_MOVE_AND_ASSIGN(Foo)
|
||||
|
||||
// ...
|
||||
};
|
||||
</pre>
|
||||
*/
|
||||
#define DRAKE_DEFAULT_COPY_AND_MOVE_AND_ASSIGN(Classname) \
|
||||
Classname(const Classname&) = default; \
|
||||
Classname& operator=(const Classname&) = default; \
|
||||
Classname(Classname&&) = default; \
|
||||
Classname& operator=(Classname&&) = default; \
|
||||
/* Fails at compile-time if default-copy doesn't work. */ \
|
||||
static void DRAKE_COPYABLE_DEMAND_COPY_CAN_COMPILE() { \
|
||||
(void) static_cast<Classname& (Classname::*)( \
|
||||
const Classname&)>(&Classname::operator=); \
|
||||
}
|
||||
|
||||
/** DRAKE_DECLARE_COPY_AND_MOVE_AND_ASSIGN declares (but does not define) the
|
||||
special member functions for copy-construction, copy-assignment,
|
||||
move-construction, and move-assignment. Drake's Doxygen is customized to
|
||||
render the declarations with appropriate comments.
|
||||
|
||||
This is useful when paired with DRAKE_DEFINE_DEFAULT_COPY_AND_MOVE_AND_ASSIGN_T
|
||||
to work around https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57728 whereby the
|
||||
declaration and definition must be split. Once Drake no longer supports GCC
|
||||
versions prior to 6.3, this macro could be removed.
|
||||
|
||||
Invoke this this macro in the public section of the class declaration, e.g.:
|
||||
<pre>
|
||||
template <typename T>
|
||||
class Foo {
|
||||
public:
|
||||
DRAKE_DECLARE_COPY_AND_MOVE_AND_ASSIGN(Foo)
|
||||
|
||||
// ...
|
||||
};
|
||||
DRAKE_DEFINE_DEFAULT_COPY_AND_MOVE_AND_ASSIGN_T(Foo)
|
||||
</pre>
|
||||
*/
|
||||
#define DRAKE_DECLARE_COPY_AND_MOVE_AND_ASSIGN(Classname) \
|
||||
Classname(const Classname&); \
|
||||
Classname& operator=(const Classname&); \
|
||||
Classname(Classname&&); \
|
||||
Classname& operator=(Classname&&); \
|
||||
/* Fails at compile-time if default-copy doesn't work. */ \
|
||||
static void DRAKE_COPYABLE_DEMAND_COPY_CAN_COMPILE() { \
|
||||
(void) static_cast<Classname& (Classname::*)( \
|
||||
const Classname&)>(&Classname::operator=); \
|
||||
}
|
||||
|
||||
/** Helper for DRAKE_DECLARE_COPY_AND_MOVE_AND_ASSIGN. Provides defaulted
|
||||
definitions for the four special member functions of a templated class.
|
||||
*/
|
||||
#define DRAKE_DEFINE_DEFAULT_COPY_AND_MOVE_AND_ASSIGN_T(Classname) \
|
||||
template <typename T> \
|
||||
Classname<T>::Classname(const Classname<T>&) = default; \
|
||||
template <typename T> \
|
||||
Classname<T>& Classname<T>::operator=(const Classname<T>&) = default; \
|
||||
template <typename T> \
|
||||
Classname<T>::Classname(Classname<T>&&) = default; \
|
||||
template <typename T> \
|
||||
Classname<T>& Classname<T>::operator=(Classname<T>&&) = default;
|
||||
@@ -1,31 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include "drake/common/drake_assert.h"
|
||||
|
||||
/// @file
|
||||
/// Provides a convenient wrapper to throw an exception when a condition is
|
||||
/// unmet. This is similar to an assertion, but uses exceptions instead of
|
||||
/// ::abort(), and cannot be disabled.
|
||||
|
||||
namespace drake {
|
||||
namespace internal {
|
||||
// Throw an error message.
|
||||
[[noreturn]]
|
||||
void Throw(const char* condition, const char* func, const char* file, int line);
|
||||
} // namespace internal
|
||||
} // namespace drake
|
||||
|
||||
/// Evaluates @p condition and iff the value is false will throw an exception
|
||||
/// with a message showing at least the condition text, function name, file,
|
||||
/// and line.
|
||||
#define DRAKE_THROW_UNLESS(condition) \
|
||||
do { \
|
||||
typedef ::drake::assert::ConditionTraits< \
|
||||
typename std::remove_cv<decltype(condition)>::type> Trait; \
|
||||
static_assert(Trait::is_valid, "Condition should be bool-convertible."); \
|
||||
if (!Trait::Evaluate(condition)) { \
|
||||
::drake::internal::Throw(#condition, __func__, __FILE__, __LINE__); \
|
||||
} \
|
||||
} while (0)
|
||||
@@ -1,62 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <Eigen/Core>
|
||||
|
||||
namespace drake {
|
||||
|
||||
/// Returns true if and only if the two matrices are equal to within a certain
|
||||
/// absolute elementwise @p tolerance. Special values (infinities, NaN, etc.)
|
||||
/// do not compare as equal elements.
|
||||
template <typename DerivedA, typename DerivedB>
|
||||
bool is_approx_equal_abstol(const Eigen::MatrixBase<DerivedA>& m1,
|
||||
const Eigen::MatrixBase<DerivedB>& m2,
|
||||
double tolerance) {
|
||||
return (
|
||||
(m1.rows() == m2.rows()) &&
|
||||
(m1.cols() == m2.cols()) &&
|
||||
((m1 - m2).template lpNorm<Eigen::Infinity>() <= tolerance));
|
||||
}
|
||||
|
||||
/// Returns true if and only if a simple greedy search reveals a permutation
|
||||
/// of the columns of m2 to make the matrix equal to m1 to within a certain
|
||||
/// absolute elementwise @p tolerance. E.g., there exists a P such that
|
||||
/// <pre>
|
||||
/// forall i,j, |m1 - m2*P|_{i,j} <= tolerance
|
||||
/// where P is a permutation matrix:
|
||||
/// P(i,j)={0,1}, sum_i P(i,j)=1, sum_j P(i,j)=1.
|
||||
/// </pre>
|
||||
/// Note: Returns false for matrices of different sizes.
|
||||
/// Note: The current implementation is O(n^2) in the number of columns.
|
||||
/// Note: In marginal cases (with similar but not identical columns) this
|
||||
/// algorithm can fail to find a permutation P even if it exists because it
|
||||
/// accepts the first column match (m1(i),m2(j)) and removes m2(j) from the
|
||||
/// pool. It is possible that other columns of m2 would also match m1(i) but
|
||||
/// that m2(j) is the only match possible for a later column of m1.
|
||||
template <typename DerivedA, typename DerivedB>
|
||||
bool IsApproxEqualAbsTolWithPermutedColumns(
|
||||
const Eigen::MatrixBase<DerivedA>& m1,
|
||||
const Eigen::MatrixBase<DerivedB>& m2, double tolerance) {
|
||||
if ((m1.cols() != m2.cols()) || (m1.rows() != m2.rows())) return false;
|
||||
|
||||
std::vector<bool> available(m2.cols());
|
||||
for (int i = 0; i < m2.cols(); i++) available[i] = true;
|
||||
|
||||
for (int i = 0; i < m1.cols(); i++) {
|
||||
bool found_match = false;
|
||||
for (int j = 0; j < m2.cols(); j++) {
|
||||
if (available[j] &&
|
||||
is_approx_equal_abstol(m1.col(i), m2.col(j), tolerance)) {
|
||||
found_match = true;
|
||||
available[j] = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found_match) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
} // namespace drake
|
||||
@@ -1,84 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <new>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
#include "drake/common/drake_copyable.h"
|
||||
|
||||
namespace drake {
|
||||
|
||||
/// Wraps an underlying type T such that its storage is a direct member field
|
||||
/// of this object (i.e., without any indirection into the heap), but *unlike*
|
||||
/// most member fields T's destructor is never invoked.
|
||||
///
|
||||
/// This is especially useful for function-local static variables that are not
|
||||
/// trivially destructable. We shouldn't call their destructor at program exit
|
||||
/// because of the "indeterminate order of ... destruction" as mentioned in
|
||||
/// cppguide's
|
||||
/// <a href="https://drake.mit.edu/styleguide/cppguide.html#Static_and_Global_Variables">Static
|
||||
/// and Global Variables</a> section, but other solutions to this problem place
|
||||
/// the objects on the heap through an indirection.
|
||||
///
|
||||
/// Compared with other approaches, this mechanism more clearly describes the
|
||||
/// intent to readers, avoids "possible leak" warnings from memory-checking
|
||||
/// tools, and is probably slightly faster.
|
||||
///
|
||||
/// Example uses:
|
||||
///
|
||||
/// The singleton pattern:
|
||||
/// @code
|
||||
/// class Singleton {
|
||||
/// public:
|
||||
/// DRAKE_NO_COPY_NO_MOVE_NO_ASSIGN(Singleton)
|
||||
/// static Singleton& getInstance() {
|
||||
/// static never_destroyed<Singleton> instance;
|
||||
/// return instance.access();
|
||||
/// }
|
||||
/// private:
|
||||
/// friend never_destroyed<Singleton>;
|
||||
/// Singleton() = default;
|
||||
/// };
|
||||
/// @endcode
|
||||
///
|
||||
/// A lookup table, created on demand the first time its needed, and then
|
||||
/// reused thereafter:
|
||||
/// @code
|
||||
/// enum class Foo { kBar, kBaz };
|
||||
/// Foo ParseFoo(const std::string& foo_string) {
|
||||
/// using Dict = std::unordered_map<std::string, Foo>;
|
||||
/// static const drake::never_destroyed<Dict> string_to_enum{
|
||||
/// std::initializer_list<Dict::value_type>{
|
||||
/// {"bar", Foo::kBar},
|
||||
/// {"baz", Foo::kBaz},
|
||||
/// }
|
||||
/// };
|
||||
/// return string_to_enum.access().at(foo_string);
|
||||
/// }
|
||||
/// @endcode
|
||||
//
|
||||
// The above examples are repeated in the unit test; keep them in sync.
|
||||
template <typename T>
|
||||
class never_destroyed {
|
||||
public:
|
||||
DRAKE_NO_COPY_NO_MOVE_NO_ASSIGN(never_destroyed)
|
||||
|
||||
/// Passes the constructor arguments along to T using perfect forwarding.
|
||||
template <typename... Args>
|
||||
explicit never_destroyed(Args&&... args) {
|
||||
// Uses "placement new" to construct a `T` in `storage_`.
|
||||
new (&storage_) T(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
/// Does nothing. Guaranteed!
|
||||
~never_destroyed() = default;
|
||||
|
||||
/// Returns the underlying T reference.
|
||||
T& access() { return *reinterpret_cast<T*>(&storage_); }
|
||||
const T& access() const { return *reinterpret_cast<const T*>(&storage_); }
|
||||
|
||||
private:
|
||||
typename std::aligned_storage<sizeof(T), alignof(T)>::type storage_;
|
||||
};
|
||||
|
||||
} // namespace drake
|
||||
@@ -1,32 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
|
||||
#include <Eigen/Core>
|
||||
|
||||
namespace drake {
|
||||
namespace math {
|
||||
|
||||
/// Computes the unique stabilizing solution X to the discrete-time algebraic
|
||||
/// Riccati equation:
|
||||
///
|
||||
/// \f[
|
||||
/// A'XA - X - A'XB(B'XB+R)^{-1}B'XA + Q = 0
|
||||
/// \f]
|
||||
///
|
||||
/// @throws std::runtime_error if Q is not positive semi-definite.
|
||||
/// @throws std::runtime_error if R is not positive definite.
|
||||
///
|
||||
/// Based on the Schur Vector approach outlined in this paper:
|
||||
/// "On the Numerical Solution of the Discrete-Time Algebraic Riccati Equation"
|
||||
/// by Thrasyvoulos Pappas, Alan J. Laub, and Nils R. Sandell
|
||||
///
|
||||
Eigen::MatrixXd DiscreteAlgebraicRiccatiEquation(
|
||||
const Eigen::Ref<const Eigen::MatrixXd>& A,
|
||||
const Eigen::Ref<const Eigen::MatrixXd>& B,
|
||||
const Eigen::Ref<const Eigen::MatrixXd>& Q,
|
||||
const Eigen::Ref<const Eigen::MatrixXd>& R);
|
||||
} // namespace math
|
||||
} // namespace drake
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// 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/base.h"
|
||||
#include "units/length.h"
|
||||
#include "units/time.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::acceleration
|
||||
* @brief namespace for unit types and containers representing acceleration
|
||||
* values
|
||||
* @details The SI unit for acceleration is `meters_per_second_squared`, and the
|
||||
* corresponding `base_unit` category is `acceleration_unit`.
|
||||
* @anchor accelerationContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || \
|
||||
defined(ENABLE_PREDEFINED_ACCELERATION_UNITS)
|
||||
UNIT_ADD(acceleration, meters_per_second_squared, meters_per_second_squared,
|
||||
mps_sq, unit<std::ratio<1>, units::category::acceleration_unit>)
|
||||
UNIT_ADD(acceleration, feet_per_second_squared, feet_per_second_squared, fps_sq,
|
||||
compound_unit<length::feet, inverse<squared<time::seconds>>>)
|
||||
UNIT_ADD(acceleration, standard_gravity, standard_gravity, SG,
|
||||
unit<std::ratio<980665, 100000>, meters_per_second_squared>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(acceleration)
|
||||
#endif
|
||||
|
||||
using namespace acceleration;
|
||||
} // namespace units
|
||||
@@ -1,59 +0,0 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// 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/base.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::angle
|
||||
* @brief namespace for unit types and containers representing angle values
|
||||
* @details The SI unit for angle is `radians`, and the corresponding
|
||||
* `base_unit` category is`angle_unit`.
|
||||
* @anchor angleContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_ANGLE_UNITS)
|
||||
UNIT_ADD_WITH_METRIC_PREFIXES(angle, radian, radians, rad,
|
||||
unit<std::ratio<1>, units::category::angle_unit>)
|
||||
UNIT_ADD(angle, degree, degrees, deg,
|
||||
unit<std::ratio<1, 180>, radians, std::ratio<1>>)
|
||||
UNIT_ADD(angle, arcminute, arcminutes, arcmin, unit<std::ratio<1, 60>, degrees>)
|
||||
UNIT_ADD(angle, arcsecond, arcseconds, arcsec,
|
||||
unit<std::ratio<1, 60>, arcminutes>)
|
||||
UNIT_ADD(angle, milliarcsecond, milliarcseconds, mas, milli<arcseconds>)
|
||||
UNIT_ADD(angle, turn, turns, tr, unit<std::ratio<2>, radians, std::ratio<1>>)
|
||||
UNIT_ADD(angle, gradian, gradians, gon, unit<std::ratio<1, 400>, turns>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(angle)
|
||||
#endif
|
||||
|
||||
using namespace angle;
|
||||
} // namespace units
|
||||
@@ -1,35 +0,0 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "units/angular_velocity.h"
|
||||
#include "units/base.h"
|
||||
#include "units/time.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::angular_acceleration
|
||||
* @brief namespace for unit types and containers representing angular
|
||||
* acceleration values
|
||||
* @details The SI unit for angular acceleration is
|
||||
* `radians_per_second_squared`, and the corresponding `base_unit`
|
||||
* category is`angular_acceleration_unit`.
|
||||
* @anchor angularAccelerationContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
UNIT_ADD(angular_acceleration, radians_per_second_squared,
|
||||
radians_per_second_squared, rad_per_s_sq,
|
||||
unit<std::ratio<1>, units::category::angular_acceleration_unit>)
|
||||
UNIT_ADD(angular_acceleration, degrees_per_second_squared,
|
||||
degrees_per_second_squared, deg_per_s_sq,
|
||||
compound_unit<angle::degrees, inverse<squared<time::seconds>>>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(angular_acceleration)
|
||||
|
||||
using namespace angular_acceleration;
|
||||
} // namespace units
|
||||
@@ -1,61 +0,0 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// 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/angle.h"
|
||||
#include "units/base.h"
|
||||
#include "units/time.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::angular_velocity
|
||||
* @brief namespace for unit types and containers representing angular velocity
|
||||
* values
|
||||
* @details The SI unit for angular velocity is `radians_per_second`, and the
|
||||
* corresponding `base_unit` category is`angular_velocity_unit`.
|
||||
* @anchor angularVelocityContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || \
|
||||
defined(ENABLE_PREDEFINED_ANGULAR_VELOCITY_UNITS)
|
||||
UNIT_ADD(angular_velocity, radians_per_second, radians_per_second, rad_per_s,
|
||||
unit<std::ratio<1>, units::category::angular_velocity_unit>)
|
||||
UNIT_ADD(angular_velocity, degrees_per_second, degrees_per_second, deg_per_s,
|
||||
compound_unit<angle::degrees, inverse<time::seconds>>)
|
||||
UNIT_ADD(angular_velocity, revolutions_per_minute, revolutions_per_minute, rpm,
|
||||
unit<std::ratio<2, 60>, radians_per_second, std::ratio<1>>)
|
||||
UNIT_ADD(angular_velocity, milliarcseconds_per_year, milliarcseconds_per_year,
|
||||
mas_per_yr, compound_unit<angle::milliarcseconds, inverse<time::year>>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(angular_velocity)
|
||||
#endif
|
||||
|
||||
using namespace angular_velocity;
|
||||
} // namespace units
|
||||
@@ -1,59 +0,0 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// 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/base.h"
|
||||
#include "units/length.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::area
|
||||
* @brief namespace for unit types and containers representing area values
|
||||
* @details The SI unit for area is `square_meters`, and the corresponding
|
||||
* `base_unit` category is `area_unit`.
|
||||
* @anchor areaContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_AREA_UNITS)
|
||||
UNIT_ADD(area, square_meter, square_meters, sq_m,
|
||||
unit<std::ratio<1>, units::category::area_unit>)
|
||||
UNIT_ADD(area, square_foot, square_feet, sq_ft, squared<length::feet>)
|
||||
UNIT_ADD(area, square_inch, square_inches, sq_in, squared<length::inch>)
|
||||
UNIT_ADD(area, square_mile, square_miles, sq_mi, squared<length::miles>)
|
||||
UNIT_ADD(area, square_kilometer, square_kilometers, sq_km,
|
||||
squared<length::kilometers>)
|
||||
UNIT_ADD(area, hectare, hectares, ha, unit<std::ratio<10000>, square_meters>)
|
||||
UNIT_ADD(area, acre, acres, acre, unit<std::ratio<43560>, square_feet>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(area)
|
||||
#endif
|
||||
|
||||
using namespace area;
|
||||
} // namespace units
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,54 +0,0 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// 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/base.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::capacitance
|
||||
* @brief namespace for unit types and containers representing capacitance
|
||||
* values
|
||||
* @details The SI unit for capacitance is `farads`, and the corresponding
|
||||
* `base_unit` category is `capacitance_unit`.
|
||||
* @anchor capacitanceContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || \
|
||||
defined(ENABLE_PREDEFINED_CAPACITANCE_UNITS)
|
||||
UNIT_ADD_WITH_METRIC_PREFIXES(
|
||||
capacitance, farad, farads, F,
|
||||
unit<std::ratio<1>, units::category::capacitance_unit>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(capacitance)
|
||||
#endif
|
||||
|
||||
using namespace capacitance;
|
||||
} // namespace units
|
||||
@@ -1,56 +0,0 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// 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/base.h"
|
||||
#include "units/current.h"
|
||||
#include "units/time.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::charge
|
||||
* @brief namespace for unit types and containers representing charge values
|
||||
* @details The SI unit for charge is `coulombs`, and the corresponding
|
||||
* `base_unit` category is `charge_unit`.
|
||||
* @anchor chargeContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || \
|
||||
defined(ENABLE_PREDEFINED_CHARGE_UNITS)
|
||||
UNIT_ADD_WITH_METRIC_PREFIXES(charge, coulomb, coulombs, C,
|
||||
unit<std::ratio<1>, units::category::charge_unit>)
|
||||
UNIT_ADD_WITH_METRIC_PREFIXES(charge, ampere_hour, ampere_hours, Ah,
|
||||
compound_unit<current::ampere, time::hours>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(charge)
|
||||
#endif
|
||||
|
||||
using namespace charge;
|
||||
} // namespace units
|
||||
@@ -1,59 +0,0 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// 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/base.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::concentration
|
||||
* @brief namespace for unit types and containers representing concentration
|
||||
* values
|
||||
* @details The SI unit for concentration is `parts_per_million`, and the
|
||||
* corresponding `base_unit` category is `scalar_unit`.
|
||||
* @anchor concentrationContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || \
|
||||
defined(ENABLE_PREDEFINED_CONCENTRATION_UNITS)
|
||||
UNIT_ADD(concentration, ppm, parts_per_million, ppm,
|
||||
unit<std::ratio<1, 1000000>, units::category::scalar_unit>)
|
||||
UNIT_ADD(concentration, ppb, parts_per_billion, ppb,
|
||||
unit<std::ratio<1, 1000>, parts_per_million>)
|
||||
UNIT_ADD(concentration, ppt, parts_per_trillion, ppt,
|
||||
unit<std::ratio<1, 1000>, parts_per_billion>)
|
||||
UNIT_ADD(concentration, percent, percent, pct,
|
||||
unit<std::ratio<1, 100>, units::category::scalar_unit>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(concentration)
|
||||
#endif
|
||||
|
||||
using namespace concentration;
|
||||
} // namespace units
|
||||
@@ -1,54 +0,0 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// 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/base.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::conductance
|
||||
* @brief namespace for unit types and containers representing conductance
|
||||
* values
|
||||
* @details The SI unit for conductance is `siemens`, and the corresponding
|
||||
* `base_unit` category is `conductance_unit`.
|
||||
* @anchor conductanceContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || \
|
||||
defined(ENABLE_PREDEFINED_CONDUCTANCE_UNITS)
|
||||
UNIT_ADD_WITH_METRIC_PREFIXES(
|
||||
conductance, siemens, siemens, S,
|
||||
unit<std::ratio<1>, units::category::conductance_unit>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(conductance)
|
||||
#endif
|
||||
|
||||
using namespace conductance;
|
||||
} // namespace units
|
||||
@@ -1,113 +0,0 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// 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/area.h"
|
||||
#include "units/capacitance.h"
|
||||
#include "units/charge.h"
|
||||
#include "units/current.h"
|
||||
#include "units/dimensionless.h"
|
||||
#include "units/energy.h"
|
||||
#include "units/force.h"
|
||||
#include "units/impedance.h"
|
||||
#include "units/length.h"
|
||||
#include "units/magnetic_field_strength.h"
|
||||
#include "units/mass.h"
|
||||
#include "units/power.h"
|
||||
#include "units/substance.h"
|
||||
#include "units/temperature.h"
|
||||
#include "units/time.h"
|
||||
#include "units/velocity.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @brief namespace for physical constants like PI and Avogadro's Number.
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS)
|
||||
namespace constants {
|
||||
/**
|
||||
* @name Unit Containers
|
||||
* @anchor constantContainers
|
||||
* @{
|
||||
*/
|
||||
using PI = unit<std::ratio<1>, dimensionless::scalar, std::ratio<1>>;
|
||||
|
||||
static constexpr const unit_t<PI> pi(
|
||||
1); ///< Ratio of a circle's circumference to its diameter.
|
||||
static constexpr const velocity::meters_per_second_t c(
|
||||
299792458.0); ///< Speed of light in vacuum.
|
||||
static constexpr const unit_t<
|
||||
compound_unit<cubed<length::meters>, inverse<mass::kilogram>,
|
||||
inverse<squared<time::seconds>>>>
|
||||
G(6.67408e-11); ///< Newtonian constant of gravitation.
|
||||
static constexpr const unit_t<compound_unit<energy::joule, time::seconds>> h(
|
||||
6.626070040e-34); ///< Planck constant.
|
||||
static constexpr const unit_t<
|
||||
compound_unit<force::newtons, inverse<squared<current::ampere>>>>
|
||||
mu0(pi * 4.0e-7 * force::newton_t(1) /
|
||||
units::math::cpow<2>(current::ampere_t(1))); ///< vacuum permeability.
|
||||
static constexpr const unit_t<
|
||||
compound_unit<capacitance::farad, inverse<length::meter>>>
|
||||
epsilon0(1.0 / (mu0 * math::cpow<2>(c))); ///< vacuum permitivity.
|
||||
static constexpr const impedance::ohm_t Z0(
|
||||
mu0* c); ///< characteristic impedance of vacuum.
|
||||
static constexpr const unit_t<compound_unit<force::newtons, area::square_meter,
|
||||
inverse<squared<charge::coulomb>>>>
|
||||
k_e(1.0 / (4 * pi * epsilon0)); ///< Coulomb's constant.
|
||||
static constexpr const charge::coulomb_t e(
|
||||
1.6021766208e-19); ///< elementary charge.
|
||||
static constexpr const mass::kilogram_t m_e(
|
||||
9.10938356e-31); ///< electron mass.
|
||||
static constexpr const mass::kilogram_t m_p(1.672621898e-27); ///< proton mass.
|
||||
static constexpr const unit_t<
|
||||
compound_unit<energy::joules, inverse<magnetic_field_strength::tesla>>>
|
||||
mu_B(e* h / (4 * pi * m_e)); ///< Bohr magneton.
|
||||
static constexpr const unit_t<inverse<substance::mol>> N_A(
|
||||
6.022140857e23); ///< Avagadro's Number.
|
||||
static constexpr const unit_t<compound_unit<
|
||||
energy::joules, inverse<temperature::kelvin>, inverse<substance::moles>>>
|
||||
R(8.3144598); ///< Gas constant.
|
||||
static constexpr const unit_t<
|
||||
compound_unit<energy::joules, inverse<temperature::kelvin>>>
|
||||
k_B(R / N_A); ///< Boltzmann constant.
|
||||
static constexpr const unit_t<
|
||||
compound_unit<charge::coulomb, inverse<substance::mol>>>
|
||||
F(N_A* e); ///< Faraday constant.
|
||||
static constexpr const unit_t<
|
||||
compound_unit<power::watts, inverse<area::square_meters>,
|
||||
inverse<squared<squared<temperature::kelvin>>>>>
|
||||
sigma((2 * math::cpow<5>(pi) * math::cpow<4>(R)) /
|
||||
(15 * math::cpow<3>(h) * math::cpow<2>(c) *
|
||||
math::cpow<4>(N_A))); ///< Stefan-Boltzmann constant.
|
||||
/** @} */
|
||||
} // namespace constants
|
||||
#endif
|
||||
} // namespace units
|
||||
@@ -1,53 +0,0 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// 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/base.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::current
|
||||
* @brief namespace for unit types and containers representing current values
|
||||
* @details The SI unit for current is `amperes`, and the corresponding
|
||||
* `base_unit` category is `current_unit`.
|
||||
* @anchor currentContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || \
|
||||
defined(ENABLE_PREDEFINED_CURRENT_UNITS)
|
||||
UNIT_ADD_WITH_METRIC_PREFIXES(
|
||||
current, ampere, amperes, A,
|
||||
unit<std::ratio<1>, units::category::current_unit>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(current)
|
||||
#endif
|
||||
|
||||
using namespace current;
|
||||
} // namespace units
|
||||
@@ -1,17 +0,0 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "units/angle.h"
|
||||
#include "units/base.h"
|
||||
#include "units/length.h"
|
||||
|
||||
namespace units {
|
||||
using curvature_t = units::unit_t<
|
||||
units::compound_unit<units::radians, units::inverse<units::meters>>>;
|
||||
} // namespace units
|
||||
@@ -1,55 +0,0 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// 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/base.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::data
|
||||
* @brief namespace for unit types and containers representing data values
|
||||
* @details The base unit for data is `bytes`, and the corresponding `base_unit`
|
||||
* category is `data_unit`.
|
||||
* @anchor dataContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_DATA_UNITS)
|
||||
UNIT_ADD_WITH_METRIC_AND_BINARY_PREFIXES(
|
||||
data, byte, bytes, B, unit<std::ratio<1>, units::category::data_unit>)
|
||||
UNIT_ADD(data, exabyte, exabytes, EB, unit<std::ratio<1000>, petabytes>)
|
||||
UNIT_ADD_WITH_METRIC_AND_BINARY_PREFIXES(data, bit, bits, b,
|
||||
unit<std::ratio<1, 8>, byte>)
|
||||
UNIT_ADD(data, exabit, exabits, Eb, unit<std::ratio<1000>, petabits>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(data)
|
||||
#endif
|
||||
|
||||
using namespace data;
|
||||
} // namespace units
|
||||
@@ -1,60 +0,0 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// 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/base.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::data_transfer_rate
|
||||
* @brief namespace for unit types and containers representing data values
|
||||
* @details The base unit for data is `bytes`, and the corresponding `base_unit`
|
||||
* category is `data_unit`.
|
||||
* @anchor dataContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || \
|
||||
defined(ENABLE_PREDEFINED_DATA_TRANSFER_RATE_UNITS)
|
||||
UNIT_ADD_WITH_METRIC_AND_BINARY_PREFIXES(
|
||||
data_transfer_rate, bytes_per_second, bytes_per_second, Bps,
|
||||
unit<std::ratio<1>, units::category::data_transfer_rate_unit>)
|
||||
UNIT_ADD(data_transfer_rate, exabytes_per_second, exabytes_per_second, EBps,
|
||||
unit<std::ratio<1000>, petabytes_per_second>)
|
||||
UNIT_ADD_WITH_METRIC_AND_BINARY_PREFIXES(
|
||||
data_transfer_rate, bits_per_second, bits_per_second, bps,
|
||||
unit<std::ratio<1, 8>, bytes_per_second>)
|
||||
UNIT_ADD(data_transfer_rate, exabits_per_second, exabits_per_second, Ebps,
|
||||
unit<std::ratio<1000>, petabits_per_second>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(data_transfer_rate)
|
||||
#endif
|
||||
|
||||
using namespace data_transfer_rate;
|
||||
} // namespace units
|
||||
@@ -1,73 +0,0 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// 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/base.h"
|
||||
#include "units/mass.h"
|
||||
#include "units/volume.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::density
|
||||
* @brief namespace for unit types and containers representing density values
|
||||
* @details The SI unit for density is `kilograms_per_cubic_meter`, and the
|
||||
* corresponding `base_unit` category is `density_unit`.
|
||||
* @anchor densityContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || \
|
||||
defined(ENABLE_PREDEFINED_DENSITY_UNITS)
|
||||
UNIT_ADD(density, kilograms_per_cubic_meter, kilograms_per_cubic_meter,
|
||||
kg_per_cu_m, unit<std::ratio<1>, units::category::density_unit>)
|
||||
UNIT_ADD(density, grams_per_milliliter, grams_per_milliliter, g_per_mL,
|
||||
compound_unit<mass::grams, inverse<volume::milliliter>>)
|
||||
UNIT_ADD(density, kilograms_per_liter, kilograms_per_liter, kg_per_L,
|
||||
unit<std::ratio<1>,
|
||||
compound_unit<mass::grams, inverse<volume::milliliter>>>)
|
||||
UNIT_ADD(density, ounces_per_cubic_foot, ounces_per_cubic_foot, oz_per_cu_ft,
|
||||
compound_unit<mass::ounces, inverse<volume::cubic_foot>>)
|
||||
UNIT_ADD(density, ounces_per_cubic_inch, ounces_per_cubic_inch, oz_per_cu_in,
|
||||
compound_unit<mass::ounces, inverse<volume::cubic_inch>>)
|
||||
UNIT_ADD(density, ounces_per_gallon, ounces_per_gallon, oz_per_gal,
|
||||
compound_unit<mass::ounces, inverse<volume::gallon>>)
|
||||
UNIT_ADD(density, pounds_per_cubic_foot, pounds_per_cubic_foot, lb_per_cu_ft,
|
||||
compound_unit<mass::pounds, inverse<volume::cubic_foot>>)
|
||||
UNIT_ADD(density, pounds_per_cubic_inch, pounds_per_cubic_inch, lb_per_cu_in,
|
||||
compound_unit<mass::pounds, inverse<volume::cubic_inch>>)
|
||||
UNIT_ADD(density, pounds_per_gallon, pounds_per_gallon, lb_per_gal,
|
||||
compound_unit<mass::pounds, inverse<volume::gallon>>)
|
||||
UNIT_ADD(density, slugs_per_cubic_foot, slugs_per_cubic_foot, slug_per_cu_ft,
|
||||
compound_unit<mass::slugs, inverse<volume::cubic_foot>>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(density)
|
||||
#endif
|
||||
|
||||
using namespace density;
|
||||
} // namespace units
|
||||
@@ -1,39 +0,0 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// 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/base.h"
|
||||
|
||||
namespace units {
|
||||
using dimensionless::dB_t;
|
||||
using dimensionless::dimensionless_t;
|
||||
using dimensionless::scalar;
|
||||
using dimensionless::scalar_t;
|
||||
} // namespace units
|
||||
@@ -1,68 +0,0 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// 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/base.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::energy
|
||||
* @brief namespace for unit types and containers representing energy values
|
||||
* @details The SI unit for energy is `joules`, and the corresponding
|
||||
* `base_unit` category is `energy_unit`.
|
||||
* @anchor energyContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || \
|
||||
defined(ENABLE_PREDEFINED_ENERGY_UNITS)
|
||||
UNIT_ADD_WITH_METRIC_PREFIXES(energy, joule, joules, J,
|
||||
unit<std::ratio<1>, units::category::energy_unit>)
|
||||
UNIT_ADD_WITH_METRIC_PREFIXES(energy, calorie, calories, cal,
|
||||
unit<std::ratio<4184, 1000>, joules>)
|
||||
UNIT_ADD(energy, kilowatt_hour, kilowatt_hours, kWh,
|
||||
unit<std::ratio<36, 10>, megajoules>)
|
||||
UNIT_ADD(energy, watt_hour, watt_hours, Wh,
|
||||
unit<std::ratio<1, 1000>, kilowatt_hours>)
|
||||
UNIT_ADD(energy, british_thermal_unit, british_thermal_units, BTU,
|
||||
unit<std::ratio<105505585262, 100000000>, joules>)
|
||||
UNIT_ADD(energy, british_thermal_unit_iso, british_thermal_units_iso, BTU_iso,
|
||||
unit<std::ratio<1055056, 1000>, joules>)
|
||||
UNIT_ADD(energy, british_thermal_unit_59, british_thermal_units_59, BTU59,
|
||||
unit<std::ratio<1054804, 1000>, joules>)
|
||||
UNIT_ADD(energy, therm, therms, thm,
|
||||
unit<std::ratio<100000>, british_thermal_units_59>)
|
||||
UNIT_ADD(energy, foot_pound, foot_pounds, ftlbf,
|
||||
unit<std::ratio<13558179483314004, 10000000000000000>, joules>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(energy)
|
||||
#endif
|
||||
|
||||
using namespace energy;
|
||||
} // namespace units
|
||||
@@ -1,65 +0,0 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// 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/acceleration.h"
|
||||
#include "units/base.h"
|
||||
#include "units/length.h"
|
||||
#include "units/mass.h"
|
||||
#include "units/time.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::force
|
||||
* @brief namespace for unit types and containers representing force values
|
||||
* @details The SI unit for force is `newtons`, and the corresponding
|
||||
* `base_unit` category is `force_unit`.
|
||||
* @anchor forceContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_FORCE_UNITS)
|
||||
UNIT_ADD_WITH_METRIC_PREFIXES(force, newton, newtons, N,
|
||||
unit<std::ratio<1>, units::category::force_unit>)
|
||||
UNIT_ADD(
|
||||
force, pound, pounds, lbf,
|
||||
compound_unit<mass::slug, length::foot, inverse<squared<time::seconds>>>)
|
||||
UNIT_ADD(force, dyne, dynes, dyn, unit<std::ratio<1, 100000>, newtons>)
|
||||
UNIT_ADD(force, kilopond, kiloponds, kp,
|
||||
compound_unit<acceleration::standard_gravity, mass::kilograms>)
|
||||
UNIT_ADD(
|
||||
force, poundal, poundals, pdl,
|
||||
compound_unit<mass::pound, length::foot, inverse<squared<time::seconds>>>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(force)
|
||||
#endif
|
||||
|
||||
using force::newton_t;
|
||||
using force::newtons;
|
||||
} // namespace units
|
||||
@@ -1,53 +0,0 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// 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/base.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::frequency
|
||||
* @brief namespace for unit types and containers representing frequency values
|
||||
* @details The SI unit for frequency is `hertz`, and the corresponding
|
||||
* `base_unit` category is `frequency_unit`.
|
||||
* @anchor frequencyContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || \
|
||||
defined(ENABLE_PREDEFINED_FREQUENCY_UNITS)
|
||||
UNIT_ADD_WITH_METRIC_PREFIXES(
|
||||
frequency, hertz, hertz, Hz,
|
||||
unit<std::ratio<1>, units::category::frequency_unit>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(frequency)
|
||||
#endif
|
||||
|
||||
using namespace frequency;
|
||||
} // namespace units
|
||||
@@ -1,64 +0,0 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// 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/base.h"
|
||||
#include "units/length.h"
|
||||
#include "units/luminous_flux.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::illuminance
|
||||
* @brief namespace for unit types and containers representing illuminance
|
||||
* values
|
||||
* @details The SI unit for illuminance is `luxes`, and the corresponding
|
||||
* `base_unit` category is `illuminance_unit`.
|
||||
* @anchor illuminanceContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || \
|
||||
defined(ENABLE_PREDEFINED_ILLUMINANCE_UNITS)
|
||||
UNIT_ADD_WITH_METRIC_PREFIXES(
|
||||
illuminance, lux, luxes, lx,
|
||||
unit<std::ratio<1>, units::category::illuminance_unit>)
|
||||
UNIT_ADD(illuminance, footcandle, footcandles, fc,
|
||||
compound_unit<luminous_flux::lumen, inverse<squared<length::foot>>>)
|
||||
UNIT_ADD(illuminance, lumens_per_square_inch, lumens_per_square_inch,
|
||||
lm_per_in_sq,
|
||||
compound_unit<luminous_flux::lumen, inverse<squared<length::inch>>>)
|
||||
UNIT_ADD(
|
||||
illuminance, phot, phots, ph,
|
||||
compound_unit<luminous_flux::lumens, inverse<squared<length::centimeter>>>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(illuminance)
|
||||
#endif
|
||||
|
||||
using namespace illuminance;
|
||||
} // namespace units
|
||||
@@ -1,53 +0,0 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// 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/base.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::impedance
|
||||
* @brief namespace for unit types and containers representing impedance values
|
||||
* @details The SI unit for impedance is `ohms`, and the corresponding
|
||||
* `base_unit` category is `impedance_unit`.
|
||||
* @anchor impedanceContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || \
|
||||
defined(ENABLE_PREDEFINED_IMPEDANCE_UNITS)
|
||||
UNIT_ADD_WITH_METRIC_PREFIXES(
|
||||
impedance, ohm, ohms, Ohm,
|
||||
unit<std::ratio<1>, units::category::impedance_unit>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(impedance)
|
||||
#endif
|
||||
|
||||
using namespace impedance;
|
||||
} // namespace units
|
||||
@@ -1,53 +0,0 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// 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/base.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::inductance
|
||||
* @brief namespace for unit types and containers representing inductance values
|
||||
* @details The SI unit for inductance is `henrys`, and the corresponding
|
||||
* `base_unit` category is `inductance_unit`.
|
||||
* @anchor inductanceContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || \
|
||||
defined(ENABLE_PREDEFINED_INDUCTANCE_UNITS)
|
||||
UNIT_ADD_WITH_METRIC_PREFIXES(
|
||||
inductance, henry, henries, H,
|
||||
unit<std::ratio<1>, units::category::inductance_unit>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(inductance)
|
||||
#endif
|
||||
|
||||
using namespace inductance;
|
||||
} // namespace units
|
||||
@@ -1,75 +0,0 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// 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/base.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::length
|
||||
* @brief namespace for unit types and containers representing length values
|
||||
* @details The SI unit for length is `meters`, and the corresponding
|
||||
* `base_unit` category is `length_unit`.
|
||||
* @anchor lengthContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || \
|
||||
defined(ENABLE_PREDEFINED_LENGTH_UNITS)
|
||||
UNIT_ADD_WITH_METRIC_PREFIXES(length, meter, meters, m,
|
||||
unit<std::ratio<1>, units::category::length_unit>)
|
||||
UNIT_ADD(length, foot, feet, ft, unit<std::ratio<381, 1250>, meters>)
|
||||
UNIT_ADD(length, mil, mils, mil, unit<std::ratio<1000>, feet>)
|
||||
UNIT_ADD(length, inch, inches, in, unit<std::ratio<1, 12>, feet>)
|
||||
UNIT_ADD(length, mile, miles, mi, unit<std::ratio<5280>, feet>)
|
||||
UNIT_ADD(length, nauticalMile, nauticalMiles, nmi,
|
||||
unit<std::ratio<1852>, meters>)
|
||||
UNIT_ADD(length, astronicalUnit, astronicalUnits, au,
|
||||
unit<std::ratio<149597870700>, meters>)
|
||||
UNIT_ADD(length, lightyear, lightyears, ly,
|
||||
unit<std::ratio<9460730472580800>, meters>)
|
||||
UNIT_ADD(length, parsec, parsecs, pc,
|
||||
unit<std::ratio<648000>, astronicalUnits, std::ratio<-1>>)
|
||||
UNIT_ADD(length, angstrom, angstroms, angstrom,
|
||||
unit<std::ratio<1, 10>, nanometers>)
|
||||
UNIT_ADD(length, cubit, cubits, cbt, unit<std::ratio<18>, inches>)
|
||||
UNIT_ADD(length, fathom, fathoms, ftm, unit<std::ratio<6>, feet>)
|
||||
UNIT_ADD(length, chain, chains, ch, unit<std::ratio<66>, feet>)
|
||||
UNIT_ADD(length, furlong, furlongs, fur, unit<std::ratio<10>, chains>)
|
||||
UNIT_ADD(length, hand, hands, hand, unit<std::ratio<4>, inches>)
|
||||
UNIT_ADD(length, league, leagues, lea, unit<std::ratio<3>, miles>)
|
||||
UNIT_ADD(length, nauticalLeague, nauticalLeagues, nl,
|
||||
unit<std::ratio<3>, nauticalMiles>)
|
||||
UNIT_ADD(length, yard, yards, yd, unit<std::ratio<3>, feet>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(length)
|
||||
#endif
|
||||
|
||||
using namespace length;
|
||||
} // namespace units
|
||||
@@ -1,54 +0,0 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// 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/base.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::luminous_flux
|
||||
* @brief namespace for unit types and containers representing luminous_flux
|
||||
* values
|
||||
* @details The SI unit for luminous_flux is `lumens`, and the corresponding
|
||||
* `base_unit` category is `luminous_flux_unit`.
|
||||
* @anchor luminousFluxContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || \
|
||||
defined(ENABLE_PREDEFINED_LUMINOUS_FLUX_UNITS)
|
||||
UNIT_ADD_WITH_METRIC_PREFIXES(
|
||||
luminous_flux, lumen, lumens, lm,
|
||||
unit<std::ratio<1>, units::category::luminous_flux_unit>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(luminous_flux)
|
||||
#endif
|
||||
|
||||
using namespace luminous_flux;
|
||||
} // namespace units
|
||||
@@ -1,54 +0,0 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// 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/base.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::luminous_intensity
|
||||
* @brief namespace for unit types and containers representing
|
||||
* luminous_intensity values
|
||||
* @details The SI unit for luminous_intensity is `candelas`, and the
|
||||
* corresponding `base_unit` category is `luminous_intensity_unit`.
|
||||
* @anchor luminousIntensityContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || \
|
||||
defined(ENABLE_PREDEFINED_LUMINOUS_INTENSITY_UNITS)
|
||||
UNIT_ADD_WITH_METRIC_PREFIXES(
|
||||
luminous_intensity, candela, candelas, cd,
|
||||
unit<std::ratio<1>, units::category::luminous_intensity_unit>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(luminous_intensity)
|
||||
#endif
|
||||
|
||||
using namespace luminous_intensity;
|
||||
} // namespace units
|
||||
@@ -1,62 +0,0 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// 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/base.h"
|
||||
#include "units/length.h"
|
||||
#include "units/magnetic_flux.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::magnetic_field_strength
|
||||
* @brief namespace for unit types and containers representing
|
||||
* magnetic_field_strength values
|
||||
* @details The SI unit for magnetic_field_strength is `teslas`, and the
|
||||
* corresponding `base_unit` category is
|
||||
* `magnetic_field_strength_unit`.
|
||||
* @anchor magneticFieldStrengthContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
// Unfortunately `_T` is a WINAPI macro, so we have to use `_Te` as the tesla
|
||||
// abbreviation.
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || \
|
||||
defined(ENABLE_PREDEFINED_MAGNETIC_FIELD_STRENGTH_UNITS)
|
||||
UNIT_ADD_WITH_METRIC_PREFIXES(
|
||||
magnetic_field_strength, tesla, teslas, Te,
|
||||
unit<std::ratio<1>, units::category::magnetic_field_strength_unit>)
|
||||
UNIT_ADD(
|
||||
magnetic_field_strength, gauss, gauss, G,
|
||||
compound_unit<magnetic_flux::maxwell, inverse<squared<length::centimeter>>>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(magnetic_field_strength)
|
||||
#endif
|
||||
|
||||
using namespace magnetic_field_strength;
|
||||
} // namespace units
|
||||
@@ -1,56 +0,0 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// 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/base.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::magnetic_flux
|
||||
* @brief namespace for unit types and containers representing magnetic_flux
|
||||
* values
|
||||
* @details The SI unit for magnetic_flux is `webers`, and the corresponding
|
||||
* `base_unit` category is `magnetic_flux_unit`.
|
||||
* @anchor magneticFluxContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || \
|
||||
defined(ENABLE_PREDEFINED_MAGNETIC_FLUX_UNITS)
|
||||
UNIT_ADD_WITH_METRIC_PREFIXES(
|
||||
magnetic_flux, weber, webers, Wb,
|
||||
unit<std::ratio<1>, units::category::magnetic_flux_unit>)
|
||||
UNIT_ADD(magnetic_flux, maxwell, maxwells, Mx,
|
||||
unit<std::ratio<1, 100000000>, webers>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(magnetic_flux)
|
||||
#endif
|
||||
|
||||
using namespace magnetic_flux;
|
||||
} // namespace units
|
||||
@@ -1,61 +0,0 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// 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/base.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::mass
|
||||
* @brief namespace for unit types and containers representing mass values
|
||||
* @details The SI unit for mass is `kilograms`, and the corresponding
|
||||
* `base_unit` category is `mass_unit`.
|
||||
* @anchor massContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_MASS_UNITS)
|
||||
UNIT_ADD_WITH_METRIC_PREFIXES(
|
||||
mass, gram, grams, g, unit<std::ratio<1, 1000>, units::category::mass_unit>)
|
||||
UNIT_ADD(mass, metric_ton, metric_tons, t, unit<std::ratio<1000>, kilograms>)
|
||||
UNIT_ADD(mass, pound, pounds, lb,
|
||||
unit<std::ratio<45359237, 100000000>, kilograms>)
|
||||
UNIT_ADD(mass, long_ton, long_tons, ln_t, unit<std::ratio<2240>, pounds>)
|
||||
UNIT_ADD(mass, short_ton, short_tons, sh_t, unit<std::ratio<2000>, pounds>)
|
||||
UNIT_ADD(mass, stone, stone, st, unit<std::ratio<14>, pounds>)
|
||||
UNIT_ADD(mass, ounce, ounces, oz, unit<std::ratio<1, 16>, pounds>)
|
||||
UNIT_ADD(mass, carat, carats, ct, unit<std::ratio<200>, milligrams>)
|
||||
UNIT_ADD(mass, slug, slugs, slug,
|
||||
unit<std::ratio<145939029, 10000000>, kilograms>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(mass)
|
||||
#endif
|
||||
|
||||
using namespace mass;
|
||||
} // namespace units
|
||||
@@ -1,779 +0,0 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// 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 <cmath>
|
||||
|
||||
#include <wpi/math>
|
||||
|
||||
#include "units/angle.h"
|
||||
#include "units/base.h"
|
||||
#include "units/dimensionless.h"
|
||||
|
||||
namespace units {
|
||||
//----------------------------------
|
||||
// UNIT-ENABLED CMATH FUNCTIONS
|
||||
//----------------------------------
|
||||
|
||||
/**
|
||||
* @brief namespace for unit-enabled versions of the `<cmath>` library
|
||||
* @details Includes trigonometric functions, exponential/log functions,
|
||||
* rounding functions, etc.
|
||||
* @sa See `unit_t` for more information on unit type containers.
|
||||
*/
|
||||
namespace math {
|
||||
//----------------------------------
|
||||
// TRIGONOMETRIC FUNCTIONS
|
||||
//----------------------------------
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Compute cosine
|
||||
* @details The input value can be in any unit of angle, including radians or
|
||||
* degrees.
|
||||
* @tparam AngleUnit any `unit_t` type of `category::angle_unit`.
|
||||
* @param[in] angle angle to compute the cosine of
|
||||
* @returns Returns the cosine of <i>angle</i>
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_ANGLE_UNITS)
|
||||
template <class AngleUnit>
|
||||
dimensionless::scalar_t cos(const AngleUnit angle) noexcept {
|
||||
static_assert(
|
||||
traits::is_angle_unit<AngleUnit>::value,
|
||||
"Type `AngleUnit` must be a unit of angle derived from `unit_t`.");
|
||||
return dimensionless::scalar_t(
|
||||
std::cos(angle.template convert<angle::radian>()()));
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Compute sine
|
||||
* @details The input value can be in any unit of angle, including radians or
|
||||
* degrees.
|
||||
* @tparam AngleUnit any `unit_t` type of `category::angle_unit`.
|
||||
* @param[in] angle angle to compute the since of
|
||||
* @returns Returns the sine of <i>angle</i>
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_ANGLE_UNITS)
|
||||
template <class AngleUnit>
|
||||
dimensionless::scalar_t sin(const AngleUnit angle) noexcept {
|
||||
static_assert(
|
||||
traits::is_angle_unit<AngleUnit>::value,
|
||||
"Type `AngleUnit` must be a unit of angle derived from `unit_t`.");
|
||||
return dimensionless::scalar_t(
|
||||
std::sin(angle.template convert<angle::radian>()()));
|
||||
}
|
||||
#endif
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Compute tangent
|
||||
* @details The input value can be in any unit of angle, including radians or
|
||||
* degrees.
|
||||
* @tparam AngleUnit any `unit_t` type of `category::angle_unit`.
|
||||
* @param[in] angle angle to compute the tangent of
|
||||
* @returns Returns the tangent of <i>angle</i>
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_ANGLE_UNITS)
|
||||
template <class AngleUnit>
|
||||
dimensionless::scalar_t tan(const AngleUnit angle) noexcept {
|
||||
static_assert(
|
||||
traits::is_angle_unit<AngleUnit>::value,
|
||||
"Type `AngleUnit` must be a unit of angle derived from `unit_t`.");
|
||||
return dimensionless::scalar_t(
|
||||
std::tan(angle.template convert<angle::radian>()()));
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Compute arc cosine
|
||||
* @details Returns the principal value of the arc cosine of x, expressed in
|
||||
* radians.
|
||||
* @param[in] x Value whose arc cosine is computed, in the interval [-1,+1].
|
||||
* @returns Principal arc cosine of x, in the interval [0,pi] radians.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_ANGLE_UNITS)
|
||||
template <class ScalarUnit>
|
||||
angle::radian_t acos(const ScalarUnit x) noexcept {
|
||||
static_assert(
|
||||
traits::is_dimensionless_unit<ScalarUnit>::value,
|
||||
"Type `ScalarUnit` must be a dimensionless unit derived from `unit_t`.");
|
||||
return angle::radian_t(std::acos(x()));
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Compute arc sine
|
||||
* @details Returns the principal value of the arc sine of x, expressed in
|
||||
* radians.
|
||||
* @param[in] x Value whose arc sine is computed, in the interval [-1,+1].
|
||||
* @returns Principal arc sine of x, in the interval [-pi/2,+pi/2] radians.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_ANGLE_UNITS)
|
||||
template <class ScalarUnit>
|
||||
angle::radian_t asin(const ScalarUnit x) noexcept {
|
||||
static_assert(
|
||||
traits::is_dimensionless_unit<ScalarUnit>::value,
|
||||
"Type `ScalarUnit` must be a dimensionless unit derived from `unit_t`.");
|
||||
return angle::radian_t(std::asin(x()));
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Compute arc tangent
|
||||
* @details Returns the principal value of the arc tangent of x, expressed in
|
||||
* radians. Notice that because of the sign ambiguity, the function
|
||||
* cannot determine with certainty in which quadrant the angle falls
|
||||
* only by its tangent value. See atan2 for an alternative that takes a
|
||||
* fractional argument instead.
|
||||
* @tparam AngleUnit any `unit_t` type of `category::angle_unit`.
|
||||
* @param[in] x Value whose arc tangent is computed, in the interval [-1,+1].
|
||||
* @returns Principal arc tangent of x, in the interval [-pi/2,+pi/2] radians.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_ANGLE_UNITS)
|
||||
template <class ScalarUnit>
|
||||
angle::radian_t atan(const ScalarUnit x) noexcept {
|
||||
static_assert(
|
||||
traits::is_dimensionless_unit<ScalarUnit>::value,
|
||||
"Type `ScalarUnit` must be a dimensionless unit derived from `unit_t`.");
|
||||
return angle::radian_t(std::atan(x()));
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Compute arc tangent with two parameters
|
||||
* @details To compute the value, the function takes into account the sign of
|
||||
* both arguments in order to determine the quadrant.
|
||||
* @param[in] y y-component of the triangle expressed.
|
||||
* @param[in] x x-component of the triangle expressed.
|
||||
* @returns Returns the principal value of the arc tangent of <i>y/x</i>,
|
||||
* expressed in radians.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_ANGLE_UNITS)
|
||||
template <class Y, class X>
|
||||
angle::radian_t atan2(const Y y, const X x) noexcept {
|
||||
static_assert(traits::is_dimensionless_unit<decltype(y / x)>::value,
|
||||
"The quantity y/x must yield a dimensionless ratio.");
|
||||
|
||||
// X and Y could be different length units, so normalize them
|
||||
return angle::radian_t(
|
||||
std::atan2(y.template convert<
|
||||
typename units::traits::unit_t_traits<X>::unit_type>()(),
|
||||
x()));
|
||||
}
|
||||
#endif
|
||||
|
||||
//----------------------------------
|
||||
// HYPERBOLIC TRIG FUNCTIONS
|
||||
//----------------------------------
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Compute hyperbolic cosine
|
||||
* @details The input value can be in any unit of angle, including radians or
|
||||
* degrees.
|
||||
* @tparam AngleUnit any `unit_t` type of `category::angle_unit`.
|
||||
* @param[in] angle angle to compute the hyperbolic cosine of
|
||||
* @returns Returns the hyperbolic cosine of <i>angle</i>
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_ANGLE_UNITS)
|
||||
template <class AngleUnit>
|
||||
dimensionless::scalar_t cosh(const AngleUnit angle) noexcept {
|
||||
static_assert(
|
||||
traits::is_angle_unit<AngleUnit>::value,
|
||||
"Type `AngleUnit` must be a unit of angle derived from `unit_t`.");
|
||||
return dimensionless::scalar_t(
|
||||
std::cosh(angle.template convert<angle::radian>()()));
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Compute hyperbolic sine
|
||||
* @details The input value can be in any unit of angle, including radians or
|
||||
* degrees.
|
||||
* @tparam AngleUnit any `unit_t` type of `category::angle_unit`.
|
||||
* @param[in] angle angle to compute the hyperbolic sine of
|
||||
* @returns Returns the hyperbolic sine of <i>angle</i>
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_ANGLE_UNITS)
|
||||
template <class AngleUnit>
|
||||
dimensionless::scalar_t sinh(const AngleUnit angle) noexcept {
|
||||
static_assert(
|
||||
traits::is_angle_unit<AngleUnit>::value,
|
||||
"Type `AngleUnit` must be a unit of angle derived from `unit_t`.");
|
||||
return dimensionless::scalar_t(
|
||||
std::sinh(angle.template convert<angle::radian>()()));
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Compute hyperbolic tangent
|
||||
* @details The input value can be in any unit of angle, including radians or
|
||||
* degrees.
|
||||
* @tparam AngleUnit any `unit_t` type of `category::angle_unit`.
|
||||
* @param[in] angle angle to compute the hyperbolic tangent of
|
||||
* @returns Returns the hyperbolic tangent of <i>angle</i>
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_ANGLE_UNITS)
|
||||
template <class AngleUnit>
|
||||
dimensionless::scalar_t tanh(const AngleUnit angle) noexcept {
|
||||
static_assert(
|
||||
traits::is_angle_unit<AngleUnit>::value,
|
||||
"Type `AngleUnit` must be a unit of angle derived from `unit_t`.");
|
||||
return dimensionless::scalar_t(
|
||||
std::tanh(angle.template convert<angle::radian>()()));
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Compute arc hyperbolic cosine
|
||||
* @details Returns the nonnegative arc hyperbolic cosine of x, expressed in
|
||||
* radians.
|
||||
* @param[in] x Value whose arc hyperbolic cosine is computed. If the argument
|
||||
* is less than 1, a domain error occurs.
|
||||
* @returns Nonnegative arc hyperbolic cosine of x, in the interval
|
||||
* [0,+INFINITY] radians.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_ANGLE_UNITS)
|
||||
template <class ScalarUnit>
|
||||
angle::radian_t acosh(const ScalarUnit x) noexcept {
|
||||
static_assert(
|
||||
traits::is_dimensionless_unit<ScalarUnit>::value,
|
||||
"Type `ScalarUnit` must be a dimensionless unit derived from `unit_t`.");
|
||||
return angle::radian_t(std::acosh(x()));
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Compute arc hyperbolic sine
|
||||
* @details Returns the arc hyperbolic sine of x, expressed in radians.
|
||||
* @param[in] x Value whose arc hyperbolic sine is computed.
|
||||
* @returns Arc hyperbolic sine of x, in radians.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_ANGLE_UNITS)
|
||||
template <class ScalarUnit>
|
||||
angle::radian_t asinh(const ScalarUnit x) noexcept {
|
||||
static_assert(
|
||||
traits::is_dimensionless_unit<ScalarUnit>::value,
|
||||
"Type `ScalarUnit` must be a dimensionless unit derived from `unit_t`.");
|
||||
return angle::radian_t(std::asinh(x()));
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Compute arc hyperbolic tangent
|
||||
* @details Returns the arc hyperbolic tangent of x, expressed in radians.
|
||||
* @param[in] x Value whose arc hyperbolic tangent is computed, in the interval
|
||||
* [-1,+1]. If the argument is out of this interval, a domain error
|
||||
* occurs. For values of -1 and +1, a pole error may occur.
|
||||
* @returns units::angle::radian_t
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_ANGLE_UNITS)
|
||||
template <class ScalarUnit>
|
||||
angle::radian_t atanh(const ScalarUnit x) noexcept {
|
||||
static_assert(
|
||||
traits::is_dimensionless_unit<ScalarUnit>::value,
|
||||
"Type `ScalarUnit` must be a dimensionless unit derived from `unit_t`.");
|
||||
return angle::radian_t(std::atanh(x()));
|
||||
}
|
||||
#endif
|
||||
|
||||
//----------------------------------
|
||||
// TRANSCENDENTAL FUNCTIONS
|
||||
//----------------------------------
|
||||
|
||||
// it makes NO SENSE to put dimensioned units into a transcendental function,
|
||||
// and if you think it does you are demonstrably wrong.
|
||||
// https://en.wikipedia.org/wiki/Transcendental_function#Dimensional_analysis
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Compute exponential function
|
||||
* @details Returns the base-e exponential function of x, which is e raised to
|
||||
* the power x: ex.
|
||||
* @param[in] x scalar value of the exponent.
|
||||
* @returns Exponential value of x.
|
||||
* If the magnitude of the result is too large to be represented by a
|
||||
* value of the return type, the function returns HUGE_VAL (or
|
||||
* HUGE_VALF or HUGE_VALL) with the proper sign, and an overflow range
|
||||
* error occurs.
|
||||
*/
|
||||
template <class ScalarUnit>
|
||||
dimensionless::scalar_t exp(const ScalarUnit x) noexcept {
|
||||
static_assert(
|
||||
traits::is_dimensionless_unit<ScalarUnit>::value,
|
||||
"Type `ScalarUnit` must be a dimensionless unit derived from `unit_t`.");
|
||||
return dimensionless::scalar_t(std::exp(x()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Compute natural logarithm
|
||||
* @details Returns the natural logarithm of x.
|
||||
* @param[in] x scalar value whose logarithm is calculated. If the argument is
|
||||
* negative, a domain error occurs.
|
||||
* @sa log10 for more common base-10 logarithms
|
||||
* @returns Natural logarithm of x.
|
||||
*/
|
||||
template <class ScalarUnit>
|
||||
dimensionless::scalar_t log(const ScalarUnit x) noexcept {
|
||||
static_assert(
|
||||
traits::is_dimensionless_unit<ScalarUnit>::value,
|
||||
"Type `ScalarUnit` must be a dimensionless unit derived from `unit_t`.");
|
||||
return dimensionless::scalar_t(std::log(x()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Compute common logarithm
|
||||
* @details Returns the common (base-10) logarithm of x.
|
||||
* @param[in] x Value whose logarithm is calculated. If the argument is
|
||||
* negative, a domain error occurs.
|
||||
* @returns Common logarithm of x.
|
||||
*/
|
||||
template <class ScalarUnit>
|
||||
dimensionless::scalar_t log10(const ScalarUnit x) noexcept {
|
||||
static_assert(
|
||||
traits::is_dimensionless_unit<ScalarUnit>::value,
|
||||
"Type `ScalarUnit` must be a dimensionless unit derived from `unit_t`.");
|
||||
return dimensionless::scalar_t(std::log10(x()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Break into fractional and integral parts.
|
||||
* @details The integer part is stored in the object pointed by intpart, and the
|
||||
* fractional part is returned by the function. Both parts have the
|
||||
* same sign as x.
|
||||
* @param[in] x scalar value to break into parts.
|
||||
* @param[in] intpart Pointer to an object (of the same type as x) where the
|
||||
* integral part is stored with the same sign as x.
|
||||
* @returns The fractional part of x, with the same sign.
|
||||
*/
|
||||
template <class ScalarUnit>
|
||||
dimensionless::scalar_t modf(const ScalarUnit x, ScalarUnit* intpart) noexcept {
|
||||
static_assert(
|
||||
traits::is_dimensionless_unit<ScalarUnit>::value,
|
||||
"Type `ScalarUnit` must be a dimensionless unit derived from `unit_t`.");
|
||||
|
||||
UNIT_LIB_DEFAULT_TYPE intp;
|
||||
dimensionless::scalar_t fracpart =
|
||||
dimensionless::scalar_t(std::modf(x(), &intp));
|
||||
*intpart = intp;
|
||||
return fracpart;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Compute binary exponential function
|
||||
* @details Returns the base-2 exponential function of x, which is 2 raised to
|
||||
* the power x: 2^x. 2param[in] x Value of the exponent.
|
||||
* @returns 2 raised to the power of x.
|
||||
*/
|
||||
template <class ScalarUnit>
|
||||
dimensionless::scalar_t exp2(const ScalarUnit x) noexcept {
|
||||
static_assert(
|
||||
traits::is_dimensionless_unit<ScalarUnit>::value,
|
||||
"Type `ScalarUnit` must be a dimensionless unit derived from `unit_t`.");
|
||||
return dimensionless::scalar_t(std::exp2(x()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Compute exponential minus one
|
||||
* @details Returns e raised to the power x minus one: e^x-1. For small
|
||||
* magnitude values of x, expm1 may be more accurate than exp(x)-1.
|
||||
* @param[in] x Value of the exponent.
|
||||
* @returns e raised to the power of x, minus one.
|
||||
*/
|
||||
template <class ScalarUnit>
|
||||
dimensionless::scalar_t expm1(const ScalarUnit x) noexcept {
|
||||
static_assert(
|
||||
traits::is_dimensionless_unit<ScalarUnit>::value,
|
||||
"Type `ScalarUnit` must be a dimensionless unit derived from `unit_t`.");
|
||||
return dimensionless::scalar_t(std::expm1(x()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Compute logarithm plus one
|
||||
* @details Returns the natural logarithm of one plus x. For small magnitude
|
||||
* values of x, logp1 may be more accurate than log(1+x).
|
||||
* @param[in] x Value whose logarithm is calculated. If the argument is less
|
||||
* than -1, a domain error occurs.
|
||||
* @returns The natural logarithm of (1+x).
|
||||
*/
|
||||
template <class ScalarUnit>
|
||||
dimensionless::scalar_t log1p(const ScalarUnit x) noexcept {
|
||||
static_assert(
|
||||
traits::is_dimensionless_unit<ScalarUnit>::value,
|
||||
"Type `ScalarUnit` must be a dimensionless unit derived from `unit_t`.");
|
||||
return dimensionless::scalar_t(std::log1p(x()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Compute binary logarithm
|
||||
* @details Returns the binary (base-2) logarithm of x.
|
||||
* @param[in] x Value whose logarithm is calculated. If the argument is
|
||||
* negative, a domain error occurs.
|
||||
* @returns The binary logarithm of x: log2x.
|
||||
*/
|
||||
template <class ScalarUnit>
|
||||
dimensionless::scalar_t log2(const ScalarUnit x) noexcept {
|
||||
static_assert(
|
||||
traits::is_dimensionless_unit<ScalarUnit>::value,
|
||||
"Type `ScalarUnit` must be a dimensionless unit derived from `unit_t`.");
|
||||
return dimensionless::scalar_t(std::log2(x()));
|
||||
}
|
||||
|
||||
//----------------------------------
|
||||
// POWER FUNCTIONS
|
||||
//----------------------------------
|
||||
|
||||
/* pow is implemented earlier in the library since a lot of the unit definitions
|
||||
* depend on it */
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief computes the square root of <i>value</i>
|
||||
* @details Only implemented for linear_scale units.
|
||||
* @param[in] value `unit_t` derived type to compute the square root of.
|
||||
* @returns new unit_t, whose units are the square root of value's.
|
||||
* E.g. if values had units of `square_meter`, then the return type
|
||||
* will have units of `meter`.
|
||||
* @note `sqrt` provides a _rational approximation_ of the square root of
|
||||
* <i>value</i>. In some cases, _both_ the returned value _and_ conversion
|
||||
* factor of the returned unit type may have errors no larger than
|
||||
* `1e-10`.
|
||||
*/
|
||||
template <
|
||||
class UnitType,
|
||||
std::enable_if_t<units::traits::has_linear_scale<UnitType>::value, int> = 0>
|
||||
inline auto sqrt(const UnitType& value) noexcept -> unit_t<
|
||||
square_root<typename units::traits::unit_t_traits<UnitType>::unit_type>,
|
||||
typename units::traits::unit_t_traits<UnitType>::underlying_type,
|
||||
linear_scale> {
|
||||
return unit_t<
|
||||
square_root<typename units::traits::unit_t_traits<UnitType>::unit_type>,
|
||||
typename units::traits::unit_t_traits<UnitType>::underlying_type,
|
||||
linear_scale>(std::sqrt(value()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Computes the square root of the sum-of-squares of x and y.
|
||||
* @details Only implemented for linear_scale units.
|
||||
* @param[in] x unit_t type value
|
||||
* @param[in] y unit_t type value
|
||||
* @returns square root of the sum-of-squares of x and y in the same units as x.
|
||||
*/
|
||||
template <class UnitTypeLhs, class UnitTypeRhs,
|
||||
std::enable_if_t<
|
||||
units::traits::has_linear_scale<UnitTypeLhs, UnitTypeRhs>::value,
|
||||
int> = 0>
|
||||
inline UnitTypeLhs hypot(const UnitTypeLhs& x, const UnitTypeRhs& y) {
|
||||
static_assert(traits::is_convertible_unit_t<UnitTypeLhs, UnitTypeRhs>::value,
|
||||
"Parameters of hypot() function are not compatible units.");
|
||||
return UnitTypeLhs(std::hypot(
|
||||
x(),
|
||||
y.template convert<
|
||||
typename units::traits::unit_t_traits<UnitTypeLhs>::unit_type>()()));
|
||||
}
|
||||
|
||||
//----------------------------------
|
||||
// ROUNDING FUNCTIONS
|
||||
//----------------------------------
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Round up value
|
||||
* @details Rounds x upward, returning the smallest integral value that is not
|
||||
* less than x.
|
||||
* @param[in] x Unit value to round up.
|
||||
* @returns The smallest integral value that is not less than x.
|
||||
*/
|
||||
template <class UnitType,
|
||||
class = std::enable_if_t<traits::is_unit_t<UnitType>::value>>
|
||||
UnitType ceil(const UnitType x) noexcept {
|
||||
return UnitType(std::ceil(x()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Round down value
|
||||
* @details Rounds x downward, returning the largest integral value that is not
|
||||
* greater than x.
|
||||
* @param[in] x Unit value to round down.
|
||||
* @returns The value of x rounded downward.
|
||||
*/
|
||||
template <class UnitType,
|
||||
class = std::enable_if_t<traits::is_unit_t<UnitType>::value>>
|
||||
UnitType floor(const UnitType x) noexcept {
|
||||
return UnitType(std::floor(x()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Compute remainder of division
|
||||
* @details Returns the floating-point remainder of numer/denom (rounded towards
|
||||
* zero).
|
||||
* @param[in] numer Value of the quotient numerator.
|
||||
* @param[in] denom Value of the quotient denominator.
|
||||
* @returns The remainder of dividing the arguments.
|
||||
*/
|
||||
template <class UnitTypeLhs, class UnitTypeRhs,
|
||||
class = std::enable_if_t<traits::is_unit_t<UnitTypeLhs>::value &&
|
||||
traits::is_unit_t<UnitTypeRhs>::value>>
|
||||
UnitTypeLhs fmod(const UnitTypeLhs numer, const UnitTypeRhs denom) noexcept {
|
||||
static_assert(traits::is_convertible_unit_t<UnitTypeLhs, UnitTypeRhs>::value,
|
||||
"Parameters of fmod() function are not compatible units.");
|
||||
return UnitTypeLhs(std::fmod(
|
||||
numer(),
|
||||
denom.template convert<
|
||||
typename units::traits::unit_t_traits<UnitTypeLhs>::unit_type>()()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Truncate value
|
||||
* @details Rounds x toward zero, returning the nearest integral value that is
|
||||
* not larger in magnitude than x. Effectively rounds towards 0.
|
||||
* @param[in] x Value to truncate
|
||||
* @returns The nearest integral value that is not larger in magnitude than x.
|
||||
*/
|
||||
template <class UnitType,
|
||||
class = std::enable_if_t<traits::is_unit_t<UnitType>::value>>
|
||||
UnitType trunc(const UnitType x) noexcept {
|
||||
return UnitType(std::trunc(x()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Round to nearest
|
||||
* @details Returns the integral value that is nearest to x, with halfway cases
|
||||
* rounded away from zero.
|
||||
* @param[in] x value to round.
|
||||
* @returns The value of x rounded to the nearest integral.
|
||||
*/
|
||||
template <class UnitType,
|
||||
class = std::enable_if_t<traits::is_unit_t<UnitType>::value>>
|
||||
UnitType round(const UnitType x) noexcept {
|
||||
return UnitType(std::round(x()));
|
||||
}
|
||||
|
||||
//----------------------------------
|
||||
// FLOATING POINT MANIPULATION
|
||||
//----------------------------------
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Copy sign
|
||||
* @details Returns a value with the magnitude and dimension of x, and the sign
|
||||
* of y. Values x and y do not have to be compatible units.
|
||||
* @param[in] x Value with the magnitude of the resulting value.
|
||||
* @param[in] y Value with the sign of the resulting value.
|
||||
* @returns value with the magnitude and dimension of x, and the sign of y.
|
||||
*/
|
||||
template <class UnitTypeLhs, class UnitTypeRhs,
|
||||
class = std::enable_if_t<traits::is_unit_t<UnitTypeLhs>::value &&
|
||||
traits::is_unit_t<UnitTypeRhs>::value>>
|
||||
UnitTypeLhs copysign(const UnitTypeLhs x, const UnitTypeRhs y) noexcept {
|
||||
return UnitTypeLhs(std::copysign(
|
||||
x(), y())); // no need for conversion to get the correct sign.
|
||||
}
|
||||
|
||||
/// Overload to copy the sign from a raw double
|
||||
template <class UnitTypeLhs,
|
||||
class = std::enable_if_t<traits::is_unit_t<UnitTypeLhs>::value>>
|
||||
UnitTypeLhs copysign(const UnitTypeLhs x,
|
||||
const UNIT_LIB_DEFAULT_TYPE y) noexcept {
|
||||
return UnitTypeLhs(std::copysign(x(), y));
|
||||
}
|
||||
|
||||
//----------------------------------
|
||||
// MIN / MAX / DIFFERENCE
|
||||
//----------------------------------
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Positive difference
|
||||
* @details The function returns x-y if x>y, and zero otherwise, in the same
|
||||
* units as x. Values x and y do not have to be the same type of units,
|
||||
* but they do have to be compatible.
|
||||
* @param[in] x Values whose difference is calculated.
|
||||
* @param[in] y Values whose difference is calculated.
|
||||
* @returns The positive difference between x and y.
|
||||
*/
|
||||
template <class UnitTypeLhs, class UnitTypeRhs,
|
||||
class = std::enable_if_t<traits::is_unit_t<UnitTypeLhs>::value &&
|
||||
traits::is_unit_t<UnitTypeRhs>::value>>
|
||||
UnitTypeLhs fdim(const UnitTypeLhs x, const UnitTypeRhs y) noexcept {
|
||||
static_assert(traits::is_convertible_unit_t<UnitTypeLhs, UnitTypeRhs>::value,
|
||||
"Parameters of fdim() function are not compatible units.");
|
||||
return UnitTypeLhs(std::fdim(
|
||||
x(),
|
||||
y.template convert<
|
||||
typename units::traits::unit_t_traits<UnitTypeLhs>::unit_type>()()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Maximum value
|
||||
* @details Returns the larger of its arguments: either x or y, in the same
|
||||
* units as x. Values x and y do not have to be the same type of units,
|
||||
* but they do have to be compatible.
|
||||
* @param[in] x Values among which the function selects a maximum.
|
||||
* @param[in] y Values among which the function selects a maximum.
|
||||
* @returns The maximum numeric value of its arguments.
|
||||
*/
|
||||
template <class UnitTypeLhs, class UnitTypeRhs,
|
||||
class = std::enable_if_t<traits::is_unit_t<UnitTypeLhs>::value &&
|
||||
traits::is_unit_t<UnitTypeRhs>::value>>
|
||||
UnitTypeLhs fmax(const UnitTypeLhs x, const UnitTypeRhs y) noexcept {
|
||||
static_assert(traits::is_convertible_unit_t<UnitTypeLhs, UnitTypeRhs>::value,
|
||||
"Parameters of fmax() function are not compatible units.");
|
||||
return UnitTypeLhs(std::fmax(
|
||||
x(),
|
||||
y.template convert<
|
||||
typename units::traits::unit_t_traits<UnitTypeLhs>::unit_type>()()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Minimum value
|
||||
* @details Returns the smaller of its arguments: either x or y, in the same
|
||||
* units as x. If one of the arguments in a NaN, the other is returned.
|
||||
* Values x and y do not have to be the same type of units, but they do
|
||||
* have to be compatible.
|
||||
* @param[in] x Values among which the function selects a minimum.
|
||||
* @param[in] y Values among which the function selects a minimum.
|
||||
* @returns The minimum numeric value of its arguments.
|
||||
*/
|
||||
template <class UnitTypeLhs, class UnitTypeRhs,
|
||||
class = std::enable_if_t<traits::is_unit_t<UnitTypeLhs>::value &&
|
||||
traits::is_unit_t<UnitTypeRhs>::value>>
|
||||
UnitTypeLhs fmin(const UnitTypeLhs x, const UnitTypeRhs y) noexcept {
|
||||
static_assert(traits::is_convertible_unit_t<UnitTypeLhs, UnitTypeRhs>::value,
|
||||
"Parameters of fmin() function are not compatible units.");
|
||||
return UnitTypeLhs(std::fmin(
|
||||
x(),
|
||||
y.template convert<
|
||||
typename units::traits::unit_t_traits<UnitTypeLhs>::unit_type>()()));
|
||||
}
|
||||
|
||||
//----------------------------------
|
||||
// OTHER FUNCTIONS
|
||||
//----------------------------------
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Compute absolute value
|
||||
* @details Returns the absolute value of x, i.e. |x|.
|
||||
* @param[in] x Value whose absolute value is returned.
|
||||
* @returns The absolute value of x.
|
||||
*/
|
||||
template <class UnitType,
|
||||
class = std::enable_if_t<traits::is_unit_t<UnitType>::value>>
|
||||
UnitType fabs(const UnitType x) noexcept {
|
||||
return UnitType(std::fabs(x()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Compute absolute value
|
||||
* @details Returns the absolute value of x, i.e. |x|.
|
||||
* @param[in] x Value whose absolute value is returned.
|
||||
* @returns The absolute value of x.
|
||||
*/
|
||||
template <class UnitType,
|
||||
class = std::enable_if_t<traits::is_unit_t<UnitType>::value>>
|
||||
UnitType abs(const UnitType x) noexcept {
|
||||
return UnitType(std::fabs(x()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Multiply-add
|
||||
* @details Returns x*y+z. The function computes the result without losing
|
||||
* precision in any intermediate result. The resulting unit type is a
|
||||
* compound unit of x* y.
|
||||
* @param[in] x Values to be multiplied.
|
||||
* @param[in] y Values to be multiplied.
|
||||
* @param[in] z Value to be added.
|
||||
* @returns The result of x*y+z
|
||||
*/
|
||||
template <class UnitTypeLhs, class UnitMultiply, class UnitAdd,
|
||||
class = std::enable_if_t<traits::is_unit_t<UnitTypeLhs>::value &&
|
||||
traits::is_unit_t<UnitMultiply>::value &&
|
||||
traits::is_unit_t<UnitAdd>::value>>
|
||||
auto fma(const UnitTypeLhs x, const UnitMultiply y, const UnitAdd z) noexcept
|
||||
-> decltype(x * y) {
|
||||
using resultType = decltype(x * y);
|
||||
static_assert(
|
||||
traits::is_convertible_unit_t<
|
||||
compound_unit<
|
||||
typename units::traits::unit_t_traits<UnitTypeLhs>::unit_type,
|
||||
typename units::traits::unit_t_traits<UnitMultiply>::unit_type>,
|
||||
typename units::traits::unit_t_traits<UnitAdd>::unit_type>::value,
|
||||
"Unit types are not compatible.");
|
||||
return resultType(std::fma(x(), y(), resultType(z)()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Constrains theta to within the range (-pi, pi].
|
||||
*
|
||||
* @param theta Angle to normalize.
|
||||
*/
|
||||
constexpr units::radian_t NormalizeAngle(units::radian_t theta) {
|
||||
units::radian_t pi(wpi::math::pi);
|
||||
|
||||
// Constrain theta to within (-3pi, pi)
|
||||
const int n_pi_pos = (theta + pi) / 2.0 / pi;
|
||||
theta = theta - units::radian_t{n_pi_pos * 2.0 * wpi::math::pi};
|
||||
|
||||
// Cut off the bottom half of the above range to constrain within
|
||||
// (-pi, pi]
|
||||
const int n_pi_neg = (theta - pi) / 2.0 / pi;
|
||||
theta = theta - units::radian_t{n_pi_neg * 2.0 * wpi::math::pi};
|
||||
|
||||
return theta;
|
||||
}
|
||||
} // namespace math
|
||||
} // namespace units
|
||||
@@ -1,19 +0,0 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "units/area.h"
|
||||
#include "units/base.h"
|
||||
#include "units/mass.h"
|
||||
|
||||
namespace units {
|
||||
UNIT_ADD(moment_of_inertia, kilogram_square_meter, kilogram_square_meters,
|
||||
kg_sq_m, compound_unit<mass::kilograms, area::square_meters>)
|
||||
|
||||
using namespace moment_of_inertia;
|
||||
} // namespace units
|
||||
@@ -1,54 +0,0 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// 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/base.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::power
|
||||
* @brief namespace for unit types and containers representing power values
|
||||
* @details The SI unit for power is `watts`, and the corresponding `base_unit`
|
||||
* category is `power_unit`.
|
||||
* @anchor powerContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_POWER_UNITS)
|
||||
UNIT_ADD_WITH_METRIC_PREFIXES(power, watt, watts, W,
|
||||
unit<std::ratio<1>, units::category::power_unit>)
|
||||
UNIT_ADD(power, horsepower, horsepower, hp, unit<std::ratio<7457, 10>, watts>)
|
||||
UNIT_ADD_DECIBEL(power, watt, dBW)
|
||||
UNIT_ADD_DECIBEL(power, milliwatt, dBm)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(power)
|
||||
#endif
|
||||
|
||||
using namespace power;
|
||||
} // namespace units
|
||||
@@ -1,62 +0,0 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// 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/base.h"
|
||||
#include "units/force.h"
|
||||
#include "units/length.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::pressure
|
||||
* @brief namespace for unit types and containers representing pressure values
|
||||
* @details The SI unit for pressure is `pascals`, and the corresponding
|
||||
* `base_unit` category is `pressure_unit`.
|
||||
* @anchor pressureContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || \
|
||||
defined(ENABLE_PREDEFINED_PRESSURE_UNITS)
|
||||
UNIT_ADD_WITH_METRIC_PREFIXES(
|
||||
pressure, pascal, pascals, Pa,
|
||||
unit<std::ratio<1>, units::category::pressure_unit>)
|
||||
UNIT_ADD(pressure, bar, bars, bar, unit<std::ratio<100>, kilo<pascals>>)
|
||||
UNIT_ADD(pressure, mbar, mbars, mbar, unit<std::ratio<1>, milli<bar>>)
|
||||
UNIT_ADD(pressure, atmosphere, atmospheres, atm,
|
||||
unit<std::ratio<101325>, pascals>)
|
||||
UNIT_ADD(pressure, pounds_per_square_inch, pounds_per_square_inch, psi,
|
||||
compound_unit<force::pounds, inverse<squared<length::inch>>>)
|
||||
UNIT_ADD(pressure, torr, torrs, torr, unit<std::ratio<1, 760>, atmospheres>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(pressure)
|
||||
#endif
|
||||
|
||||
using namespace pressure;
|
||||
} // namespace units
|
||||
@@ -1,71 +0,0 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "units/base.h"
|
||||
#include "units/energy.h"
|
||||
#include "units/frequency.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::radiation
|
||||
* @brief namespace for unit types and containers representing radiation values
|
||||
* @details The SI units for radiation are:
|
||||
* - source activity: becquerel
|
||||
* - absorbed dose: gray
|
||||
* - equivalent dose: sievert
|
||||
* @anchor radiationContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || \
|
||||
defined(ENABLE_PREDEFINED_RADIATION_UNITS)
|
||||
UNIT_ADD_WITH_METRIC_PREFIXES(radiation, becquerel, becquerels, Bq,
|
||||
unit<std::ratio<1>, units::frequency::hertz>)
|
||||
UNIT_ADD_WITH_METRIC_PREFIXES(
|
||||
radiation, gray, grays, Gy,
|
||||
compound_unit<energy::joules, inverse<mass::kilogram>>)
|
||||
UNIT_ADD_WITH_METRIC_PREFIXES(radiation, sievert, sieverts, Sv,
|
||||
unit<std::ratio<1>, grays>)
|
||||
UNIT_ADD(radiation, curie, curies, Ci, unit<std::ratio<37>, gigabecquerels>)
|
||||
UNIT_ADD(radiation, rutherford, rutherfords, rd,
|
||||
unit<std::ratio<1>, megabecquerels>)
|
||||
UNIT_ADD(radiation, rad, rads, rads, unit<std::ratio<1>, centigrays>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(radioactivity)
|
||||
#endif
|
||||
|
||||
using namespace radiation;
|
||||
} // namespace units
|
||||
@@ -1,59 +0,0 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// 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/angle.h"
|
||||
#include "units/base.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::solid_angle
|
||||
* @brief namespace for unit types and containers representing solid_angle
|
||||
* values
|
||||
* @details The SI unit for solid_angle is `steradians`, and the corresponding
|
||||
* `base_unit` category is `solid_angle_unit`.
|
||||
* @anchor solidAngleContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || \
|
||||
defined(ENABLE_PREDEFINED_SOLID_ANGLE_UNITS)
|
||||
UNIT_ADD_WITH_METRIC_PREFIXES(
|
||||
solid_angle, steradian, steradians, sr,
|
||||
unit<std::ratio<1>, units::category::solid_angle_unit>)
|
||||
UNIT_ADD(solid_angle, degree_squared, degrees_squared, sq_deg,
|
||||
squared<angle::degrees>)
|
||||
UNIT_ADD(solid_angle, spat, spats, sp,
|
||||
unit<std::ratio<4>, steradians, std::ratio<1>>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(solid_angle)
|
||||
#endif
|
||||
|
||||
using namespace solid_angle;
|
||||
} // namespace units
|
||||
@@ -1,52 +0,0 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// 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/base.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::substance
|
||||
* @brief namespace for unit types and containers representing substance values
|
||||
* @details The SI unit for substance is `moles`, and the corresponding
|
||||
* `base_unit` category is `substance_unit`.
|
||||
* @anchor substanceContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || \
|
||||
defined(ENABLE_PREDEFINED_SUBSTANCE_UNITS)
|
||||
UNIT_ADD(substance, mole, moles, mol,
|
||||
unit<std::ratio<1>, units::category::substance_unit>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(substance)
|
||||
#endif
|
||||
|
||||
using namespace substance;
|
||||
} // namespace units
|
||||
@@ -1,62 +0,0 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// 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/base.h"
|
||||
|
||||
namespace units {
|
||||
// NOTE: temperature units have special conversion overloads, since they
|
||||
// require translations and aren't a reversible transform.
|
||||
|
||||
/**
|
||||
* @namespace units::temperature
|
||||
* @brief namespace for unit types and containers representing temperature
|
||||
* values
|
||||
* @details The SI unit for temperature is `kelvin`, and the corresponding
|
||||
* `base_unit` category is `temperature_unit`.
|
||||
* @anchor temperatureContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || \
|
||||
defined(ENABLE_PREDEFINED_TEMPERATURE_UNITS)
|
||||
UNIT_ADD(temperature, kelvin, kelvin, K,
|
||||
unit<std::ratio<1>, units::category::temperature_unit>)
|
||||
UNIT_ADD(temperature, celsius, celsius, degC,
|
||||
unit<std::ratio<1>, kelvin, std::ratio<0>, std::ratio<27315, 100>>)
|
||||
UNIT_ADD(temperature, fahrenheit, fahrenheit, degF,
|
||||
unit<std::ratio<5, 9>, celsius, std::ratio<0>, std::ratio<-160, 9>>)
|
||||
UNIT_ADD(temperature, reaumur, reaumur, Re, unit<std::ratio<10, 8>, celsius>)
|
||||
UNIT_ADD(temperature, rankine, rankine, Ra, unit<std::ratio<5, 9>, kelvin>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(temperature)
|
||||
#endif
|
||||
|
||||
using namespace temperature;
|
||||
} // namespace units
|
||||
@@ -1,60 +0,0 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// 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/base.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::time
|
||||
* @brief namespace for unit types and containers representing time values
|
||||
* @details The SI unit for time is `seconds`, and the corresponding `base_unit`
|
||||
* category is `time_unit`.
|
||||
* @anchor timeContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_TIME_UNITS)
|
||||
UNIT_ADD_WITH_METRIC_PREFIXES(time, second, seconds, s,
|
||||
unit<std::ratio<1>, units::category::time_unit>)
|
||||
UNIT_ADD(time, minute, minutes, min, unit<std::ratio<60>, seconds>)
|
||||
UNIT_ADD(time, hour, hours, hr, unit<std::ratio<60>, minutes>)
|
||||
UNIT_ADD(time, day, days, d, unit<std::ratio<24>, hours>)
|
||||
UNIT_ADD(time, week, weeks, wk, unit<std::ratio<7>, days>)
|
||||
UNIT_ADD(time, year, years, yr, unit<std::ratio<365>, days>)
|
||||
UNIT_ADD(time, julian_year, julian_years, a_j,
|
||||
unit<std::ratio<31557600>, seconds>)
|
||||
UNIT_ADD(time, gregorian_year, gregorian_years, a_g,
|
||||
unit<std::ratio<31556952>, seconds>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(time)
|
||||
#endif
|
||||
|
||||
using namespace time;
|
||||
} // namespace units
|
||||
@@ -1,63 +0,0 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// 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/base.h"
|
||||
#include "units/energy.h"
|
||||
#include "units/force.h"
|
||||
#include "units/length.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::torque
|
||||
* @brief namespace for unit types and containers representing torque values
|
||||
* @details The SI unit for torque is `newton_meters`, and the corresponding
|
||||
* `base_unit` category is `torque_units`.
|
||||
* @anchor torqueContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || \
|
||||
defined(ENABLE_PREDEFINED_TORQUE_UNITS)
|
||||
UNIT_ADD(torque, newton_meter, newton_meters, Nm,
|
||||
unit<std::ratio<1>, units::energy::joule>)
|
||||
UNIT_ADD(torque, foot_pound, foot_pounds, ftlb,
|
||||
compound_unit<length::foot, force::pounds>)
|
||||
UNIT_ADD(torque, foot_poundal, foot_poundals, ftpdl,
|
||||
compound_unit<length::foot, force::poundal>)
|
||||
UNIT_ADD(torque, inch_pound, inch_pounds, inlb,
|
||||
compound_unit<length::inch, force::pounds>)
|
||||
UNIT_ADD(torque, meter_kilogram, meter_kilograms, mkgf,
|
||||
compound_unit<length::meter, force::kiloponds>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(torque)
|
||||
#endif
|
||||
|
||||
using namespace torque;
|
||||
} // namespace units
|
||||
@@ -1,59 +0,0 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
// clang-format off
|
||||
#ifdef _MSC_VER
|
||||
#pragma message("warning: Including this header drastically increases compilation times and is bad style. Include only what you use instead.")
|
||||
#else
|
||||
#warning "Including this header drastically increases compilation times and is bad style. Include only what you use instead."
|
||||
#endif
|
||||
|
||||
// clang-format on
|
||||
|
||||
#include "units/acceleration.h"
|
||||
#include "units/angle.h"
|
||||
#include "units/angular_acceleration.h"
|
||||
#include "units/angular_velocity.h"
|
||||
#include "units/area.h"
|
||||
#include "units/capacitance.h"
|
||||
#include "units/charge.h"
|
||||
#include "units/concentration.h"
|
||||
#include "units/conductance.h"
|
||||
#include "units/constants.h"
|
||||
#include "units/current.h"
|
||||
#include "units/curvature.h"
|
||||
#include "units/data.h"
|
||||
#include "units/data_transfer_rate.h"
|
||||
#include "units/density.h"
|
||||
#include "units/dimensionless.h"
|
||||
#include "units/energy.h"
|
||||
#include "units/force.h"
|
||||
#include "units/frequency.h"
|
||||
#include "units/illuminance.h"
|
||||
#include "units/impedance.h"
|
||||
#include "units/inductance.h"
|
||||
#include "units/length.h"
|
||||
#include "units/luminous_flux.h"
|
||||
#include "units/luminous_intensity.h"
|
||||
#include "units/magnetic_field_strength.h"
|
||||
#include "units/magnetic_flux.h"
|
||||
#include "units/mass.h"
|
||||
#include "units/math.h"
|
||||
#include "units/moment_of_inertia.h"
|
||||
#include "units/power.h"
|
||||
#include "units/pressure.h"
|
||||
#include "units/radiation.h"
|
||||
#include "units/solid_angle.h"
|
||||
#include "units/substance.h"
|
||||
#include "units/temperature.h"
|
||||
#include "units/time.h"
|
||||
#include "units/torque.h"
|
||||
#include "units/velocity.h"
|
||||
#include "units/voltage.h"
|
||||
#include "units/volume.h"
|
||||
@@ -1,62 +0,0 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// 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/base.h"
|
||||
#include "units/length.h"
|
||||
#include "units/time.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::velocity
|
||||
* @brief namespace for unit types and containers representing velocity values
|
||||
* @details The SI unit for velocity is `meters_per_second`, and the
|
||||
* corresponding `base_unit` category is `velocity_unit`.
|
||||
* @anchor velocityContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || \
|
||||
defined(ENABLE_PREDEFINED_VELOCITY_UNITS)
|
||||
UNIT_ADD(velocity, meters_per_second, meters_per_second, mps,
|
||||
unit<std::ratio<1>, units::category::velocity_unit>)
|
||||
UNIT_ADD(velocity, feet_per_second, feet_per_second, fps,
|
||||
compound_unit<length::feet, inverse<time::seconds>>)
|
||||
UNIT_ADD(velocity, miles_per_hour, miles_per_hour, mph,
|
||||
compound_unit<length::miles, inverse<time::hour>>)
|
||||
UNIT_ADD(velocity, kilometers_per_hour, kilometers_per_hour, kph,
|
||||
compound_unit<length::kilometers, inverse<time::hour>>)
|
||||
UNIT_ADD(velocity, knot, knots, kts,
|
||||
compound_unit<length::nauticalMiles, inverse<time::hour>>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(velocity)
|
||||
#endif
|
||||
|
||||
using namespace velocity;
|
||||
} // namespace units
|
||||
@@ -1,55 +0,0 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// 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/base.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::voltage
|
||||
* @brief namespace for unit types and containers representing voltage values
|
||||
* @details The SI unit for voltage is `volts`, and the corresponding
|
||||
* `base_unit` category is `voltage_unit`.
|
||||
* @anchor voltageContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || \
|
||||
defined(ENABLE_PREDEFINED_VOLTAGE_UNITS)
|
||||
UNIT_ADD_WITH_METRIC_PREFIXES(
|
||||
voltage, volt, volts, V, unit<std::ratio<1>, units::category::voltage_unit>)
|
||||
UNIT_ADD(voltage, statvolt, statvolts, statV,
|
||||
unit<std::ratio<1000000, 299792458>, volts>)
|
||||
UNIT_ADD(voltage, abvolt, abvolts, abV, unit<std::ratio<1, 100000000>, volts>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(voltage)
|
||||
#endif
|
||||
|
||||
using namespace voltage;
|
||||
} // namespace units
|
||||
@@ -1,86 +0,0 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// 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/base.h"
|
||||
#include "units/length.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::volume
|
||||
* @brief namespace for unit types and containers representing volume values
|
||||
* @details The SI unit for volume is `cubic_meters`, and the corresponding
|
||||
* `base_unit` category is `volume_unit`.
|
||||
* @anchor volumeContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || \
|
||||
defined(ENABLE_PREDEFINED_VOLUME_UNITS)
|
||||
UNIT_ADD(volume, cubic_meter, cubic_meters, cu_m,
|
||||
unit<std::ratio<1>, units::category::volume_unit>)
|
||||
UNIT_ADD(volume, cubic_millimeter, cubic_millimeters, cu_mm,
|
||||
cubed<length::millimeter>)
|
||||
UNIT_ADD(volume, cubic_kilometer, cubic_kilometers, cu_km,
|
||||
cubed<length::kilometer>)
|
||||
UNIT_ADD_WITH_METRIC_PREFIXES(volume, liter, liters, L,
|
||||
cubed<deci<length::meter>>)
|
||||
UNIT_ADD(volume, cubic_inch, cubic_inches, cu_in, cubed<length::inches>)
|
||||
UNIT_ADD(volume, cubic_foot, cubic_feet, cu_ft, cubed<length::feet>)
|
||||
UNIT_ADD(volume, cubic_yard, cubic_yards, cu_yd, cubed<length::yards>)
|
||||
UNIT_ADD(volume, cubic_mile, cubic_miles, cu_mi, cubed<length::miles>)
|
||||
UNIT_ADD(volume, gallon, gallons, gal, unit<std::ratio<231>, cubic_inches>)
|
||||
UNIT_ADD(volume, quart, quarts, qt, unit<std::ratio<1, 4>, gallons>)
|
||||
UNIT_ADD(volume, pint, pints, pt, unit<std::ratio<1, 2>, quarts>)
|
||||
UNIT_ADD(volume, cup, cups, c, unit<std::ratio<1, 2>, pints>)
|
||||
UNIT_ADD(volume, fluid_ounce, fluid_ounces, fl_oz, unit<std::ratio<1, 8>, cups>)
|
||||
UNIT_ADD(volume, barrel, barrels, bl, unit<std::ratio<42>, gallons>)
|
||||
UNIT_ADD(volume, bushel, bushels, bu,
|
||||
unit<std::ratio<215042, 100>, cubic_inches>)
|
||||
UNIT_ADD(volume, cord, cords, cord, unit<std::ratio<128>, cubic_feet>)
|
||||
UNIT_ADD(volume, cubic_fathom, cubic_fathoms, cu_fm, cubed<length::fathom>)
|
||||
UNIT_ADD(volume, tablespoon, tablespoons, tbsp,
|
||||
unit<std::ratio<1, 2>, fluid_ounces>)
|
||||
UNIT_ADD(volume, teaspoon, teaspoons, tsp, unit<std::ratio<1, 6>, fluid_ounces>)
|
||||
UNIT_ADD(volume, pinch, pinches, pinch, unit<std::ratio<1, 8>, teaspoons>)
|
||||
UNIT_ADD(volume, dash, dashes, dash, unit<std::ratio<1, 2>, pinches>)
|
||||
UNIT_ADD(volume, drop, drops, drop, unit<std::ratio<1, 360>, fluid_ounces>)
|
||||
UNIT_ADD(volume, fifth, fifths, fifth, unit<std::ratio<1, 5>, gallons>)
|
||||
UNIT_ADD(volume, dram, drams, dr, unit<std::ratio<1, 8>, fluid_ounces>)
|
||||
UNIT_ADD(volume, gill, gills, gi, unit<std::ratio<4>, fluid_ounces>)
|
||||
UNIT_ADD(volume, peck, pecks, pk, unit<std::ratio<1, 4>, bushels>)
|
||||
UNIT_ADD(volume, sack, sacks, sacks, unit<std::ratio<3>, bushels>)
|
||||
UNIT_ADD(volume, shot, shots, shots, unit<std::ratio<3, 2>, fluid_ounces>)
|
||||
UNIT_ADD(volume, strike, strikes, strikes, unit<std::ratio<2>, bushels>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(volume)
|
||||
#endif
|
||||
|
||||
using namespace volume;
|
||||
} // namespace units
|
||||
Reference in New Issue
Block a user