PlayRho  2.0.0
An interactive physics engine & library.
Units.hpp File Reference

Declarations for physical units possibly backed by strong types. More...

#include <cmath>
#include <type_traits>
#include <playrho/Real.hpp>
#include <playrho/RealConstants.hpp>
#include <playrho/Templates.hpp>
#include <playrho/to_underlying.hpp>
Include dependency graph for Units.hpp:
This graph shows which files directly or indirectly include this file:

Namespaces

 playrho
 
 playrho::detail
 

Typedefs

using playrho::detail::acceleration = Real
 Acceleration quantity type.
 
using playrho::Angle = detail::plane_angle
 Angle quantity. More...
 
using playrho::detail::angular_acceleration = Real
 Angular acceleration quantity type.
 
using playrho::detail::angular_momentum = Real
 Angular momemntum quantity type.
 
using playrho::detail::angular_velocity = Real
 Angular velocity quantity type.
 
using playrho::AngularAcceleration = detail::angular_acceleration
 Angular acceleration quantity. More...
 
using playrho::AngularMomentum = detail::angular_momentum
 Angular momentum quantity. More...
 
using playrho::AngularVelocity = detail::angular_velocity
 Angular velocity quantity. More...
 
using playrho::detail::area = Real
 Area quantity type.
 
using playrho::Area = detail::area
 Area quantity. More...
 
using playrho::AreaDensity = detail::surface_density
 Area (surface) density quantity. More...
 
using playrho::detail::force = Real
 Force quantity type.
 
using playrho::Force = detail::force
 Force quantity. More...
 
using playrho::detail::frequency = Real
 Frequency quantity type.
 
using playrho::Frequency = detail::frequency
 Frequency quantity. More...
 
template<class T >
using playrho::detail::get_member_type = decltype(std::declval< T & >().get())
 Alias for getting the return type of a get() member function.
 
using playrho::detail::inverse_mass = Real
 Inverse mass quantity type.
 
using playrho::detail::inverse_moment_of_inertia = Real
 Inverse moment of inertia quantity type.
 
using playrho::InvMass = detail::inverse_mass
 Inverse mass quantity. More...
 
using playrho::InvRotInertia = detail::inverse_moment_of_inertia
 Inverse rotational inertia quantity. More...
 
using playrho::detail::length = Real
 Length quantity type.
 
using playrho::Length = detail::length
 Length quantity. More...
 
using playrho::LinearAcceleration = detail::acceleration
 Linear acceleration quantity. More...
 
using playrho::LinearVelocity = detail::velocity
 Linear velocity quantity. More...
 
using playrho::detail::mass = Real
 Mass quantity type.
 
using playrho::Mass = detail::mass
 Mass quantity. More...
 
using playrho::detail::moment_of_inertia = Real
 2nd momemnt of inertia quantity type.
 
using playrho::detail::momentum = Real
 Linear momentum quantity type.
 
using playrho::Momentum = detail::momentum
 Momentum quantity. More...
 
using playrho::detail::plane_angle = Real
 Plane angle quantity type.
 
using playrho::RotInertia = detail::moment_of_inertia
 Rotational inertia quantity. More...
 
using playrho::detail::second_moment_of_area = Real
 2nd moment of area quantity type.
 
using playrho::SecondMomentOfArea = detail::second_moment_of_area
 Second moment of area quantity. More...
 
using playrho::detail::surface_density = Real
 Surface density quantity type.
 
using playrho::detail::time = Real
 Time quantity type.
 
using playrho::Time = detail::time
 Time quantity. More...
 
using playrho::detail::torque = Real
 Torque quantity type.
 
using playrho::Torque = detail::torque
 Torque quantity. More...
 
using playrho::detail::velocity = Real
 Velocity quantity type.
 

Functions

constexpr Length playrho::literals::operator""_cm (long double v) noexcept
 SI unit symbol for a centimeter of Length. More...
 
constexpr Length playrho::literals::operator""_cm (unsigned long long int v) noexcept
 SI unit symbol for a centimeter of Length. More...
 
