Implementation of Math's API's unit system. More...
#include <iostream>
#include <ratio>
#include <Utility/String/NRE_String.hpp>
#include <Utility/Interfaces/Stringable/NRE_Stringable.hpp>
#include "NRE_Math.hpp"
Go to the source code of this file.
Classes | |
class | NRE::Math::Unit< M, L, T, A > |
Used to define clear physical unit. More... | |
Namespaces | |
NRE | |
The NearlyRealEngine's global namespace. | |
Math | |
Math's API. | |
Macros | |
#define | TYPEDEF_UNIT(M, L, T, A, name) typedef Unit<std::ratio<M>, std::ratio<L>, std::ratio<T>, std::ratio<A>> name |
Functions | |
template<class M , class L , class T , class A > | |
std::ostream & | NRE::Math::operator<< (std::ostream &stream, Unit< M, L, T, A > const &o) |
template<class M , class L , class T , class A , class M2 , class L2 , class T2 , class A2 > | |
constexpr Unit< std::ratio_subtract< M, M2 >, std::ratio_subtract< L, L2 >, std::ratio_subtract< T, T2 >, std::ratio_subtract< A, A2 > > | NRE::Math::operator/ (Unit< M, L, T, A > const &u1, Unit< M2, L2, T2, A2 > const &u2) |
template<class M , class L , class T , class A > | |
constexpr Unit< std::ratio_subtract< std::ratio< 0 >, M >, std::ratio_subtract< std::ratio< 0 >, L >, std::ratio_subtract< std::ratio< 0 >, T >, std::ratio_subtract< std::ratio< 0 >, A > > | NRE::Math::operator/ (long double x, Unit< M, L, T, A > const &u) |
template<class M , class L , class T , class A > | |
constexpr Unit< M, L, T, A > | NRE::Math::operator/ (Unit< M, L, T, A > const &u, long double x) |
template<class M , class L , class T , class A , class M2 , class L2 , class T2 , class A2 > | |
constexpr Unit< std::ratio_add< M, M2 >, std::ratio_add< L, L2 >, std::ratio_add< T, T2 >, std::ratio_add< A, A2 > > | NRE::Math::operator* (Unit< M, L, T, A > const &u1, Unit< M2, L2, T2, A2 > const &u2) |
template<class M , class L , class T , class A > | |
constexpr Unit< M, L, T, A > | NRE::Math::operator* (long double x, Unit< M, L, T, A > const &u) |
template<class M , class L , class T , class A > | |
constexpr Unit< M, L, T, A > | NRE::Math::operator* (Unit< M, L, T, A > const &u, long double x) |
NRE::Math::TYPEDEF_UNIT (1, 0, 0, 0, UMass) | |
NRE::Math::TYPEDEF_UNIT (0, 1, 0, 0, ULength) | |
NRE::Math::TYPEDEF_UNIT (0, 2, 0, 0, UArea) | |
NRE::Math::TYPEDEF_UNIT (0, 3, 0, 0, UVolume) | |
NRE::Math::TYPEDEF_UNIT (0, 0, 1, 0, UTime) | |
NRE::Math::TYPEDEF_UNIT (0, 1,-1, 0, USpeed) | |
NRE::Math::TYPEDEF_UNIT (0, 1,-2, 0, UAcceleration) | |
NRE::Math::TYPEDEF_UNIT (0, 0,-1, 0, UFrequency) | |
NRE::Math::TYPEDEF_UNIT (1, 1,-2, 0, UForce) | |
NRE::Math::TYPEDEF_UNIT (1,-1,-2, 0, UPressure) | |
NRE::Math::TYPEDEF_UNIT (0, 0, 0, 1, Angle) | |
constexpr UMass | NRE::Math::kilogramme (1.0) |
constexpr ULength | NRE::Math::metre (1.0) |
constexpr UTime | NRE::Math::second (1.0) |
constexpr UFrequency | NRE::Math::Hz (1.0) |
constexpr UForce | NRE::Math::newton (1.0) |
constexpr UPressure | NRE::Math::pascal (1.0) |
constexpr ULength | NRE::Math::operator""_mm (long double x) |
constexpr ULength | NRE::Math::operator""_cm (long double x) |
constexpr ULength | NRE::Math::operator""_m (long double x) |
constexpr ULength | NRE::Math::operator""_km (long double x) |
constexpr ULength | NRE::Math::operator""_mm (unsigned long long int x) |
constexpr ULength | NRE::Math::operator""_cm (unsigned long long int x) |
constexpr ULength | NRE::Math::operator""_m (unsigned long long int x) |
constexpr ULength | NRE::Math::operator""_km (unsigned long long int x) |
constexpr USpeed | NRE::Math::operator""_kmph (long double x) |
constexpr USpeed | NRE::Math::operator""_kmph (unsigned long long int x) |
constexpr UFrequency | NRE::Math::operator""_Hz (long double x) |
constexpr UFrequency | NRE::Math::operator""_Hz (unsigned long long int x) |
constexpr UTime | NRE::Math::operator""_s (long double x) |
constexpr UTime | NRE::Math::operator""_min (long double x) |
constexpr UTime | NRE::Math::operator""_h (long double x) |
constexpr UTime | NRE::Math::operator""_day (long double x) |
constexpr UTime | NRE::Math::operator""_s (unsigned long long int x) |
constexpr UTime | NRE::Math::operator""_min (unsigned long long int x) |
constexpr UTime | NRE::Math::operator""_h (unsigned long long int x) |
constexpr UTime | NRE::Math::operator""_day (unsigned long long int x) |
constexpr UMass | NRE::Math::operator""_kg (long double x) |
constexpr UMass | NRE::Math::operator""_g (long double x) |
constexpr UMass | NRE::Math::operator""_t (long double x) |
constexpr UMass | NRE::Math::operator""_kg (unsigned long long int x) |
constexpr UMass | NRE::Math::operator""_g (unsigned long long int x) |
constexpr UMass | NRE::Math::operator""_t (unsigned long long int x) |
constexpr UAcceleration | NRE::Math::operator""_mps2 (long double x) |
constexpr UAcceleration | NRE::Math::operator""_mps2 (unsigned long long int x) |
constexpr UAcceleration | NRE::Math::operator""_G (long double x) |
constexpr UAcceleration | NRE::Math::operator""_G (unsigned long long int x) |
constexpr UForce | NRE::Math::operator""_N (long double x) |
constexpr UForce | NRE::Math::operator""_N (unsigned long long int x) |
constexpr UPressure | NRE::Math::operator""_Pa (long double x) |
constexpr UPressure | NRE::Math::operator""_Pa (unsigned long long int x) |
constexpr long double | NRE::Math::operator""_pi (long double x) |
constexpr long double | NRE::Math::operator""_pi (unsigned long long int x) |
constexpr Angle | NRE::Math::radian (1.0) |
constexpr Angle | NRE::Math::operator""_rad (long double x) |
constexpr Angle | NRE::Math::operator""_rad (unsigned long long int x) |
constexpr Angle | NRE::Math::operator""_deg (long double x) |
constexpr Angle | NRE::Math::operator""_deg (unsigned long long int x) |
double | NRE::Math::sin (Angle const &u) |
double | NRE::Math::cos (Angle const &u) |
double | NRE::Math::tan (Angle const &u) |
double | NRE::Math::asin (Angle const &u) |
double | NRE::Math::acos (Angle const &u) |
double | NRE::Math::atan (Angle const &u) |
double | NRE::Math::toRad (Angle const &u) |
double | NRE::Math::toDeg (Angle const &u) |
Variables | |
constexpr UMass | NRE::Math::gramme = 0.001 * kilogramme |
constexpr UMass | NRE::Math::tonne = 1000 * kilogramme |
constexpr ULength | NRE::Math::decimetre = metre / 10 |
constexpr ULength | NRE::Math::centimetre = metre / 100 |
constexpr ULength | NRE::Math::millimetre = metre / 1000 |
constexpr ULength | NRE::Math::kilometre = 1000 * metre |
constexpr UArea | NRE::Math::metre2 = metre * metre |
constexpr UArea | NRE::Math::decimetre2 = decimetre * decimetre |
constexpr UArea | NRE::Math::centimetre2 = centimetre * centimetre |
constexpr UArea | NRE::Math::millimetre2 = millimetre * millimetre |
constexpr UArea | NRE::Math::kilometre2 = kilometre * kilometre |
constexpr UVolume | NRE::Math::metre3 = metre2 * metre |
constexpr UVolume | NRE::Math::decimetre3 = decimetre2 * decimetre |
constexpr UVolume | NRE::Math::centimetre3 = centimetre2 * centimetre |
constexpr UVolume | NRE::Math::millimetre3 = millimetre2 * millimetre |
constexpr UVolume | NRE::Math::kilometre3 = kilometre2 * kilometre |
constexpr UVolume | NRE::Math::litre = decimetre3 |
constexpr UTime | NRE::Math::minute = 60 * second |
constexpr UTime | NRE::Math::hour = 60 * minute |
constexpr UTime | NRE::Math::day = 24 * hour |
constexpr UAcceleration | NRE::Math::G = 9.80665 * metre / (second * second) |
constexpr Angle | NRE::Math::degree = (PI / 180.0f) * radian |
#define TYPEDEF_UNIT | ( | M, | |
L, | |||
T, | |||
A, | |||
name | |||
) | typedef Unit<std::ratio<M>, std::ratio<L>, std::ratio<T>, std::ratio<A>> name |
Mass unit
|
inline |
Compute the arc cos of a unit in typed manners
u | the unit |
|
inline |
Compute the arc sin of a unit in typed manners
u | the unit |
|
inline |
Compute the arc tan of a unit in typed manners
u | the unit |
|
inline |
Compute the cos of a unit in typed manners
u | the unit |
constexpr UFrequency NRE::Math::Hz | ( | 1. | 0 | ) |
Standard SI unit
constexpr UMass NRE::Math::kilogramme | ( | 1. | 0 | ) |
Standard SI unit
constexpr ULength NRE::Math::metre | ( | 1. | 0 | ) |
Standard SI unit
constexpr UForce NRE::Math::newton | ( | 1. | 0 | ) |
Standard SI unit
constexpr ULength NRE::Math::operator""_cm | ( | long double | x | ) |
Litteral operator for centimetre
x | the value to convert |
constexpr ULength NRE::Math::operator""_cm | ( | unsigned long long int | x | ) |
Litteral operator for centimetre
x | the value to convert |
constexpr UTime NRE::Math::operator""_day | ( | long double | x | ) |
Litteral operator for day
x | the value to convert |
constexpr UTime NRE::Math::operator""_day | ( | unsigned long long int | x | ) |
Litteral operator for day
x | the value to convert |
constexpr Angle NRE::Math::operator""_deg | ( | long double | x | ) |
Litteral operator for degree
x | the value to convert |
constexpr Angle NRE::Math::operator""_deg | ( | unsigned long long int | x | ) |
Litteral operator for degree
x | the value to convert |
constexpr UMass NRE::Math::operator""_g | ( | long double | x | ) |
Litteral operator for gramme
x | the value to convert |
constexpr UMass NRE::Math::operator""_g | ( | unsigned long long int | x | ) |
Litteral operator for gramme
x | the value to convert |
constexpr UAcceleration NRE::Math::operator""_G | ( | long double | x | ) |
Litteral operator for gravity
x | the value to convert |
constexpr UAcceleration NRE::Math::operator""_G | ( | unsigned long long int | x | ) |
Litteral operator for gravity
x | the value to convert |
constexpr UTime NRE::Math::operator""_h | ( | long double | x | ) |
Litteral operator for hour
x | the value to convert |
constexpr UTime NRE::Math::operator""_h | ( | unsigned long long int | x | ) |
Litteral operator for hour
x | the value to convert |
constexpr UFrequency NRE::Math::operator""_Hz | ( | long double | x | ) |
Litteral operator for hertz
x | the value to convert |
constexpr UFrequency NRE::Math::operator""_Hz | ( | unsigned long long int | x | ) |
Litteral operator for hertz
x | the value to convert |
constexpr UMass NRE::Math::operator""_kg | ( | long double | x | ) |
Litteral operator for kilogramme
x | the value to convert |
constexpr UMass NRE::Math::operator""_kg | ( | unsigned long long int | x | ) |
Litteral operator for kilogramme
x | the value to convert |
constexpr ULength NRE::Math::operator""_km | ( | long double | x | ) |
Litteral operator for kilometre
x | the value to convert |
constexpr ULength NRE::Math::operator""_km | ( | unsigned long long int | x | ) |
Litteral operator for kilometre
x | the value to convert |
constexpr USpeed NRE::Math::operator""_kmph | ( | long double | x | ) |
Litteral operator for kilometre per hour
x | the value to convert |
constexpr USpeed NRE::Math::operator""_kmph | ( | unsigned long long int | x | ) |
Litteral operator for kilometre per hour
x | the value to convert |
constexpr ULength NRE::Math::operator""_m | ( | long double | x | ) |
Litteral operator for metre
x | the value to convert |
constexpr ULength NRE::Math::operator""_m | ( | unsigned long long int | x | ) |
Litteral operator for metre
x | the value to convert |
constexpr UTime NRE::Math::operator""_min | ( | long double | x | ) |
Litteral operator for minute
x | the value to convert |
constexpr UTime NRE::Math::operator""_min | ( | unsigned long long int | x | ) |
Litteral operator for minute
x | the value to convert |
constexpr ULength NRE::Math::operator""_mm | ( | long double | x | ) |
Litteral operator for millimetre
x | the value to convert |
constexpr ULength NRE::Math::operator""_mm | ( | unsigned long long int | x | ) |
Litteral operator for millimetre
x | the value to convert |
constexpr UAcceleration NRE::Math::operator""_mps2 | ( | long double | x | ) |
Litteral operator for metre per second square
x | the value to convert |
constexpr UAcceleration NRE::Math::operator""_mps2 | ( | unsigned long long int | x | ) |
Litteral operator for metre per second square
x | the value to convert |
constexpr UForce NRE::Math::operator""_N | ( | long double | x | ) |
Litteral operator for newton
x | the value to convert |
constexpr UForce NRE::Math::operator""_N | ( | unsigned long long int | x | ) |
Litteral operator for newton
x | the value to convert |
constexpr UPressure NRE::Math::operator""_Pa | ( | long double | x | ) |
Litteral operator for pascal
x | the value to convert |
constexpr UPressure NRE::Math::operator""_Pa | ( | unsigned long long int | x | ) |
Litteral operator for pascal
x | the value to convert |
constexpr long double NRE::Math::operator""_pi | ( | long double | x | ) |
Litteral operator for pi
x | the value to convert |
constexpr long double NRE::Math::operator""_pi | ( | unsigned long long int | x | ) |
Litteral operator for pi
x | the value to convert |
constexpr Angle NRE::Math::operator""_rad | ( | long double | x | ) |
Litteral operator for radian
x | the value to convert |
constexpr Angle NRE::Math::operator""_rad | ( | unsigned long long int | x | ) |
Litteral operator for radian
x | the value to convert |
constexpr UTime NRE::Math::operator""_s | ( | long double | x | ) |
Litteral operator for second
x | the value to convert |
constexpr UTime NRE::Math::operator""_s | ( | unsigned long long int | x | ) |
Litteral operator for second
x | the value to convert |
constexpr UMass NRE::Math::operator""_t | ( | long double | x | ) |
Litteral operator for tonne
x | the value to convert |
constexpr UMass NRE::Math::operator""_t | ( | unsigned long long int | x | ) |
Litteral operator for tonne
x | the value to convert |
constexpr Unit<std::ratio_add<M, M2>, std::ratio_add<L, L2>, std::ratio_add<T, T2>, std::ratio_add<A, A2> > NRE::Math::operator* | ( | Unit< M, L, T, A > const & | u1, |
Unit< M2, L2, T2, A2 > const & | u2 | ||
) |
Compute the unit resulting in the multiplication of u1 by u2
u1 | the first unit |
u2 | the second unit |
constexpr Unit<M, L, T, A> NRE::Math::operator* | ( | long double | x, |
Unit< M, L, T, A > const & | u | ||
) |
Compute the unit resulting in the multiplication of x by u
x | the value to multiply with u |
u | the unit |
constexpr Unit<M, L, T, A> NRE::Math::operator* | ( | Unit< M, L, T, A > const & | u, |
long double | x | ||
) |
Compute the unit resulting in the multiplication of u by x
u | the unit |
x | the value to multiply with u |
constexpr Unit<std::ratio_subtract<M, M2>, std::ratio_subtract<L, L2>, std::ratio_subtract<T, T2>, std::ratio_subtract<A, A2> > NRE::Math::operator/ | ( | Unit< M, L, T, A > const & | u1, |
Unit< M2, L2, T2, A2 > const & | u2 | ||
) |
Compute the unit resulting in the division of u1 by u2
u1 | the first unit |
u2 | the second unit |
constexpr Unit<std::ratio_subtract<std::ratio<0>, M>, std::ratio_subtract<std::ratio<0>, L>, std::ratio_subtract<std::ratio<0>, T>, std::ratio_subtract<std::ratio<0>, A> > NRE::Math::operator/ | ( | long double | x, |
Unit< M, L, T, A > const & | u | ||
) |
Compute the unit resulting in the division of x by u
x | the value to divide with u |
u | the unit |
constexpr Unit<M, L, T, A> NRE::Math::operator/ | ( | Unit< M, L, T, A > const & | u, |
long double | x | ||
) |
Compute the unit resulting in the division of u by x
u | the unit to be divided |
x | the value |
std::ostream& NRE::Math::operator<< | ( | std::ostream & | stream, |
Unit< M, L, T, A > const & | o | ||
) |
Output stream operator for the object
stream | the stream to add the object's string representation |
o | the object to add in the stream |
constexpr UPressure NRE::Math::pascal | ( | 1. | 0 | ) |
Standard SI unit
constexpr Angle NRE::Math::radian | ( | 1. | 0 | ) |
Standard SI unit
constexpr UTime NRE::Math::second | ( | 1. | 0 | ) |
Standard SI unit
|
inline |
Compute the sin of a unit in typed manners
u | the unit |
|
inline |
Compute the tan of a unit in typed manners
u | the unit |
|
inline |
Return the angle value in degree
u | the unit |
|
inline |
Return the angle value in radian
u | the unit |
NRE::Math::TYPEDEF_UNIT | ( | 1 | , |
0 | , | ||
0 | , | ||
0 | , | ||
UMass | |||
) |
Length unit
NRE::Math::TYPEDEF_UNIT | ( | 0 | , |
1 | , | ||
0 | , | ||
0 | , | ||
ULength | |||
) |
Area unit
NRE::Math::TYPEDEF_UNIT | ( | 0 | , |
2 | , | ||
0 | , | ||
0 | , | ||
UArea | |||
) |
Volume unit
NRE::Math::TYPEDEF_UNIT | ( | 0 | , |
3 | , | ||
0 | , | ||
0 | , | ||
UVolume | |||
) |
Time unit
NRE::Math::TYPEDEF_UNIT | ( | 0 | , |
0 | , | ||
1 | , | ||
0 | , | ||
UTime | |||
) |
Speed unit
NRE::Math::TYPEDEF_UNIT | ( | 0 | , |
1 | , | ||
- | 1, | ||
0 | , | ||
USpeed | |||
) |
Acceleration unit
NRE::Math::TYPEDEF_UNIT | ( | 0 | , |
1 | , | ||
- | 2, | ||
0 | , | ||
UAcceleration | |||
) |
Frequency unit
NRE::Math::TYPEDEF_UNIT | ( | 0 | , |
0 | , | ||
- | 1, | ||
0 | , | ||
UFrequency | |||
) |
Force unit
NRE::Math::TYPEDEF_UNIT | ( | 1 | , |
1 | , | ||
- | 2, | ||
0 | , | ||
UForce | |||
) |
Pressure unit
NRE::Math::TYPEDEF_UNIT | ( | 1 | , |
- | 1, | ||
- | 2, | ||
0 | , | ||
UPressure | |||
) |
Angle unit
constexpr ULength NRE::Math::centimetre = metre / 100 |
A hundredth of metre
constexpr UArea NRE::Math::centimetre2 = centimetre * centimetre |
One by One centimetre square
constexpr UVolume NRE::Math::centimetre3 = centimetre2 * centimetre |
One by One by One centimetre cube
constexpr UTime NRE::Math::day = 24 * hour |
Twenty four hours
constexpr ULength NRE::Math::decimetre = metre / 10 |
A tenth of metre
constexpr UArea NRE::Math::decimetre2 = decimetre * decimetre |
One by One decimetre square
constexpr UVolume NRE::Math::decimetre3 = decimetre2 * decimetre |
One by One by One decimetre cube
constexpr Angle NRE::Math::degree = (PI / 180.0f) * radian |
Scale degree with radian
constexpr UAcceleration NRE::Math::G = 9.80665 * metre / (second * second) |
Standard Gravity value
constexpr UMass NRE::Math::gramme = 0.001 * kilogramme |
A thousandth of kilogramme
constexpr UTime NRE::Math::hour = 60 * minute |
Sixty minutes
constexpr ULength NRE::Math::kilometre = 1000 * metre |
One thousand of metre
constexpr UArea NRE::Math::kilometre2 = kilometre * kilometre |
One by One kilometre square
constexpr UVolume NRE::Math::kilometre3 = kilometre2 * kilometre |
One by One by One kilometre cube
constexpr UVolume NRE::Math::litre = decimetre3 |
One by One by One decimetre cube
constexpr UArea NRE::Math::metre2 = metre * metre |
One by One metre square
constexpr UVolume NRE::Math::metre3 = metre2 * metre |
One by One by One metre cube
constexpr ULength NRE::Math::millimetre = metre / 1000 |
A thousandth of metre
constexpr UArea NRE::Math::millimetre2 = millimetre * millimetre |
One by One millimetre square
constexpr UVolume NRE::Math::millimetre3 = millimetre2 * millimetre |
One by One by One millimetre cube
constexpr UTime NRE::Math::minute = 60 * second |
Sixty seconds
constexpr UMass NRE::Math::tonne = 1000 * kilogramme |
One thousand of kilogramme