Physical Quantities  v1.0.0
C++ library of physical quantities, physical models, and units of measure for scientific computing. https://github.com/acodcha/phq
Public Member Functions | Static Public Member Functions | Protected Attributes | Private Member Functions | Friends | List of all members
PhQ::Length< NumericType > Class Template Reference

Length, distance, or physical size. Can also represent a scalar component or magnitude of a position or displacement vector. For a three-dimensional Euclidean position vector, see PhQ::Position. For a three-dimensional Euclidean displacement vector, see PhQ::Displacement. For a two-dimensional Euclidean position vector in the XY plane, see PhQ::PlanarPosition. For a two-dimensional Euclidean displacement vector in the XY plane, see PhQ::PlanarDisplacement. More...

#include "Length.hpp"

Public Member Functions

 Length ()=default
 Default constructor. Constructs a length with an uninitialized value. More...
 
 Length (const NumericType value, const Unit::Length unit)
 Constructor. Constructs a length with a given value expressed in a given length unit. More...
 
constexpr Length (const Area< NumericType > &area, const Length< NumericType > &length)
 Constructor. Constructs a length from a given area and length. More...
 
constexpr Length (const Volume< NumericType > &volume, const Area< NumericType > &area)
 Constructor. Constructs a length from a given volume and area. More...
 
constexpr Length (const Speed< NumericType > &speed, const Time< NumericType > &time)
 Constructor. Constructs a length from a given speed and time using the definition of speed. More...
 
constexpr Length (const Speed< NumericType > &speed, const Frequency< NumericType > &frequency)
 Constructor. Constructs a length from a given speed and frequency using the definition of speed. More...
 
constexpr Length (const ReynoldsNumber< NumericType > &reynolds_number, const DynamicViscosity< NumericType > &dynamic_viscosity, const MassDensity< NumericType > &mass_density, const Speed< NumericType > &speed)
 Constructor. Constructs a length from a given Reynolds number, dynamic viscosity, mass density, and speed using the definition of the Reynolds number. More...
 
constexpr Length (const ReynoldsNumber< NumericType > &reynolds_number, const KinematicViscosity< NumericType > &kinematic_viscosity, const Speed< NumericType > &speed)
 Constructor. Constructs a length from a given Reynolds number, kinematic viscosity, and speed using the definition of the Reynolds number. More...
 
constexpr Length (const Energy< NumericType > &energy, const TransportEnergyConsumption< NumericType > &transport_energy_consumption)
 Constructor. Constructs a length from a given energy and transport energy consumption using the definition of transport energy consumption. More...
 
 ~Length () noexcept=default
 Destructor. Destroys this length. More...
 
constexpr Length (const Length< NumericType > &other)=default
 Copy constructor. Constructs a length by copying another one. More...
 
template<typename OtherNumericType >
constexpr Length (const Length< OtherNumericType > &other)
 Copy constructor. Constructs a length by copying another one. More...
 
constexpr Length (Length< NumericType > &&other) noexcept=default
 Move constructor. Constructs a length by moving another one. More...
 
constexpr Length< NumericType > & operator= (const Length< NumericType > &other)=default
 Copy assignment operator. Assigns this length by copying another one. More...
 
template<typename OtherNumericType >
constexpr Length< NumericType > & operator= (const Length< OtherNumericType > &other)
 Copy assignment operator. Assigns this length by copying another one. More...
 
constexpr Length< NumericType > & operator= (Length< NumericType > &&other) noexcept=default
 Move assignment operator. Assigns this length by moving another one. More...
 
constexpr Length< NumericType > operator+ (const Length< NumericType > &length) const
 
constexpr Length< NumericType > operator- (const Length< NumericType > &length) const
 
constexpr Length< NumericType > operator* (const NumericType number) const
 
constexpr Area< NumericType > operator* (const Length< NumericType > &length) const
 
constexpr Volume< NumericType > operator* (const Area< NumericType > &area) const
 
constexpr Speed< NumericType > operator* (const Frequency< NumericType > &frequency) const
 
constexpr Position< NumericType > operator* (const Direction< NumericType > &direction) const
 
constexpr PlanarPosition< NumericType > operator* (const PlanarDirection< NumericType > &planar_direction) const
 
constexpr Energy< NumericType > operator* (const TransportEnergyConsumption< NumericType > &transport_energy_consumption) const
 
constexpr Length< NumericType > operator/ (const NumericType number) const
 
constexpr Speed< NumericType > operator/ (const Time< NumericType > &time) const
 
constexpr Time< NumericType > operator/ (const Speed< NumericType > &speed) const
 
constexpr NumericType operator/ (const Length< NumericType > &length) const noexcept
 
constexpr void operator+= (const Length< NumericType > &length) noexcept
 
constexpr void operator-= (const Length< NumericType > &length) noexcept
 
constexpr void operator*= (const NumericType number) noexcept
 
constexpr void operator/= (const NumericType number) noexcept
 
constexpr double Value () const noexcept
 Value of this physical quantity expressed in its standard unit of measure. More...
 
double Value (const Unit::Length unit) const
 Value of this physical quantity expressed in a given unit of measure. More...
 
constexpr double StaticValue () const
 Value of this physical quantity expressed in a given unit of measure. This method can be evaluated statically at compile-time. More...
 
constexpr double & MutableValue () noexcept
 Returns the value of this physical quantity expressed in its standard unit of measure as a mutable value. More...
 
constexpr void SetValue (const double value) noexcept
 Sets the value of this physical quantity expressed in its standard unit of measure to the given value. More...
 
std::string Print () const
 Prints this physical quantity as a string. This physical quantity's value is expressed in its standard unit of measure. More...
 
std::string Print (const Unit::Length unit) const
 Prints this physical quantity as a string. This physical quantity's value is expressed in the given unit of measure. More...
 
std::string JSON () const
 Serializes this physical quantity as a JSON message. This physical quantity's value is expressed in its standard unit of measure. More...
 
std::string JSON (const Unit::Length unit) const
 Serializes this physical quantity as a JSON message. This physical quantity's value is expressed in the given unit of measure. More...
 
std::string XML () const
 Serializes this physical quantity as an XML message. This physical quantity's value is expressed in its standard unit of measure. More...
 
std::string XML (const Unit::Length unit) const
 Serializes this physical quantity as an XML message. This physical quantity's value is expressed in the given unit of measure. More...
 
std::string YAML () const
 Serializes this physical quantity as a YAML message. This physical quantity's value is expressed in its standard unit of measure. More...
 
std::string YAML (const Unit::Length unit) const
 Serializes this physical quantity as a YAML message. This physical quantity's value is expressed in the given unit of measure. More...
 

Static Public Member Functions

static constexpr Length< NumericType > Zero ()
 Statically creates a length of zero. More...
 
template<Unit::Length Unit>
static constexpr Length< NumericType > Create (const NumericType value)
 Statically creates a length with a given value expressed in a given length unit. More...
 
static constexpr const PhQ::DimensionsDimensions ()
 Physical dimension set of this physical quantity. More...
 
static constexpr Unit::Length Unit ()
 Standard unit of measure for this physical quantity. This physical quantity's value is stored internally in this unit of measure. More...
 

Protected Attributes

double value
 Value of this physical quantity expressed in its standard unit of measure. More...
 

Private Member Functions

constexpr Length (const NumericType value)
 Constructor. Constructs a length with a given value expressed in the standard length unit. More...
 

Friends

template<typename OtherNumericType >
class Displacement
 
template<typename OtherNumericType >
class PlanarDisplacement
 
template<typename OtherNumericType >
class PlanarPosition
 
template<typename OtherNumericType >
class Position
 

Detailed Description

template<typename NumericType = double>
class PhQ::Length< NumericType >

