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

Two-dimensional Euclidean vector in the XY plane. Contains two components in Cartesian coordinates: x and y. For a three-dimensional Euclidean vector, see PhQ::Vector. For a three-dimensional Euclidean dyadic tensor, see PhQ::Dyad. For a three-dimensional symmetric Euclidean dyadic tensor, see PhQ::SymmetricDyad. More...

#include "PlanarVector.hpp"

Public Member Functions

 PlanarVector ()=default
 Default constructor. Constructs a two-dimensional planar vector with uninitialized x and y Cartesian components. More...
 
constexpr PlanarVector (const NumericType x, const NumericType y)
 Constructor. Constructs a two-dimensional planar vector from the given x and y Cartesian components. More...
 
constexpr PlanarVector (const std::array< NumericType, 2 > &x_y)
 Constructor. Constructs a two-dimensional planar vector from a given array representing its x and y Cartesian components. More...
 
constexpr PlanarVector (const Vector< NumericType > &vector)
 Constructor. Constructs a two-dimensional planar vector from a given three-dimensional vector. Projects the three-dimensional vector onto the XY plane. More...
 
constexpr PlanarVector (NumericType magnitude, const PlanarDirection< NumericType > &direction)
 Constructor. Constructs a two-dimensional planar vector given a magnitude and a planar direction. More...
 
 ~PlanarVector () noexcept=default
 Destructor. Destroys this two-dimensional planar vector. More...
 
constexpr PlanarVector (const PlanarVector< NumericType > &other)=default
 Copy constructor. Constructs a two-dimensional planar vector by copying another one. More...
 
template<typename OtherNumericType >
constexpr PlanarVector (const PlanarVector< OtherNumericType > &other)
 Copy constructor. Constructs a two-dimensional planar vector by copying another one. More...
 
constexpr PlanarVector (PlanarVector< NumericType > &&other) noexcept=default
 Move constructor. Constructs a two-dimensional planar vector by moving another one. More...
 
constexpr PlanarVector< NumericType > & operator= (const PlanarVector< NumericType > &other)=default
 Copy assignment operator. Assigns this two-dimensional planar vector by copying another one. More...
 
template<typename OtherNumericType >
constexpr PlanarVector< NumericType > & operator= (const PlanarVector< OtherNumericType > &other)
 Copy assignment operator. Assigns this two-dimensional planar vector by copying another one. More...
 
constexpr PlanarVector< NumericType > & operator= (PlanarVector< NumericType > &&other) noexcept=default
 Move assignment operator. Assigns this two-dimensional planar vector by moving another one. More...
 
constexpr PlanarVector< NumericType > & operator= (const std::array< NumericType, 2 > &x_y)
 Assignment operator. Assigns this two-dimensional planar vector by copying a given array representing its x and y Cartesian components. More...
 
constexpr const std::array< NumericType, 2 > & x_y () const noexcept
 Returns this two-dimensional planar vector's x and y Cartesian components as an array. More...
 
constexpr NumericType x () const noexcept
 Returns this two-dimensional planar vector's x Cartesian component. More...
 
constexpr NumericType y () const noexcept
 Returns this two-dimensional planar vector's y Cartesian component. More...
 
constexpr std::array< NumericType, 2 > & Mutable_x_y () noexcept
 Returns this two-dimensional planar vector's x and y Cartesian components as a mutable array. More...
 
constexpr NumericType & Mutable_x () noexcept
 Returns this two-dimensional planar vector's x Cartesian component as a mutable value. More...
 
constexpr NumericType & Mutable_y () noexcept
 Returns this two-dimensional planar vector's y Cartesian component as a mutable value. More...
 
constexpr void Set_x_y (const std::array< NumericType, 2 > &x_y) noexcept
 Sets this two-dimensional planar vector's x and y Cartesian components to the given values. More...
 
constexpr void Set_x_y (const NumericType x, const NumericType y) noexcept
 Sets this two-dimensional planar vector's x and y Cartesian components to the given values. More...
 
constexpr void Set_x (const NumericType x) noexcept
 Sets this two-dimensional planar vector's x Cartesian component to a given value. More...
 
constexpr void Set_y (const NumericType y) noexcept
 Sets this two-dimensional planar vector's y Cartesian component to a given value. More...
 
constexpr NumericType MagnitudeSquared () const noexcept
 Returns the square of the magnitude of this two-dimensional planar vector. More...
 
