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::Position< NumericType > Class Template Reference

Three-dimensional Euclidean position vector. Contains three components in Cartesian coordinates: x, y, and z. Position is not to be confused with displacement; 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 scalar position components or for the magnitude of a position vector, see PhQ::Length. More...

#include "Position.hpp"

Public Member Functions

 Position ()=default
 Default constructor. Constructs a position vector with an uninitialized value. More...
 
 Position (const Vector< NumericType > &value, const Unit::Length unit)
 Constructor. Constructs a position vector with a given value expressed in a given length unit. More...
 
 Position (const Length< NumericType > &x, const Length< NumericType > &y, const Length< NumericType > &z)
 Constructor. Constructs a position vector from a given set of length components. More...
 
constexpr Position (const Length< NumericType > &length, const Direction< NumericType > &direction)
 Constructor. Constructs a position vector from a given length and direction. More...
 
constexpr Position (const PlanarPosition< NumericType > &planar_force)
 Constructor. Constructs a position vector from a given planar position vector in the XY plane. This position vector's z-component is initialized to zero. More...
 
constexpr Position (const Displacement< NumericType > &displacement)
 Constructor. Constructs a position vector from a given displacement vector from the origin. More...
 
 ~Position () noexcept=default
 Destructor. Destroys this position vector. More...
 
constexpr Position (const Position< NumericType > &other)=default
 Copy constructor. Constructs a position vector by copying another one. More...
 
template<typename OtherNumericType >
constexpr Position (const Position< OtherNumericType > &other)
 Copy constructor. Constructs a position by copying another one. More...
 
constexpr Position (Position< NumericType > &&other) noexcept=default
 Move constructor. Constructs a position vector by moving another one. More...
 
constexpr Position< NumericType > & operator= (const Position< NumericType > &other)=default
 Copy assignment operator. Assigns this position vector by copying another one. More...
 
template<typename OtherNumericType >
constexpr Position< NumericType > & operator= (const Position< OtherNumericType > &other)
 Copy assignment operator. Assigns this position by copying another one. More...
 
constexpr Position< NumericType > & operator= (Position< NumericType > &&other) noexcept=default
 Move assignment operator. Assigns this position vector by moving another one. More...
 
constexpr Length< NumericType > x () const noexcept
 Returns the x Cartesian component of this position vector. More...
 
constexpr Length< NumericType > y () const noexcept
 Returns the y Cartesian component of this position vector. More...
 
constexpr Length< NumericType > z () const noexcept
 Returns the z Cartesian component of this position vector. More...
 
Length< NumericType > Magnitude () const
 Returns the magnitude of this position vector. More...
 
PhQ::Direction< NumericType > Direction () const
 Returns the direction of this position vector. More...
 
PhQ::Angle< NumericType > Angle (const Position< NumericType > &position) const
 Returns the angle between this position vector and another one. More...
 
constexpr Position< NumericType > operator+ (const Position< NumericType > &position) const
 
constexpr Position< NumericType > operator+ (const Displacement< NumericType > &displacement) const
 
constexpr Displacement< NumericType > operator- (const Position< NumericType > &position) const
 
constexpr Position< NumericType > operator- (const Displacement< NumericType > &displacement) const
 
constexpr Position< NumericType > operator* (const NumericType number) const
 
constexpr Position< NumericType > operator/ (const NumericType number) const
 
constexpr void operator+= (const Position< NumericType > &position) noexcept
 
constexpr void operator+= (const Displacement< NumericType > &displacement) noexcept
 
constexpr void operator-= (const Position< NumericType > &position) noexcept
 
constexpr void operator-= (const Displacement< NumericType > &displacement) 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::Length 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::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 Position< NumericType > Zero ()
 Statically creates a position vector of zero. More...
 
template<Unit::Length Unit>
static constexpr Position< NumericType > Create (const NumericType x, const NumericType y, const NumericType z)
 Statically creates a position vector from the given x, y, and z Cartesian components expressed in a given length unit. More...
 
template<Unit::Length Unit>
static constexpr Position< NumericType > Create (const std::array< NumericType, 3 > &x_y_z)
 Statically creates a position vector from the given x, y, and z Cartesian components expressed in a given length unit. More...
 
template<Unit::Length Unit>
static constexpr Position< NumericType > Create (const Vector< NumericType > &value)
 Statically creates a position vector 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

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

Private Member Functions

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

Friends

template<typename OtherNumericType >
class Displacement
 

Detailed Description

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

Three-dimensional Euclidean position vector. Contains three components in Cartesian coordinates: x, y, and z. Position is not to be confused with displacement; 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 scalar position components or for the magnitude of a position vector, see PhQ::Length.

Definition at line 50 of file Position.hpp.

Constructor & Destructor Documentation

◆ Position() [1/10]

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

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

◆ Position() [2/10]

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

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

Definition at line 57 of file Position.hpp.

◆ Position() [3/10]

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

Constructor. Constructs a position vector from a given set of length components.

Definition at line 61 of file Position.hpp.

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

◆ Position() [4/10]

template<typename NumericType = double>
constexpr PhQ::Position< NumericType >::Position ( const Length< NumericType > &  length,
const Direction< NumericType > &  direction 
)
inlineconstexpr

Constructor. Constructs a position vector from a given length and direction.

Definition at line 65 of file Position.hpp.