constexpr Time playrho::literals::operator""_d (long double v) noexcept
 Symbol for a day unit of Time. More...
 
constexpr Time playrho::literals::operator""_d (unsigned long long int v) noexcept
 Symbol for a day unit of Time. More...
 
constexpr Angle playrho::literals::operator""_deg (long double v) noexcept
 Abbreviation for a degree unit of Angle. More...
 
constexpr Angle playrho::literals::operator""_deg (unsigned long long int v) noexcept
 Abbreviation for a degree unit of Angle. More...
 
constexpr Length playrho::literals::operator""_dm (long double v) noexcept
 SI unit symbol for a decimeter of Length. More...
 
constexpr Length playrho::literals::operator""_dm (unsigned long long int v) noexcept
 SI unit symbol for a decimeter of Length. More...
 
constexpr Mass playrho::literals::operator""_g (long double v) noexcept
 SI unit symbol for a gram unit of Mass. More...
 
constexpr Mass playrho::literals::operator""_g (unsigned long long int v) noexcept
 SI unit symbol for a gram unit of Mass. More...
 
constexpr Length playrho::literals::operator""_Gm (long double v) noexcept
 SI unit symbol for a gigameter unit of Length. More...
 
constexpr Length playrho::literals::operator""_Gm (unsigned long long int v) noexcept
 SI unit symbol for a gigameter unit of Length. More...
 
constexpr Time playrho::literals::operator""_h (long double v) noexcept
 Symbol for an hour unit of Time. More...
 
constexpr Time playrho::literals::operator""_h (unsigned long long int v) noexcept
 Symbol for an hour unit of Time. More...
 
constexpr Frequency playrho::literals::operator""_Hz (long double v) noexcept
 SI symbol for a hertz unit of Frequency. More...
 
constexpr Frequency playrho::literals::operator""_Hz (unsigned long long int v) noexcept
 SI symbol for a hertz unit of Frequency. More...
 
constexpr Mass playrho::literals::operator""_kg (long double v) noexcept
 SI unit symbol for a kilogram unit of Mass. More...
 
constexpr Mass playrho::literals::operator""_kg (unsigned long long int v) noexcept
 SI unit symbol for a kilogram unit of Mass. More...
 
constexpr AreaDensity playrho::literals::operator""_kgpm2 (long double v) noexcept
 Abbreviation for kilogram per square meter.
 
constexpr AreaDensity playrho::literals::operator""_kgpm2 (unsigned long long int v) noexcept
 Abbreviation for kilogram per square meter.
 
constexpr Length playrho::literals::operator""_km (long double v) noexcept
 SI symbol for a kilometer unit of Length. More...
 
constexpr Length playrho::literals::operator""_km (unsigned long long int v) noexcept
 SI symbol for a kilometer unit of Length. More...
 
constexpr LinearVelocity playrho::literals::operator""_kps (long double v) noexcept
 Abbreviation for kilometer per second. More...
 
constexpr LinearVelocity playrho::literals::operator""_kps (unsigned long long int v) noexcept
 Abbreviation for kilometer per second. More...
 
constexpr Length playrho::literals::operator""_m (long double v) noexcept
 SI unit symbol for a meter of Length. More...
 
constexpr Length playrho::literals::operator""_m (unsigned long long int v) noexcept
 SI unit symbol for a meter of Length. More...
 
constexpr Area playrho::literals::operator""_m2 (long double v) noexcept
 Abbreviation for meter squared unit of Area. More...
 
constexpr Area playrho::literals::operator""_m2 (unsigned long long int v) noexcept
 Abbreviation for meter squared unit of Area. More...
 
constexpr Time playrho::literals::operator""_min (long double v) noexcept
 SI symbol for a minute unit of Time. More...
 
constexpr Time playrho::literals::operator""_min (unsigned long long int v) noexcept
 SI symbol for a minute unit of Time. More...
 
constexpr Length playrho::literals::operator""_Mm (long double v) noexcept
 SI unit symbol for a megameter unit of Length. More...
 
constexpr Length playrho::literals::operator""_Mm (unsigned long long int v) noexcept
 SI unit symbol for a megameter unit of Length. More...
 
constexpr LinearVelocity playrho::literals::operator""_mps (long double v) noexcept
 Abbreviation for meter per second. More...
 
constexpr LinearVelocity playrho::literals::operator""_mps (unsigned long long int v) noexcept
 Abbreviation for meter per second. More...
 
constexpr LinearAcceleration playrho::literals::operator""_mps2 (long double v) noexcept
 Abbreviation for meter per second squared. More...
 
constexpr LinearAcceleration playrho::literals::operator""_mps2 (unsigned long long int v) noexcept
 Abbreviation for meter per second squared. More...
 
constexpr Force playrho::literals::operator""_N (long double v) noexcept
 SI symbol for a newton unit of Force. More...
 
constexpr Force playrho::literals::operator""_N (unsigned long long int v) noexcept
 SI symbol for a newton unit of Force. More...
 
constexpr Torque playrho::literals::operator""_Nm (long double v) noexcept
 Abbreviation for newton-meter unit of torque. More...
 
constexpr Torque playrho::literals::operator""_Nm (unsigned long long int v) noexcept
 Abbreviation for newton-meter unit of torque. More...
 
constexpr Momentum playrho::literals::operator""_Ns (long double v) noexcept
 SI symbol for a newton second of impulse. More...
 
constexpr Momentum playrho::literals::operator""_Ns (unsigned long long int v) noexcept
 SI symbol for a newton second of impulse. More...
 
constexpr Mass playrho::literals::operator""_Pg (long double v) noexcept
 SI unit symbol for a petagram unit of Mass. More...
 
constexpr Mass playrho::literals::operator""_Pg (unsigned long long int v) noexcept
 SI unit symbol for a petagram unit of Mass. More...
 
constexpr Angle playrho::literals::operator""_rad (long double v) noexcept
 SI symbol for a radian unit of Angle. More...
 
constexpr Angle playrho::literals::operator""_rad (unsigned long long int v) noexcept
 SI symbol for a radian unit of Angle. More...
 
constexpr AngularVelocity playrho::literals::operator""_rpm (long double v) noexcept
 Abbreviation for revolutions per minute. More...
 
constexpr AngularVelocity playrho::literals::operator""_rpm (unsigned long long int v) noexcept
 Abbreviation for revolutions per minute. More...
 
constexpr Time playrho::literals::operator""_s (long double v) noexcept
 SI symbol for a second unit of Time. More...
 
constexpr Time playrho::literals::operator""_s (unsigned long long int v) noexcept
 SI symbol for a second unit of Time. More...
 
constexpr Mass playrho::literals::operator""_Yg (long double v) noexcept
 SI unit symbol for a yottagram unit of Mass. More...
 
constexpr Mass playrho::literals::operator""_Yg (unsigned long long int v) noexcept
 SI unit symbol for a yottagram unit of Mass. More...
 
template<class T >
constexpr auto playrho::StripUnit (const T &value) -> std::enable_if_t< IsArithmeticV< T > &&!detail::is_detected_v< detail::get_member_type, T >, T >
 Strips the units off of the given value. More...
 

Variables

constexpr auto playrho::BigG = static_cast<Real>(6.67408e-11f) * CubicMeter / (Kilogram * SquareSecond)
 Big "G". More...
 
constexpr auto playrho::CubicMeter = Meter * Meter * Meter
 Cubic meter unit of volume.
 
constexpr auto playrho::Degree = Angle{Radian * Pi / Real{180}}
 Degree unit of angle quantity. More...
 
constexpr auto playrho::DegreePerSecond = AngularVelocity{RadianPerSecond * Degree / Radian}
 Degree per second unit of angular velocity. More...
 
constexpr auto playrho::DegreePerSquareSecond = Degree / (Second * Second)
 Degree per square second unit of angular acceleration. More...
 
constexpr auto playrho::EarthlyLinearAcceleration = static_cast<Real>(-9.8f) * MeterPerSquareSecond
 Earthly gravity. More...
 