NumericType Magnitude () const noexcept
 Returns the magnitude (also known as the L2 norm) of this two-dimensional planar vector. More...
 
PhQ::PlanarDirection< NumericType > PlanarDirection () const
 Returns the planar direction of this two-dimensional planar vector. More...
 
constexpr NumericType Dot (const PlanarVector< NumericType > &other) const noexcept
 Returns the dot product (also known as the inner product or scalar product) of this two-dimensional planar vector and another one. More...
 
constexpr NumericType Dot (const PhQ::PlanarDirection< NumericType > &planar_direction) const noexcept
 Returns the dot product (also known as the inner product or scalar product) of this two-dimensional planar vector and a given planar direction. More...
 
constexpr Vector< NumericType > Cross (const PlanarVector< NumericType > &other) const
 Returns the cross product (also known as the vector product) of this two-dimensional planar vector and another one. More...
 
constexpr Vector< NumericType > Cross (const PhQ::PlanarDirection< NumericType > &planar_direction) const
 Returns the cross product (also known as the vector product) of this two-dimensional planar vector and a given planar direction. More...
 
constexpr Dyad< NumericType > Dyadic (const PlanarVector< NumericType > &other) const
 Returns the dyadic tensor product (also known as the outer product) of this two-dimensional planar vector and another one. More...
 
constexpr Dyad< NumericType > Dyadic (const PhQ::PlanarDirection< NumericType > &planar_direction) const
 Returns the dyadic tensor product (also known as the outer product) of this two-dimensional planar vector and a given planar direction. More...
 
PhQ::Angle< NumericType > Angle (const PlanarVector< NumericType > &other) const
 Returns the angle between this two-dimensional planar vector and another one. More...
 
PhQ::Angle< NumericType > Angle (const PhQ::PlanarDirection< NumericType > &planar_direction) const
 Returns the angle between this two-dimensional planar vector and a given planar direction. More...
 
std::string Print () const
 Prints this two-dimensional planar vector as a string. More...
 
std::string JSON () const
 Serializes this two-dimensional planar vector as a JSON message. More...
 
std::string XML () const
 Serializes this two-dimensional planar vector as an XML message. More...
 
std::string YAML () const
 Serializes this two-dimensional planar vector as a YAML message. More...
 
constexpr void operator+= (const PlanarVector< NumericType > &other) noexcept
 Adds another two-dimensional planar vector to this one. More...
 
constexpr void operator-= (const PlanarVector< NumericType > &other) noexcept
 Subtracts another two-dimensional planar vector from this one. More...
 
template<typename OtherNumericType >
constexpr void operator*= (const OtherNumericType number) noexcept
 Multiplies this two-dimensional planar vector by the given number. More...
 
template<typename OtherNumericType >
constexpr void operator/= (const OtherNumericType number) noexcept
 Divides this two-dimensional planar vector by the given number. More...
 

Static Public Member Functions

static constexpr PlanarVector< NumericType > Zero ()
 Statically creates a two-dimensional planar vector with its x and y Cartesian components initialized to zero. More...
 

Private Attributes

std::array< NumericType, 2 > x_y_
 Cartesian components of this two-dimensional planar vector. More...
 

Detailed Description

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

Two-dimensional Euclidean vector in the XY plane. Contains two components in Cartesian coordinates: x and y. For a three-dimensional Euclidean vector, see PhQ::Vector. For a three-dimensional Euclidean dyadic tensor, see PhQ::Dyad. For a three-dimensional symmetric Euclidean dyadic tensor, see PhQ::SymmetricDyad.

Template Parameters
NumericTypeFloating-point numeric type: float, double, or long double. Defaults to double if unspecified.

Definition at line 63 of file PlanarVector.hpp.

Constructor & Destructor Documentation

◆ PlanarVector() [1/8]

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

Default constructor. Constructs a two-dimensional planar vector with uninitialized x and y Cartesian components.

◆ PlanarVector() [2/8]

template<typename NumericType = double>
constexpr PhQ::PlanarVector< NumericType >::PlanarVector ( const NumericType  x,
const NumericType  y 
)
inlineconstexpr

Constructor. Constructs a two-dimensional planar vector from the given x and y Cartesian components.

Definition at line 75 of file PlanarVector.hpp.

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

◆ PlanarVector() [3/8]

template<typename NumericType = double>
constexpr PhQ::PlanarVector< NumericType >::PlanarVector ( const std::array< NumericType, 2 > &  x_y)
inlineexplicitconstexpr