◆ Position() [5/10]

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

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

Definition at line 70 of file Position.hpp.

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

◆ Position() [6/10]

template<typename NumericType = double>
constexpr PhQ::Position< NumericType >::Position ( const Displacement< NumericType > &  displacement)
inlineexplicitconstexpr

Constructor. Constructs a position vector from a given displacement vector from the origin.

Definition at line 75 of file Position.hpp.

◆ ~Position()

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

Destructor. Destroys this position vector.

◆ Position() [7/10]

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

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

◆ Position() [8/10]

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

Copy constructor. Constructs a position by copying another one.

Definition at line 86 of file Position.hpp.

◆ Position() [9/10]

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

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

◆ Position() [10/10]

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

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

Definition at line 217 of file Position.hpp.

Member Function Documentation

◆ Angle()

template<typename NumericType = double>
PhQ::Angle<NumericType> PhQ::Position< NumericType >::Angle ( const Position< NumericType > &  position) const
inline

Returns the angle between this position vector and another one.

Definition at line 162 of file Position.hpp.

◆ Create() [1/3]

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

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

Definition at line 113 of file Position.hpp.

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

◆ Create() [2/3]

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

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

Definition at line 122 of file Position.hpp.

◆ Create() [3/3]

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

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

Definition at line 131 of file Position.hpp.

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

◆ Dimensions()

static constexpr const PhQ::Dimensions& PhQ::DimensionalVector< Unit::Length , 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::Position< NumericType >::Direction ( ) const
inline

Returns the direction of this position vector.

Definition at line 157 of file Position.hpp.

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

◆ JSON() [1/2]

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

◆ JSON() [2/2]

std::string PhQ::DimensionalVector< Unit::Length , double >::JSON ( const UnitType  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>
Length<NumericType> PhQ::Position< NumericType >::Magnitude ( ) const
inline

Returns the magnitude of this position vector.

Definition at line 152 of file Position.hpp.

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

◆ MutableValue()

constexpr PhQ::Vector<double >& PhQ::DimensionalVector< 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 79 of file DimensionalVector.hpp.

◆ operator*()

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

◆ operator*=()

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

◆ operator+() [1/2]

template<typename NumericType = double>
constexpr Position<NumericType> PhQ::Position< NumericType >::operator+ ( const Displacement< NumericType > &  displacement) const
inlineconstexpr

◆ operator+() [2/2]

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

◆ operator+=() [1/2]

template<typename NumericType = double>
constexpr void PhQ::Position< NumericType >::operator+= ( const Displacement< NumericType > &  displacement)
inlineconstexprnoexcept

◆ operator+=() [2/2]

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

◆ operator-() [1/2]

template<typename NumericType = double>
constexpr Position<NumericType> PhQ::Position< NumericType >::operator- ( const Displacement< NumericType > &  displacement) const
inlineconstexpr

◆ operator-() [2/2]

template<typename NumericType = double>
constexpr Displacement<NumericType> PhQ::Position< NumericType >::operator- ( const Position< NumericType > &  position) const
inlineconstexpr

◆ operator-=() [1/2]

template<typename NumericType = double>
constexpr void PhQ::Position< NumericType >::operator-= ( const Displacement< NumericType > &  displacement)
inlineconstexprnoexcept

◆ operator-=() [2/2]

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

◆ operator/()

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

◆ operator/=()

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

◆ operator=() [1/3]

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

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

◆ operator=() [2/3]

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

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

Definition at line 97 of file Position.hpp.

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

◆ operator=() [3/3]

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

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

◆ Print() [1/2]

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

◆ Print() [2/2]

std::string PhQ::DimensionalVector< Unit::Length , double >::Print ( const UnitType  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::Length , double >::SetValue ( const PhQ::Vector< NumericType > &  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::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 73 of file DimensionalVector.hpp.

◆ Unit()

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

◆ Value() [1/2]

constexpr const PhQ::Vector<double >& PhQ::DimensionalVector< Unit::Length , 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::Length , double >::Value ( const UnitType  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 Length<NumericType> PhQ::Position< NumericType >::x ( ) const
inlineconstexprnoexcept

Returns the x Cartesian component of this position vector.

Definition at line 137 of file Position.hpp.

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

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

◆ XML() [1/2]

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

◆ XML() [2/2]

std::string PhQ::DimensionalVector< Unit::Length , double >::XML ( const UnitType  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 Length<NumericType> PhQ::Position< NumericType >::y ( ) const
inlineconstexprnoexcept

Returns the y Cartesian component of this position vector.

Definition at line 142 of file Position.hpp.

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

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

◆ YAML() [1/2]

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

◆ YAML() [2/2]

std::string PhQ::DimensionalVector< Unit::Length , double >::YAML ( const UnitType  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 Length<NumericType> PhQ::Position< NumericType >::z ( ) const
inlineconstexprnoexcept

Returns the z Cartesian component of this position vector.

Definition at line 147 of file Position.hpp.

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

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

◆ Zero()

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

Statically creates a position vector of zero.

Definition at line 106 of file Position.hpp.

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

Friends And Related Function Documentation

◆ Displacement

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

Definition at line 221 of file Position.hpp.

Member Data Documentation

◆ value

PhQ::Vector<double > PhQ::DimensionalVector< Unit::Length , 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: