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 | List of all members
PhQ::Force< NumericType > Class Template Reference

Three-dimensional Euclidean force vector. Contains three components in Cartesian coordinates: x, y, and z. For a two-dimensional Euclidean force vector in the XY plane, see PhQ::PlanarForce. For scalar force components or for the magnitude of a force vector, see PhQ::ScalarForce. More...

#include "Force.hpp"

Public Member Functions

 Force ()=default
 Default constructor. Constructs a force vector with an uninitialized value. More...
 
 Force (const Vector< NumericType > &value, const Unit::Force unit)
 Constructor. Constructs a force vector with a given value expressed in a given force unit. More...
 
 Force (const ScalarForce< NumericType > &x, const ScalarForce< NumericType > &y, const ScalarForce< NumericType > &z)
 Constructor. Constructs a force vector from a given set of scalar force components. More...
 
constexpr Force (const ScalarForce< NumericType > &scalar_force, const Direction< NumericType > &direction)
 Constructor. Constructs a force vector from a given scalar force magnitude and direction. More...
 
constexpr Force (const PlanarForce< NumericType > &planar_force)
 Constructor. Constructs a force vector from a given planar force vector in the XY plane. This force vector's z-component is initialized to zero. More...
 
constexpr Force (const Traction< NumericType > &traction, const Area< NumericType > &area)
 Constructor. Constructs a force vector from a given traction and area using the definition of traction. More...
 
 ~Force () noexcept=default
 Destructor. Destroys this force vector. More...
 
constexpr Force (const Force< NumericType > &other)=default
 Copy constructor. Constructs a force vector by copying another one. More...
 
template<typename OtherNumericType >
constexpr Force (const Force< OtherNumericType > &other)
 Copy constructor. Constructs a force vector by copying another one. More...
 
constexpr Force (Force< NumericType > &&other) noexcept=default
 Move constructor. Constructs a force vector by moving another one. More...
 
constexpr Force< NumericType > & operator= (const Force< NumericType > &other)=default
 Copy assignment operator. Assigns this force vector by copying another one. More...
 
template<typename OtherNumericType >
constexpr Force< NumericType > & operator= (const Force< OtherNumericType > &other)
 Copy assignment operator. Assigns this force vector by copying another one. More...
 
constexpr Force< NumericType > & operator= (Force< NumericType > &&other) noexcept=default
 Move assignment operator. Assigns this force vector by moving another one. More...
 
constexpr ScalarForce< NumericType > x () const noexcept
 Returns the x Cartesian component of this force vector. More...
 
constexpr ScalarForce< NumericType > y () const noexcept
 Returns the y Cartesian component of this force vector. More...
 
constexpr ScalarForce< NumericType > z () const noexcept
 Returns the z Cartesian component of this force vector. More...
 
ScalarForce< NumericType > Magnitude () const
 Returns the magnitude of this force vector. More...
 
PhQ::Direction< NumericType > Direction () const
 Returns the direction of this force vector. More...
 
PhQ::Angle< NumericType > Angle (const Force< NumericType > &force) const
 Returns the angle between this force vector and another one. More...
 
constexpr Force< NumericType > operator+ (const Force< NumericType > &force) const
 
constexpr Force< NumericType > operator- (const Force< NumericType > &force) const
 
constexpr Force< NumericType > operator* (const NumericType number) const
 
constexpr Force< NumericType > operator/ (const NumericType number) const
 
constexpr Traction< NumericType > operator/ (const Area< NumericType > &area) const
 
constexpr void operator+= (const Force< NumericType > &force) noexcept
 
constexpr void operator-= (const Force< NumericType > &force) noexcept
 
constexpr void operator*= (const NumericType number) noexcept
 
constexpr void operator/= (const NumericType number) noexcept
 
constexpr const PhQ::Vector< double > & Value () const noexcept
 Value of this physical quantity expressed in its standard unit of measure. More...
 
PhQ::Vector< double > Value (const Unit::Force unit) const
 Value of this physical quantity expressed in a given unit of measure. More...
 