Constructor. Constructs a two-dimensional planar vector from a given array representing its x and y Cartesian components.

Definition at line 79 of file PlanarVector.hpp.

◆ PlanarVector() [4/8]

template<typename NumericType >
constexpr PhQ::PlanarVector< NumericType >::PlanarVector ( const Vector< NumericType > &  vector)
inlineexplicitconstexpr

Constructor. Constructs a two-dimensional planar vector from a given three-dimensional vector. Projects the three-dimensional vector onto the XY plane.

Definition at line 407 of file Vector.hpp.

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

◆ PlanarVector() [5/8]

template<typename NumericType >
constexpr PhQ::PlanarVector< NumericType >::PlanarVector ( NumericType  magnitude,
const PlanarDirection< NumericType > &  direction 
)
inlineconstexpr

Constructor. Constructs a two-dimensional planar vector given a magnitude and a planar direction.

Definition at line 376 of file PlanarDirection.hpp.

References PhQ::DimensionlessPlanarVector< NumericType >::Value(), and PhQ::PlanarVector< NumericType >::x_y_.

◆ ~PlanarVector()

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

Destructor. Destroys this two-dimensional planar vector.

◆ PlanarVector() [6/8]

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

Copy constructor. Constructs a two-dimensional planar vector by copying another one.

◆ PlanarVector() [7/8]

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

Copy constructor. Constructs a two-dimensional planar vector by copying another one.

Definition at line 97 of file PlanarVector.hpp.

◆ PlanarVector() [8/8]

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

Move constructor. Constructs a two-dimensional planar vector by moving another one.

Member Function Documentation

◆ Angle() [1/2]

template<typename NumericType >
Angle< NumericType > PhQ::PlanarVector< NumericType >::Angle ( const PhQ::PlanarDirection< NumericType > &  planar_direction) const
inline

Returns the angle between this two-dimensional planar vector and a given planar direction.

Definition at line 417 of file PlanarDirection.hpp.

◆ Angle() [2/2]

template<typename NumericType >
PhQ::Angle< NumericType > PhQ::PlanarVector< NumericType >::Angle ( const PlanarVector< NumericType > &  other) const
inline

Returns the angle between this two-dimensional planar vector and another one.

Definition at line 394 of file Angle.hpp.

◆ Cross() [1/2]

template<typename NumericType >
constexpr Vector< NumericType > PhQ::PlanarVector< NumericType >::Cross ( const PhQ::PlanarDirection< NumericType > &  planar_direction) const
inlineconstexpr

Returns the cross product (also known as the vector product) of this two-dimensional planar vector and a given planar direction.

Definition at line 392 of file PlanarDirection.hpp.

References PhQ::DimensionlessPlanarVector< NumericType >::Value().

◆ Cross() [2/2]

template<typename NumericType >
constexpr Vector< NumericType > PhQ::PlanarVector< NumericType >::Cross ( const PlanarVector< NumericType > &  other) const
constexpr

Returns the cross product (also known as the vector product) of this two-dimensional planar vector and another one.

Definition at line 411 of file Vector.hpp.

References PhQ::PlanarVector< NumericType >::x_y_.

Referenced by PhQ::PlanarDirection< NumericType >::Cross().

◆ Dot() [1/2]

template<typename NumericType >
constexpr NumericType PhQ::PlanarVector< NumericType >::Dot ( const PhQ::PlanarDirection< NumericType > &  planar_direction) const
inlineconstexprnoexcept

Returns the dot product (also known as the inner product or scalar product) of this two-dimensional planar vector and a given planar direction.

Definition at line 386 of file PlanarDirection.hpp.

◆ Dot() [2/2]

template<typename NumericType = double>
constexpr NumericType PhQ::PlanarVector< NumericType >::Dot ( const PlanarVector< NumericType > &  other) const
inlineconstexprnoexcept

Returns the dot product (also known as the inner product or scalar product) of this two-dimensional planar vector and another one.

Definition at line 206 of file PlanarVector.hpp.

References PhQ::PlanarVector< NumericType >::x_y_.

Referenced by PhQ::PlanarDirection< NumericType >::Dot().

◆ Dyadic() [1/2]

template<typename NumericType >
constexpr Dyad< NumericType > PhQ::PlanarVector< NumericType >::Dyadic ( const PhQ::PlanarDirection< NumericType > &  planar_direction) const
inlineconstexpr

Returns the dyadic tensor product (also known as the outer product) of this two-dimensional planar vector and a given planar direction.