Length, distance, or physical size. Can also represent a scalar component or magnitude of a position or displacement vector. For a three-dimensional Euclidean position vector, see PhQ::Position. For a three-dimensional Euclidean displacement vector, see PhQ::Displacement. For a two-dimensional Euclidean position vector in the XY plane, see PhQ::PlanarPosition. For a two-dimensional Euclidean displacement vector in the XY plane, see PhQ::PlanarDisplacement.

Definition at line 111 of file Length.hpp.

Constructor & Destructor Documentation

◆ Length() [1/13]

template<typename NumericType = double>
PhQ::Length< NumericType >::Length ( )
default

Default constructor. Constructs a length with an uninitialized value.

◆ Length() [2/13]

template<typename NumericType = double>
PhQ::Length< NumericType >::Length ( const NumericType  value,
const Unit::Length< NumericType >  unit 
)
inline

Constructor. Constructs a length with a given value expressed in a given length unit.

Definition at line 117 of file Length.hpp.

◆ Length() [3/13]

template<typename NumericType = double>
constexpr PhQ::Length< NumericType >::Length ( const Area< NumericType > &  area,
const Length< NumericType > &  length 
)
constexpr

Constructor. Constructs a length from a given area and length.

◆ Length() [4/13]

template<typename NumericType = double>
constexpr PhQ::Length< NumericType >::Length ( const Volume< NumericType > &  volume,
const Area< NumericType > &  area 
)
constexpr

Constructor. Constructs a length from a given volume and area.

◆ Length() [5/13]

template<typename NumericType = double>
constexpr PhQ::Length< NumericType >::Length ( const Speed< NumericType > &  speed,
const Time< NumericType > &  time 
)
constexpr

Constructor. Constructs a length from a given speed and time using the definition of speed.

◆ Length() [6/13]

template<typename NumericType = double>
constexpr PhQ::Length< NumericType >::Length ( const Speed< NumericType > &  speed,
const Frequency< NumericType > &  frequency 
)
constexpr

Constructor. Constructs a length from a given speed and frequency using the definition of speed.

◆ Length() [7/13]

template<typename NumericType = double>
constexpr PhQ::Length< NumericType >::Length ( const ReynoldsNumber< NumericType > &  reynolds_number,
const DynamicViscosity< NumericType > &  dynamic_viscosity,
const MassDensity< NumericType > &  mass_density,
const Speed< NumericType > &  speed 
)
constexpr

Constructor. Constructs a length from a given Reynolds number, dynamic viscosity, mass density, and speed using the definition of the Reynolds number.

◆ Length() [8/13]

template<typename NumericType = double>
constexpr PhQ::Length< NumericType >::Length ( const ReynoldsNumber< NumericType > &  reynolds_number,
const KinematicViscosity< NumericType > &  kinematic_viscosity,
const Speed< NumericType > &  speed 
)
constexpr

Constructor. Constructs a length from a given Reynolds number, kinematic viscosity, and speed using the definition of the Reynolds number.

◆ Length() [9/13]

template<typename NumericType = double>
constexpr PhQ::Length< NumericType >::Length ( const Energy< NumericType > &  energy,
const TransportEnergyConsumption< NumericType > &  transport_energy_consumption 
)
constexpr

Constructor. Constructs a length from a given energy and transport energy consumption using the definition of transport energy consumption.

◆ ~Length()

template<typename NumericType = double>
PhQ::Length< NumericType >::~Length ( )
defaultnoexcept

Destructor. Destroys this length.

◆ Length() [10/13]

template<typename NumericType = double>
constexpr PhQ::Length< NumericType >::Length ( const Length< NumericType > &  other)
constexprdefault

Copy constructor. Constructs a length by copying another one.

◆ Length() [11/13]

template<typename NumericType = double>
template<typename OtherNumericType >
constexpr PhQ::Length< NumericType >::Length ( const Length< OtherNumericType > &  other)
inlineexplicitconstexpr

Copy constructor. Constructs a length by copying another one.

Definition at line 159 of file Length.hpp.

◆ Length() [12/13]

template<typename NumericType = double>
constexpr PhQ::Length< NumericType >::Length ( Length< NumericType > &&  other)
constexprdefaultnoexcept

Move constructor. Constructs a length by moving another one.

◆ Length() [13/13]

template<typename NumericType = double>
constexpr PhQ::Length< NumericType >::Length ( const NumericType  value)
inlineexplicitconstexprprivate

Constructor. Constructs a length with a given value expressed in the standard length unit.

Definition at line 247 of file Length.hpp.

Member Function Documentation

◆ Create()

template<typename NumericType = double>
template<Unit::Length Unit>
static constexpr Length<NumericType> PhQ::Length< NumericType >::Create ( const NumericType  value)
inlinestaticconstexpr

Statically creates a length with a given value expressed in a given length unit.

Definition at line 185 of file Length.hpp.

References PhQ::DimensionalScalar< Unit::Length, double >::value.

◆ Dimensions()

static constexpr const PhQ::Dimensions& PhQ::DimensionalScalar< Unit::Length , double >::Dimensions ( )
inlinestaticconstexprinherited

Physical dimension set of this physical quantity.

Definition at line 54 of file DimensionalScalar.hpp.

◆ JSON() [1/2]

std::string PhQ::DimensionalScalar< Unit::Length , double >::JSON ( ) const
inlineinherited

Serializes this physical quantity as a JSON message. This physical quantity's value is expressed in its standard unit of measure.

Definition at line 107 of file DimensionalScalar.hpp.

◆ JSON() [2/2]

std::string PhQ::DimensionalScalar< Unit::Length , double >::JSON ( const Unit::Length  unit) const
inlineinherited

Serializes this physical quantity as a JSON message. This physical quantity's value is expressed in the given unit of measure.

Definition at line 117 of file DimensionalScalar.hpp.

◆ MutableValue()

constexpr double & PhQ::DimensionalScalar< Unit::Length , double >::MutableValue ( )
inlineconstexprnoexceptinherited

Returns the value of this physical quantity expressed in its standard unit of measure as a mutable value.

Definition at line 83 of file DimensionalScalar.hpp.

◆ operator*() [1/7]

template<typename NumericType = double>
constexpr Volume<NumericType> PhQ::Length< NumericType >::operator* ( const Area< NumericType > &  area) const
constexpr

◆ operator*() [2/7]

template<typename NumericType = double>
constexpr Position<NumericType> PhQ::Length< NumericType >::operator* ( const Direction< NumericType > &  direction) const
constexpr

◆ operator*() [3/7]

template<typename NumericType = double>
constexpr Speed<NumericType> PhQ::Length< NumericType >::operator* ( const Frequency< NumericType > &  frequency) const
constexpr

◆ operator*() [4/7]

template<typename NumericType = double>
constexpr Area<NumericType> PhQ::Length< NumericType >::operator* ( const Length< NumericType > &  length) const
constexpr

◆ operator*() [5/7]

template<typename NumericType = double>
constexpr Length<NumericType> PhQ::Length< NumericType >::operator* ( const NumericType  number) const
inlineconstexpr

Definition at line 198 of file Length.hpp.

References PhQ::DimensionalScalar< Unit::Length, double >::value.

◆ operator*() [6/7]

template<typename NumericType = double>
constexpr PlanarPosition<NumericType> PhQ::Length< NumericType >::operator* ( const PlanarDirection< NumericType > &  planar_direction) const
constexpr

◆ operator*() [7/7]

template<typename NumericType = double>
constexpr Energy<NumericType> PhQ::Length< NumericType >::operator* ( const TransportEnergyConsumption< NumericType > &  transport_energy_consumption) const
constexpr

◆ operator*=()

template<typename NumericType = double>
constexpr void PhQ::Length< NumericType >::operator*= ( const NumericType  number)
inlineconstexprnoexcept

Definition at line 236 of file Length.hpp.