constexpr PhQ::Vector< 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 PhQ::Vector< 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 PhQ::Vector< 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::Force 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::Force 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::Force 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::Force 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 Force< NumericType > Zero ()
 Statically creates a force vector of zero. More...
 
template<Unit::Force Unit>
static constexpr Force< NumericType > Create (const NumericType x, const NumericType y, const NumericType z)
 Statically creates a force vector from the given x, y, and z Cartesian components expressed in a given force unit. More...
 
template<Unit::Force Unit>
static constexpr Force< NumericType > Create (const std::array< NumericType, 3 > &x_y_z)
 Statically creates a force vector from the given x, y, and z Cartesian components expressed in a given force unit. More...
 
template<Unit::Force Unit>
static constexpr Force< NumericType > Create (const Vector< NumericType > &value)
 Statically creates a force vector with a given value expressed in a given force unit. More...
 
static constexpr const PhQ::DimensionsDimensions ()
 Physical dimension set of this physical quantity. More...
 
static constexpr Unit::Force 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

PhQ::Vector< double > value
 Value of this physical quantity expressed in its standard unit of measure. More...
 

Private Member Functions

constexpr Force (const Vector< NumericType > &value)
 Constructor. Constructs a force vector with a given value expressed in the standard force unit. More...
 

Detailed Description

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

Three-dimensional Euclidean force vector. Contains three components in Cartesian coordinates: x, y, and z. For a two-dimensional Euclidean force vector in the XY plane, see PhQ::PlanarForce. For scalar force components or for the magnitude of a force vector, see PhQ::ScalarForce.

Definition at line 52 of file Force.hpp.

Constructor & Destructor Documentation

◆ Force() [1/10]

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

Default constructor. Constructs a force vector with an uninitialized value.

◆ Force() [2/10]

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

Constructor. Constructs a force vector with a given value expressed in a given force unit.

Definition at line 59 of file Force.hpp.

◆ Force() [3/10]

template<typename NumericType = double>
PhQ::Force< NumericType >::Force ( const ScalarForce< NumericType > &  x,
const ScalarForce< NumericType > &  y,
const ScalarForce< NumericType > &  z 
)
inline

Constructor. Constructs a force vector from a given set of scalar force components.

Definition at line 63 of file Force.hpp.

References PhQ::Force< NumericType >::x(), PhQ::Force< NumericType >::y(), and PhQ::Force< NumericType >::z().

◆ Force() [4/10]

template<typename NumericType = double>
constexpr PhQ::Force< NumericType >::Force ( const ScalarForce< NumericType > &  scalar_force,
const Direction< NumericType > &  direction 
)
inlineconstexpr

Constructor. Constructs a force vector from a given scalar force magnitude and direction.

Definition at line 69 of file Force.hpp.

◆ Force() [5/10]

template<typename NumericType = double>
constexpr PhQ::Force< NumericType >::Force ( const PlanarForce< NumericType > &  planar_force)
inlineexplicitconstexpr

Constructor. Constructs a force vector from a given planar force vector in the XY plane. This force vector's z-component is initialized to zero.

Definition at line 75 of file Force.hpp.

References PhQ::DimensionalPlanarVector< UnitType, NumericType >::Value().

◆ Force() [6/10]

template<typename NumericType = double>
constexpr PhQ::Force< NumericType >::Force ( const Traction< NumericType > &  traction,
const Area< NumericType > &  area 
)
constexpr

Constructor. Constructs a force vector from a given traction and area using the definition of traction.

◆ ~Force()

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

Destructor. Destroys this force vector.

◆ Force() [7/10]

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

Copy constructor. Constructs a force vector by copying another one.

◆ Force() [8/10]

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

Copy constructor. Constructs a force vector by copying another one.

Definition at line 90 of file Force.hpp.

◆ Force() [9/10]

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

Move constructor. Constructs a force vector by moving another one.

◆ Force() [10/10]

template<typename NumericType = double>
constexpr PhQ::Force< NumericType >::Force ( const Vector< NumericType > &  value)
inlineexplicitconstexprprivate

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

Definition at line 205 of file Force.hpp.

Member Function Documentation

◆ Angle()