Definition at line 398 of file PlanarDirection.hpp.

References PhQ::DimensionlessPlanarVector< NumericType >::Value().

◆ Dyadic() [2/2]

template<typename NumericType >
constexpr Dyad< NumericType > PhQ::PlanarVector< NumericType >::Dyadic ( const PlanarVector< NumericType > &  other) const
constexpr

Returns the dyadic tensor product (also known as the outer product) of this two-dimensional planar vector and another one.

Definition at line 722 of file Dyad.hpp.

References PhQ::PlanarVector< NumericType >::x_y_.

Referenced by PhQ::PlanarDirection< NumericType >::Dyadic().

◆ JSON()

template<typename NumericType = double>
std::string PhQ::PlanarVector< NumericType >::JSON ( ) const
inline

Serializes this two-dimensional planar vector as a JSON message.

Definition at line 247 of file PlanarVector.hpp.

References PhQ::Print(), and PhQ::PlanarVector< NumericType >::x_y_.

◆ Magnitude()

template<typename NumericType = double>
NumericType PhQ::PlanarVector< NumericType >::Magnitude ( ) const
inlinenoexcept

◆ MagnitudeSquared()

template<typename NumericType = double>
constexpr NumericType PhQ::PlanarVector< NumericType >::MagnitudeSquared ( ) const
inlineconstexprnoexcept

Returns the square of the magnitude of this two-dimensional planar vector.

Definition at line 191 of file PlanarVector.hpp.

References PhQ::PlanarVector< NumericType >::x_y_.

Referenced by PhQ::PlanarDirection< NumericType >::MagnitudeSquared().

◆ Mutable_x()

template<typename NumericType = double>
constexpr NumericType& PhQ::PlanarVector< NumericType >::Mutable_x ( )
inlineconstexprnoexcept

Returns this two-dimensional planar vector's x Cartesian component as a mutable value.

Definition at line 158 of file PlanarVector.hpp.

References PhQ::PlanarVector< NumericType >::x_y_.

◆ Mutable_x_y()

template<typename NumericType = double>
constexpr std::array<NumericType, 2>& PhQ::PlanarVector< NumericType >::Mutable_x_y ( )
inlineconstexprnoexcept

Returns this two-dimensional planar vector's x and y Cartesian components as a mutable array.

Definition at line 153 of file PlanarVector.hpp.

References PhQ::PlanarVector< NumericType >::x_y_.

Referenced by PhQ::ConvertInPlace().

◆ Mutable_y()

template<typename NumericType = double>
constexpr NumericType& PhQ::PlanarVector< NumericType >::Mutable_y ( )
inlineconstexprnoexcept

Returns this two-dimensional planar vector's y Cartesian component as a mutable value.

Definition at line 163 of file PlanarVector.hpp.

References PhQ::PlanarVector< NumericType >::x_y_.

◆ operator*=()

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

Multiplies this two-dimensional planar vector by the given number.

Template Parameters
OtherNumericTypeFloating-point numeric type of the given number. Deduced automatically.

Definition at line 277 of file PlanarVector.hpp.

References PhQ::PlanarVector< NumericType >::x_y_.

◆ operator+=()

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

Adds another two-dimensional planar vector to this one.

Definition at line 262 of file PlanarVector.hpp.

References PhQ::PlanarVector< NumericType >::x_y_.

◆ operator-=()

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

Subtracts another two-dimensional planar vector from this one.

Definition at line 268 of file PlanarVector.hpp.

References PhQ::PlanarVector< NumericType >::x_y_.

◆ operator/=()

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

Divides this two-dimensional planar vector by the given number.

Template Parameters
OtherNumericTypeFloating-point numeric type of the given number. Deduced automatically.

Definition at line 286 of file PlanarVector.hpp.

References PhQ::PlanarVector< NumericType >::x_y_.

◆ operator=() [1/4]

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

Copy assignment operator. Assigns this two-dimensional planar vector by copying another one.

◆ operator=() [2/4]

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

Copy assignment operator. Assigns this two-dimensional planar vector by copying another one.

Definition at line 110 of file PlanarVector.hpp.

References PhQ::PlanarVector< NumericType >::x(), PhQ::PlanarVector< NumericType >::x_y_, and PhQ::PlanarVector< NumericType >::y().

◆ operator=() [3/4]

template<typename NumericType = double>
constexpr PlanarVector<NumericType>& PhQ::PlanarVector< NumericType >::operator= ( const std::array< NumericType, 2 > &  x_y)
inlineconstexpr