References PhQ::DimensionalScalar< Unit::Length, double >::value.

◆ operator+()

template<typename NumericType = double>
constexpr Length<NumericType> PhQ::Length< NumericType >::operator+ ( const Length< NumericType > &  length) const
inlineconstexpr

◆ operator+=()

template<typename NumericType = double>
constexpr void PhQ::Length< NumericType >::operator+= ( const Length< NumericType > &  length)
inlineconstexprnoexcept

Definition at line 228 of file Length.hpp.

References PhQ::DimensionalScalar< Unit::Length, double >::value.

◆ operator-()

template<typename NumericType = double>
constexpr Length<NumericType> PhQ::Length< NumericType >::operator- ( const Length< NumericType > &  length) const
inlineconstexpr

◆ operator-=()

template<typename NumericType = double>
constexpr void PhQ::Length< NumericType >::operator-= ( const Length< NumericType > &  length)
inlineconstexprnoexcept

Definition at line 232 of file Length.hpp.

References PhQ::DimensionalScalar< Unit::Length, double >::value.

◆ operator/() [1/4]

template<typename NumericType = double>
constexpr NumericType PhQ::Length< NumericType >::operator/ ( const Length< NumericType > &  length) const
inlineconstexprnoexcept

Definition at line 224 of file Length.hpp.

References PhQ::DimensionalScalar< Unit::Length, double >::value.

◆ operator/() [2/4]

template<typename NumericType = double>
constexpr Length<NumericType> PhQ::Length< NumericType >::operator/ ( const NumericType  number) const
inlineconstexpr

Definition at line 216 of file Length.hpp.

References PhQ::DimensionalScalar< Unit::Length, double >::value.

◆ operator/() [3/4]

template<typename NumericType = double>
constexpr Time<NumericType> PhQ::Length< NumericType >::operator/ ( const Speed< NumericType > &  speed) const
constexpr

◆ operator/() [4/4]

template<typename NumericType = double>
constexpr Speed<NumericType> PhQ::Length< NumericType >::operator/ ( const Time< NumericType > &  time) const
constexpr

◆ operator/=()

template<typename NumericType = double>
constexpr void PhQ::Length< NumericType >::operator/= ( const NumericType  number)
inlineconstexprnoexcept

Definition at line 240 of file Length.hpp.

References PhQ::DimensionalScalar< Unit::Length, double >::value.

◆ operator=() [1/3]

template<typename NumericType = double>
constexpr Length<NumericType>& PhQ::Length< NumericType >::operator= ( const Length< NumericType > &  other)
constexprdefault

Copy assignment operator. Assigns this length by copying another one.

◆ operator=() [2/3]

template<typename NumericType = double>
template<typename OtherNumericType >
constexpr Length<NumericType>& PhQ::Length< NumericType >::operator= ( const Length< OtherNumericType > &  other)
inlineconstexpr

Copy assignment operator. Assigns this length by copying another one.

Definition at line 170 of file Length.hpp.

References PhQ::DimensionalScalar< UnitType, NumericType >::Value(), and PhQ::DimensionalScalar< Unit::Length, double >::value.

◆ operator=() [3/3]

template<typename NumericType = double>
constexpr Length<NumericType>& PhQ::Length< NumericType >::operator= ( Length< NumericType > &&  other)
constexprdefaultnoexcept

Move assignment operator. Assigns this length by moving another one.

◆ Print() [1/2]

std::string PhQ::DimensionalScalar< Unit::Length , double >::Print ( ) const
inlineinherited

Prints this physical quantity as a string. This physical quantity's value is expressed in its standard unit of measure.

Definition at line 95 of file DimensionalScalar.hpp.

◆ Print() [2/2]

std::string PhQ::DimensionalScalar< Unit::Length , double >::Print ( const Unit::Length  unit) const
inlineinherited

Prints this physical quantity as a string. This physical quantity's value is expressed in the given unit of measure.

Definition at line 101 of file DimensionalScalar.hpp.