template<typename NumericType = double>
PhQ::Angle<NumericType> PhQ::Force< NumericType >::Angle ( const Force< NumericType > &  force) const
inline

Returns the angle between this force vector and another one.

Definition at line 164 of file Force.hpp.

◆ Create() [1/3]

template<typename NumericType = double>
template<Unit::Force Unit>
static constexpr Force<NumericType> PhQ::Force< NumericType >::Create ( const NumericType  x,
const NumericType  y,
const NumericType  z 
)
inlinestaticconstexpr

Statically creates a force vector from the given x, y, and z Cartesian components expressed in a given force unit.

Definition at line 117 of file Force.hpp.

References PhQ::Force< NumericType >::x(), PhQ::Force< NumericType >::y(), and PhQ::Force< NumericType >::z().

◆ Create() [2/3]

template<typename NumericType = double>
template<Unit::Force Unit>
static constexpr Force<NumericType> PhQ::Force< NumericType >::Create ( const std::array< NumericType, 3 > &  x_y_z)
inlinestaticconstexpr

Statically creates a force vector from the given x, y, and z Cartesian components expressed in a given force unit.

Definition at line 126 of file Force.hpp.

◆ Create() [3/3]

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

Statically creates a force vector with a given value expressed in a given force unit.

Definition at line 134 of file Force.hpp.

References PhQ::DimensionalVector< Unit::Force, double >::value.

◆ Dimensions()

static constexpr const PhQ::Dimensions& PhQ::DimensionalVector< Unit::Force , double >::Dimensions ( )
inlinestaticconstexprinherited

Physical dimension set of this physical quantity.

Definition at line 50 of file DimensionalVector.hpp.

◆ Direction()

template<typename NumericType = double>
PhQ::Direction<NumericType> PhQ::Force< NumericType >::Direction ( ) const
inline

Returns the direction of this force vector.

Definition at line 159 of file Force.hpp.

References PhQ::Vector< NumericType >::Direction(), and PhQ::DimensionalVector< Unit::Force, double >::value.

◆ JSON() [1/2]

std::string PhQ::DimensionalVector< Unit::Force , 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 103 of file DimensionalVector.hpp.

◆ JSON() [2/2]