Assignment operator. Assigns this two-dimensional planar vector by copying a given array representing its x and y Cartesian components.

Definition at line 123 of file PlanarVector.hpp.

References PhQ::PlanarVector< NumericType >::x_y(), and PhQ::PlanarVector< NumericType >::x_y_.

◆ operator=() [4/4]

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

Move assignment operator. Assigns this two-dimensional planar vector by moving another one.

◆ PlanarDirection()

template<typename NumericType >
PhQ::PlanarDirection< NumericType > PhQ::PlanarVector< NumericType >::PlanarDirection
inline

◆ Print()

template<typename NumericType = double>
std::string PhQ::PlanarVector< NumericType >::Print ( ) const
inline

Prints this two-dimensional planar vector as a string.

Definition at line 242 of file PlanarVector.hpp.

References PhQ::Print(), and PhQ::PlanarVector< NumericType >::x_y_.

Referenced by PhQ::operator<<().

◆ Set_x()

template<typename NumericType = double>
constexpr void PhQ::PlanarVector< NumericType >::Set_x ( const NumericType  x)
inlineconstexprnoexcept

Sets this two-dimensional planar vector's x Cartesian component to a given value.

Definition at line 181 of file PlanarVector.hpp.

References PhQ::PlanarVector< NumericType >::x(), and PhQ::PlanarVector< NumericType >::x_y_.

◆ Set_x_y() [1/2]

template<typename NumericType = double>
constexpr void PhQ::PlanarVector< NumericType >::Set_x_y ( const NumericType  x,
const NumericType  y 
)
inlineconstexprnoexcept

Sets this two-dimensional planar vector's x and y Cartesian components to the given values.

Definition at line 175 of file PlanarVector.hpp.

References PhQ::PlanarVector< NumericType >::x(), PhQ::PlanarVector< NumericType >::x_y_, and PhQ::PlanarVector< NumericType >::y().

◆ Set_x_y() [2/2]

template<typename NumericType = double>
constexpr void PhQ::PlanarVector< NumericType >::Set_x_y ( const std::array< NumericType, 2 > &  x_y)
inlineconstexprnoexcept

Sets this two-dimensional planar vector's x and y Cartesian components to the given values.

Definition at line 169 of file PlanarVector.hpp.

References PhQ::PlanarVector< NumericType >::x_y(), and PhQ::PlanarVector< NumericType >::x_y_.

◆ Set_y()

template<typename NumericType = double>
constexpr void PhQ::PlanarVector< NumericType >::Set_y ( const NumericType  y)
inlineconstexprnoexcept

Sets this two-dimensional planar vector's y Cartesian component to a given value.

Definition at line 186 of file PlanarVector.hpp.

References PhQ::PlanarVector< NumericType >::x_y_, and PhQ::PlanarVector< NumericType >::y().

◆ x()

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

◆ x_y()

template<typename NumericType = double>
constexpr const std::array<NumericType, 2>& PhQ::PlanarVector< NumericType >::x_y ( ) const
inlineconstexprnoexcept

Returns this two-dimensional planar vector's x and y Cartesian components as an array.

Definition at line 137 of file PlanarVector.hpp.

References PhQ::PlanarVector< NumericType >::x_y_.

Referenced by PhQ::Convert(), PhQ::ConvertStatically(), PhQ::PlanarVector< NumericType >::operator=(), PhQ::PlanarDirection< NumericType >::Set(), and PhQ::PlanarVector< NumericType >::Set_x_y().

◆ XML()

template<typename NumericType = double>
std::string PhQ::PlanarVector< NumericType >::XML ( ) const
inline

Serializes this two-dimensional planar vector as an XML message.

Definition at line 252 of file PlanarVector.hpp.

References PhQ::Print(), and PhQ::PlanarVector< NumericType >::x_y_.

◆ y()

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

◆ YAML()

template<typename NumericType = double>
std::string PhQ::PlanarVector< NumericType >::YAML ( ) const
inline

Serializes this two-dimensional planar vector as a YAML message.

Definition at line 257 of file PlanarVector.hpp.

References PhQ::Print(), and PhQ::PlanarVector< NumericType >::x_y_.

◆ Zero()

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

Member Data Documentation

◆ x_y_

template<typename NumericType = double>
std::array<NumericType, 2> PhQ::PlanarVector< NumericType >::x_y_
private

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