constexpr auto playrho::detail::hertz = 1
 Hertz unit value.
 
constexpr auto playrho::Hertz = Frequency(detail::hertz)
 Hertz unit of Frequency. More...
 
constexpr auto playrho::detail::HoursPerDay = 24
 Hours per day.
 
constexpr auto playrho::detail::kilogram = 1
 Kilogram unit value.
 
constexpr auto playrho::Kilogram = Mass(detail::kilogram)
 Kilogram unit of mass. More...
 
constexpr auto playrho::detail::kilogram_per_square_meter = 1
 Kilogram per meter^2 unit value.
 
constexpr auto playrho::KilogramPerSquareMeter = AreaDensity(detail::kilogram_per_square_meter)
 Kilogram per square meter unit of area density. More...
 
constexpr auto playrho::detail::meter = 1
 Meter unit value.
 
constexpr auto playrho::Meter = Length(detail::meter)
 Meter unit of Length. More...
 
constexpr auto playrho::detail::meter_per_second = 1
 Meter per second unit value.
 
constexpr auto playrho::detail::meter_per_second_squared = 1
 Meter per second^2 unit value.
 
constexpr auto playrho::MeterPerSecond = LinearVelocity(detail::meter_per_second)
 Meter per second unit of linear velocity. More...
 
constexpr auto playrho::MeterPerSquareSecond = LinearAcceleration(detail::meter_per_second_squared)
 Meter per square second unit of linear acceleration. More...
 
constexpr auto playrho::detail::MinutesPerHour = 60
 Minutes per hour.
 
constexpr auto playrho::detail::newton = 1
 Newton unit value.
 
constexpr auto playrho::Newton = Force(detail::newton)
 Newton unit of force. More...
 
constexpr auto playrho::detail::newton_meter = 1
 Newton meter unit value.
 
constexpr auto playrho::NewtonMeter = Torque(detail::newton_meter)
 Newton meter unit of torque. More...
 
constexpr auto playrho::NewtonMeterSecond = NewtonMeter * Second
 Newton meter second unit of angular momentum. More...
 
constexpr auto playrho::NewtonSecond = Newton * Second
 Newton second unit of momentum. More...
 
constexpr auto playrho::detail::radian = 1
 Radian unit value.
 
constexpr auto playrho::Radian = Angle(detail::radian)
 Radian unit of angle. More...
 
constexpr auto playrho::detail::radian_per_second = 1
 Radian per second unit value.
 
constexpr auto playrho::RadianPerSecond = AngularVelocity(detail::radian_per_second)
 Radian per second unit of angular velocity. More...
 
constexpr auto playrho::RadianPerSquareSecond = Radian / (Second * Second)
 Radian per square second unit of angular acceleration. More...
 
constexpr auto playrho::RevolutionsPerMinute = 2 * Pi * Radian / (Real{detail::SecondsPerMinute} * Second)
 Revolutions per minute units of angular velocity. More...
 
constexpr auto playrho::detail::second = 1
 Second unit value.
 
constexpr auto playrho::Second = Time(detail::second)
 Second unit of time. More...
 
constexpr auto playrho::detail::SecondsPerMinute = 60
 Seconds per minute.
 
constexpr auto playrho::detail::square_meter = 1
 Square meter unit value.
 
constexpr auto playrho::SquareMeter = Area(detail::square_meter)
 Square meter unit of area. More...
 
constexpr auto playrho::SquareRadian = Radian * Radian
 Square radian unit type. More...
 
constexpr auto playrho::SquareSecond = Second * Second
 Square second unit. More...
 

Detailed Description

Declarations for physical units possibly backed by strong types.

This file establishes quantity aliases, unit constants, and associated code for the expression of physical quantities using recognizably named units of those quantities. Quantities, as used herein, are types associated with physical quantities like time and length. Conceptually a given quantity is only expressable in units that relate to that quantity. For every quantity defined herein, there's typically at least one conceptually typed unit asscociated with it.

Note
In the simplest way that the PlayRho library can be configured, there's no compiler enforcement on the usage of the units for their associated quantities beyond the usage of the Real type.