◆ SetValue()

constexpr void PhQ::DimensionalScalar< Unit::Length , double >::SetValue ( const double  value)
inlineconstexprnoexceptinherited

Sets the value of this physical quantity expressed in its standard unit of measure to the given value.

Definition at line 89 of file DimensionalScalar.hpp.

◆ StaticValue()

constexpr double PhQ::DimensionalScalar< Unit::Length , double >::StaticValue ( ) const
inlineconstexprinherited

Value of this physical quantity expressed in a given unit of measure. This method can be evaluated statically at compile-time.

Definition at line 77 of file DimensionalScalar.hpp.

◆ Unit()

static constexpr Unit::Length PhQ::DimensionalScalar< Unit::Length , double >::Unit ( )
inlinestaticconstexprinherited

Standard unit of measure for this physical quantity. This physical quantity's value is stored internally in this unit of measure.

Definition at line 60 of file DimensionalScalar.hpp.

◆ Value() [1/2]

constexpr double PhQ::DimensionalScalar< Unit::Length , double >::Value ( ) const
inlineconstexprnoexceptinherited

Value of this physical quantity expressed in its standard unit of measure.

Definition at line 65 of file DimensionalScalar.hpp.

◆ Value() [2/2]

double PhQ::DimensionalScalar< Unit::Length , double >::Value ( const Unit::Length  unit) const
inlineinherited

Value of this physical quantity expressed in a given unit of measure.

Definition at line 70 of file DimensionalScalar.hpp.

◆ XML() [1/2]

std::string PhQ::DimensionalScalar< Unit::Length , double >::XML ( ) const
inlineinherited

Serializes this physical quantity as an XML message. This physical quantity's value is expressed in its standard unit of measure.

Definition at line 127 of file DimensionalScalar.hpp.

◆ XML() [2/2]

std::string PhQ::DimensionalScalar< Unit::Length , double >::XML ( const Unit::Length  unit) const
inlineinherited

Serializes this physical quantity as an XML message. This physical quantity's value is expressed in the given unit of measure.

Definition at line 137 of file DimensionalScalar.hpp.

◆ YAML() [1/2]

std::string PhQ::DimensionalScalar< Unit::Length , double >::YAML ( ) const
inlineinherited

Serializes this physical quantity as a YAML message. This physical quantity's value is expressed in its standard unit of measure.

Definition at line 147 of file DimensionalScalar.hpp.

◆ YAML() [2/2]

std::string PhQ::DimensionalScalar< Unit::Length , double >::YAML ( const Unit::Length  unit) const
inlineinherited

Serializes this physical quantity as a YAML message. This physical quantity's value is expressed in the given unit of measure.

Definition at line 157 of file DimensionalScalar.hpp.

◆ Zero()

template<typename NumericType = double>
static constexpr Length<NumericType> PhQ::Length< NumericType >::Zero ( )
inlinestaticconstexpr

Statically creates a length of zero.

Definition at line 179 of file Length.hpp.

Friends And Related Function Documentation

◆ Displacement

template<typename NumericType = double>
template<typename OtherNumericType >
friend class Displacement
friend

Definition at line 251 of file Length.hpp.

◆ PlanarDisplacement

template<typename NumericType = double>
template<typename OtherNumericType >
friend class PlanarDisplacement
friend

Definition at line 254 of file Length.hpp.

◆ PlanarPosition

template<typename NumericType = double>
template<typename OtherNumericType >
friend class PlanarPosition
friend

Definition at line 257 of file Length.hpp.

◆ Position

template<typename NumericType = double>
template<typename OtherNumericType >
friend class Position
friend

Definition at line 260 of file Length.hpp.

Member Data Documentation

◆ value

double PhQ::DimensionalScalar< Unit::Length , double >::value
protectedinherited

Value of this physical quantity expressed in its standard unit of measure.

Definition at line 221 of file DimensionalScalar.hpp.


The documentation for this class was generated from the following files: