Brick
Loading...
Searching...
No Matches
units Namespace Reference

Classes

class  Quantity
class  Temperature

Concepts

concept  IsQuantity
 Used to require a Quantity be passed in a template (instead of typename Q).
concept  Isomorphic
 Isomorphic concept checks whether dimensions are the same between quantities.
concept  IsomorphicValues
concept  KinematicQuantity
 Only allows nonzero length, time, angle for the next two functions.

Typedefs

using Number = Quantity<>
 Number is just dimensionless.
template<IsQuantity Q1, IsQuantity Q2>
using Multiplied
 Multiplying quantities adds their dimensions.
template<IsQuantity Q1, IsQuantity Q2>
using Divided
 Dividing quantities subtracts their dimensions.
template<IsQuantity Q, typename factor>
using Exponentiated
 Exponentiating a quantity multiplies its dimensions by the power.
template<IsQuantity Q, typename quotient>
using Rooted
 Rooting a quantity divides its dimensions by the root.
using LinearVelocityProportionalGain = LinearDerivativeGain
using TemperatureQuantity
template<typename T>
using quantity_type = decltype(to_quantity(std::declval<T>()))

Enumerations

enum class  TemperatureUnit { Kelvin , Celsius , Fahrenheit }

Functions

template<typename Mass = std::ratio<0>, typename Length = std::ratio<0>, typename Time = std::ratio<0>, typename Current = std::ratio<0>, typename Angle = std::ratio<0>, typename Temperature = std::ratio<0>, typename Luminosity = std::ratio<0>, typename Moles = std::ratio<0>>
void quantity_checker (Quantity< Mass, Length, Time, Current, Angle, Temperature, Luminosity, Moles >)
 quantity checker. Used by the is_quantity concept
template<IsQuantity Q>
constexpr Q from (double value, Q unit)
template<IsQuantity Q>
constexpr Q operator+ (Q rhs)
template<IsQuantity Q, IsQuantity R>
requires Isomorphic<Q, R>
constexpr Q operator+ (Q lhs, R rhs)
 Add two isomorphic quantities.
template<IsQuantity Q>
constexpr Q operator- (Q rhs)
 Negate a quantity.
template<IsQuantity Q, IsQuantity R>
requires Isomorphic<Q, R>
constexpr Q operator- (Q lhs, R rhs)
 Subtract two isomorphic quantities.
template<IsQuantity Q>
requires (!std::is_same_v<Q, Number>)
constexpr Q operator* (Q quantity, Number multiple)
 Multiply a Quantity by a Number.
template<IsQuantity Q>
requires (!std::is_same_v<Q, Number>)
constexpr Q operator* (Number multiple, Q quantity)
 Multiply a Quantity by a Number.
template<IsQuantity Q>
requires (!std::is_same_v<Q, Number>)
constexpr Q operator/ (Q quantity, Number divisor)
 Divide a Quantity by a Number.
template<IsQuantity Q>
requires (!std::is_same_v<Q, Number>)
constexpr auto operator/ (Number enumerator, Q divisor)
 Divide a Number by a Quantity.
template<IsQuantity Q1, IsQuantity Q2>
constexpr auto operator* (Q1 lhs, Q2 rhs)
 Multiply two Quantities.
template<IsQuantity Q1, IsQuantity Q2>
constexpr auto operator/ (Q1 lhs, Q2 rhs)
 Divide two Quantities.
template<IsQuantity Q, IsQuantity R>
requires Isomorphic<Q, R>
constexpr bool operator== (const Q &lhs, const R &rhs)
 Check whether two Quantities are equal.
template<IsQuantity Q, IsQuantity R>
requires Isomorphic<Q, R>
constexpr bool operator!= (const Q &lhs, const R &rhs)
 Check whether two Quantities are not equal.
template<IsQuantity Q, IsQuantity R>
requires Isomorphic<Q, R>
constexpr bool operator<= (const Q &lhs, const R &rhs)
 Check whether a Quantity is less than or equal to another.
template<IsQuantity Q, IsQuantity R>
requires Isomorphic<Q, R>
constexpr bool operator>= (const Q &lhs, const R &rhs)
 Check whether a Quantity is greater than or equal to another.
template<IsQuantity Q, IsQuantity R>
requires Isomorphic<Q, R>
constexpr bool operator< (const Q &lhs, const R &rhs)
 Check whether a Quantity is less than another.
template<IsQuantity Q, IsQuantity R>
requires Isomorphic<Q, R>
constexpr bool operator> (const Q &lhs, const R &rhs)
 Check whether a Quantity is greater than another.
 NEW_UNIT (LinearAccelerationFeedforward, volts_per_meter_per_second_squared, VpMps2, 1, 1, -1, -1, 0, 0, 0, 0) NEW_UNIT_LITERAL(LinearAccelerationFeedforward
 Tile is the measured length of a vex field tile in real life.
 NEW_UNIT (LinearVelocityDerivativeGain, volt_seconds_squared_per_meter, Vs2pM, 1, 1, -1, -1, 0, 0, 0, 0) using LinearVelocityIntegralGain
 NEW_UNIT (AngularVelocityFeedforward, volts_per_radian_per_second, VpRadPs, 1, 2, -2, -1, -1, 0, 0, 0) NEW_UNIT(AngularAccelerationFeedforward
 NEW_UNIT_LITERAL (AngularAccelerationFeedforward, volts_per_degree_per_second_squared, VpDegPs2, V/dps2) using AngularVelocityProportionalGain
 NEW_UNIT (AngularVelocityDerivativeGain, volt_seconds_squared_per_radian, Vs2pRad, 1, 2, -1, -1, -1, 0, 0, 0) using AngularVelocityIntegralGain
constexpr Temperature from (double value, TemperatureUnit unit)
constexpr Temperature operator+ (Temperature)=delete
constexpr Temperature operator- (Temperature)=delete
constexpr Temperature operator+ (Temperature, Temperature)=delete
constexpr Temperature operator- (Temperature, Temperature)=delete
template<typename T>
constexpr auto to_quantity (T value) -> std::conditional_t< std::is_arithmetic_v< T >, Number, T >
template<typename T>
constexpr auto abs (const T &lhs)
template<typename T, typename U>
requires IsomorphicValues<T, U>
constexpr auto max (const T &lhs, const U &rhs)
template<typename T, typename U>
requires IsomorphicValues<T, U>
constexpr auto min (const T &lhs, const U &rhs)
template<typename T>
constexpr auto sgn (const T &lhs)
template<int R, typename T>
requires IsQuantity<quantity_type<T>>
constexpr auto pow (const T &lhs)
template<typename T>
constexpr auto square (const T &lhs)
template<typename T>
constexpr auto cube (const T &lhs)
template<int R, typename T>
requires (R > 0)
constexpr auto root (const T &lhs)
template<typename T>
constexpr auto sqrt (const T &lhs)
template<typename T>
constexpr auto cbrt (const T &lhs)
template<typename T, typename U>
requires IsomorphicValues<T, U>
constexpr auto hypot (const T &lhs, const U &rhs)
template<typename T, typename U>
requires IsomorphicValues<T, U>
constexpr auto mod (const T &lhs, const U &rhs)
template<typename T, typename U>
constexpr auto copysign (const T &lhs, const U &rhs)
template<typename T>
constexpr auto signbit (const T &lhs)
template<typename T, typename U, typename V>
requires IsomorphicValues<T, U, V>
constexpr auto clamp (const T &lhs, const U &lo, const V &hi)
template<typename T, typename U>
requires IsomorphicValues<T, U>
constexpr auto ceil (const T &lhs, const U &rhs)
template<typename T, typename U>
requires IsomorphicValues<T, U>
constexpr auto floor (const T &lhs, const U &rhs)
template<typename T, typename U>
requires IsomorphicValues<T, U>
constexpr auto trunc (const T &lhs, const U &rhs)
template<typename T, typename U>
requires IsomorphicValues<T, U>
constexpr auto round (const T &lhs, const U &rhs)
template<KinematicQuantity Q>
requires std::ratio_equal_v<typename Q::angle, std::ratio<1>> && std::ratio_equal_v<typename Q::length, std::ratio<0>>
constexpr auto to_linear (Q angular_distance, Length diameter)
template<KinematicQuantity Q>
requires std::ratio_equal_v<typename Q::length, std::ratio<1>> && std::ratio_equal_v<typename Q::angle, std::ratio<0>>
constexpr auto to_angular (Q linear_distance, Length diameter)
constexpr Number sin (Angle angle)
constexpr Number cos (Angle angle)
constexpr Number tan (Angle angle)
constexpr Angle asin (Number value)
constexpr Angle acos (Number value)
constexpr Angle atan (Number value)
template<typename T, typename U>
requires IsomorphicValues<T, U>
constexpr Angle atan2 (const T &y, const U &x)
constexpr Angle wrap_positive (Angle angle)
constexpr Angle wrap_signed (Angle angle)
constexpr Angle shortest_difference (Angle start, Angle end)

Variables

 volts_per_inch_per_second_squared
 VpInps2
 volts_per_radian_per_second_squared
 VpRadPs2
constexpr TemperatureUnit kelvin = TemperatureUnit::Kelvin
constexpr TemperatureUnit K = kelvin
constexpr TemperatureUnit celsius = TemperatureUnit::Celsius
constexpr TemperatureUnit fahrenheit = TemperatureUnit::Fahrenheit

Typedef Documentation

◆ Divided

template<IsQuantity Q1, IsQuantity Q2>
using units::Divided
Initial value:
std::ratio_subtract<typename Q1::mass, typename Q2::mass>,
std::ratio_subtract<typename Q1::length, typename Q2::length>,
std::ratio_subtract<typename Q1::time, typename Q2::time>,
std::ratio_subtract<typename Q1::current, typename Q2::current>,
std::ratio_subtract<typename Q1::angle, typename Q2::angle>,
std::ratio_subtract<typename Q1::temperature, typename Q2::temperature>,
std::ratio_subtract<typename Q1::luminosity, typename Q2::luminosity>,
std::ratio_subtract<typename Q1::moles, typename Q2::moles>>
Definition units.h:26

Dividing quantities subtracts their dimensions.

◆ Exponentiated

template<IsQuantity Q, typename factor>
using units::Exponentiated
Initial value:
std::ratio_multiply<typename Q::mass, factor>, std::ratio_multiply<typename Q::length, factor>,
std::ratio_multiply<typename Q::time, factor>, std::ratio_multiply<typename Q::current, factor>,
std::ratio_multiply<typename Q::angle, factor>,
std::ratio_multiply<typename Q::temperature, factor>,
std::ratio_multiply<typename Q::luminosity, factor>,
std::ratio_multiply<typename Q::moles, factor>>

Exponentiating a quantity multiplies its dimensions by the power.

◆ Multiplied

template<IsQuantity Q1, IsQuantity Q2>
using units::Multiplied
Initial value:
std::ratio_add<typename Q1::mass, typename Q2::mass>,
std::ratio_add<typename Q1::length, typename Q2::length>,
std::ratio_add<typename Q1::time, typename Q2::time>,
std::ratio_add<typename Q1::current, typename Q2::current>,
std::ratio_add<typename Q1::angle, typename Q2::angle>,
std::ratio_add<typename Q1::temperature, typename Q2::temperature>,
std::ratio_add<typename Q1::luminosity, typename Q2::luminosity>,
std::ratio_add<typename Q1::moles, typename Q2::moles>>

Multiplying quantities adds their dimensions.

◆ Rooted

template<IsQuantity Q, typename quotient>
using units::Rooted
Initial value:
std::ratio_divide<typename Q::mass, quotient>, std::ratio_divide<typename Q::length, quotient>,
std::ratio_divide<typename Q::time, quotient>, std::ratio_divide<typename Q::current, quotient>,
std::ratio_divide<typename Q::angle, quotient>,
std::ratio_divide<typename Q::temperature, quotient>,
std::ratio_divide<typename Q::luminosity, quotient>,
std::ratio_divide<typename Q::moles, quotient>>

Rooting a quantity divides its dimensions by the root.

◆ TemperatureQuantity

using units::TemperatureQuantity
Initial value:
std::ratio<0>, std::ratio<0>, std::ratio<0>, std::ratio<0>, std::ratio<0>, std::ratio<1>,
std::ratio<0>, std::ratio<0>>

Function Documentation

◆ from()

template<IsQuantity Q>
Q units::from ( double value,
Q unit )
constexpr

Creates a quantity from a numeric value expressed in a specific unit. e.g. Velocity v = from(5, inps);

◆ to_angular()

template<KinematicQuantity Q>
requires std::ratio_equal_v<typename Q::length, std::ratio<1>> && std::ratio_equal_v<typename Q::angle, std::ratio<0>>
auto units::to_angular ( Q linear_distance,
Length diameter )
constexpr

Helper to go from linear to angular, like from wheel distance travel to wheel rotation

◆ to_linear()

template<KinematicQuantity Q>
requires std::ratio_equal_v<typename Q::angle, std::ratio<1>> && std::ratio_equal_v<typename Q::length, std::ratio<0>>
auto units::to_linear ( Q angular_distance,
Length diameter )
constexpr

Helper to go from angular to linear, like from encoder rotation to wheel distance travel

◆ to_quantity()

template<typename T>
auto units::to_quantity ( T value) -> std::conditional_t< std::is_arithmetic_v< T >, Number, T >
constexpr

Helper that converts arithmetic types to Number so they can be used in the following