std::string PhQ::DimensionalVector< Unit::Force , double >::JSON ( const Unit::Force  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 113 of file DimensionalVector.hpp.

◆ Magnitude()

template<typename NumericType = double>
ScalarForce<NumericType> PhQ::Force< NumericType >::Magnitude ( ) const
inline

Returns the magnitude of this force vector.

Definition at line 154 of file Force.hpp.

References PhQ::Vector< NumericType >::Magnitude(), and PhQ::DimensionalVector< Unit::Force, double >::value.

◆ MutableValue()

constexpr PhQ::Vector<double >& PhQ::DimensionalVector< Unit::Force , double >::MutableValue ( )
inlineconstexprnoexceptinherited

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

Definition at line 79 of file DimensionalVector.hpp.

◆ operator*()

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

Definition at line 176 of file Force.hpp.

References PhQ::DimensionalVector< Unit::Force, double >::value.

◆ operator*=()

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

Definition at line 194 of file Force.hpp.

References PhQ::DimensionalVector< Unit::Force, double >::value.

◆ operator+()

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

◆ operator+=()

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

Definition at line 186 of file Force.hpp.

References PhQ::DimensionalVector< Unit::Force, double >::value.

◆ operator-()

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

◆ operator-=()

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

Definition at line 190 of file Force.hpp.

References PhQ::DimensionalVector< Unit::Force, double >::value.

◆ operator/() [1/2]

template<typename NumericType = double>
constexpr Traction<NumericType> PhQ::Force< NumericType >::operator/ ( const Area< NumericType > &  area) const
constexpr

◆ operator/() [2/2]

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

Definition at line 180 of file Force.hpp.

References PhQ::DimensionalVector< Unit::Force, double >::value.

◆ operator/=()

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

Definition at line 198 of file Force.hpp.

References PhQ::DimensionalVector< Unit::Force, double >::value.

◆ operator=() [1/3]

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

Copy assignment operator. Assigns this force vector by copying another one.

◆ operator=() [2/3]

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

Copy assignment operator. Assigns this force vector by copying another one.

Definition at line 101 of file Force.hpp.

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

◆ operator=() [3/3]

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

Move assignment operator. Assigns this force vector by moving another one.

◆ Print() [1/2]

std::string PhQ::DimensionalVector< Unit::Force , 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 91 of file DimensionalVector.hpp.

◆ Print() [2/2]

std::string PhQ::DimensionalVector< Unit::Force , double >::Print ( const Unit::Force  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 97 of file DimensionalVector.hpp.

◆ SetValue()

constexpr void PhQ::DimensionalVector< Unit::Force , double >::SetValue ( const PhQ::Vector< double > &  value)
inlineconstexprnoexceptinherited

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

Definition at line 85 of file DimensionalVector.hpp.

◆ StaticValue()

constexpr PhQ::Vector<double > PhQ::DimensionalVector< Unit::Force , 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 73 of file DimensionalVector.hpp.

◆ Unit()

static constexpr Unit::Force PhQ::DimensionalVector< Unit::Force , 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 56 of file DimensionalVector.hpp.

◆ Value() [1/2]

constexpr const PhQ::Vector<double >& PhQ::DimensionalVector< Unit::Force , double >::Value ( ) const
inlineconstexprnoexceptinherited

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

Definition at line 61 of file DimensionalVector.hpp.

◆ Value() [2/2]

PhQ::Vector<double > PhQ::DimensionalVector< Unit::Force , double >::Value ( const Unit::Force  unit) const
inlineinherited

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

Definition at line 66 of file DimensionalVector.hpp.

◆ x()

template<typename NumericType = double>
constexpr ScalarForce<NumericType> PhQ::Force< NumericType >::x ( ) const
inlineconstexprnoexcept

Returns the x Cartesian component of this force vector.

Definition at line 139 of file Force.hpp.

References PhQ::DimensionalVector< Unit::Force, double >::value, and PhQ::Vector< NumericType >::x().

Referenced by PhQ::Force< NumericType >::Create(), and PhQ::Force< NumericType >::Force().

◆ XML() [1/2]

std::string PhQ::DimensionalVector< Unit::Force , 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 123 of file DimensionalVector.hpp.

◆ XML() [2/2]

std::string PhQ::DimensionalVector< Unit::Force , double >::XML ( const Unit::Force  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 133 of file DimensionalVector.hpp.

◆ y()

template<typename NumericType = double>
constexpr ScalarForce<NumericType> PhQ::Force< NumericType >::y ( ) const
inlineconstexprnoexcept

Returns the y Cartesian component of this force vector.

Definition at line 144 of file Force.hpp.

References PhQ::DimensionalVector< Unit::Force, double >::value, and PhQ::Vector< NumericType >::y().

Referenced by PhQ::Force< NumericType >::Create(), and PhQ::Force< NumericType >::Force().

◆ YAML() [1/2]

std::string PhQ::DimensionalVector< Unit::Force , 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 143 of file DimensionalVector.hpp.

◆ YAML() [2/2]

std::string PhQ::DimensionalVector< Unit::Force , double >::YAML ( const Unit::Force  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 153 of file DimensionalVector.hpp.

◆ z()

template<typename NumericType = double>
constexpr ScalarForce<NumericType> PhQ::Force< NumericType >::z ( ) const
inlineconstexprnoexcept

Returns the z Cartesian component of this force vector.

Definition at line 149 of file Force.hpp.

References PhQ::DimensionalVector< Unit::Force, double >::value, and PhQ::Vector< NumericType >::z().

Referenced by PhQ::Force< NumericType >::Create(), and PhQ::Force< NumericType >::Force().

◆ Zero()

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

Statically creates a force vector of zero.

Definition at line 110 of file Force.hpp.

References PhQ::Vector< NumericType >::Zero().

Member Data Documentation

◆ value

PhQ::Vector<double > PhQ::DimensionalVector< Unit::Force , double >::value
protectedinherited

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

Definition at line 217 of file DimensionalVector.hpp.


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