Loading...
Searching...
No Matches
SBDQuantityType< Unit, Value > Class Template Reference

This template class defines physical quantity types. More...

Public Types

typedef SBDQuantityType< Unit, Value > Type
 The quantity type.
 
typedef Unit UnitType
 The unit type of the quantity.
 
typedef Value ValueType
 The value type of the quantity.
 

Useful functions

static const SBDQuantityType< Unit, Value > one
 The one value.
 
static const SBDQuantityType< Unit, Value > zero
 The zero value.
 
void print (bool fullName=false) const
 Prints the physical quantity (with a full unit name when fullName is true)
 
std::string toStdString (bool fullName=false) const
 Converts the physical quantity to a string (with a full unit name when fullName is true)
 
template<typename UnitB , int n>
static void diagonalize (const SBDQuantityType< Unit, Value >(&matrix)[n][n], SBDQuantityType< Unit, Value >(&eigenValues)[n], SBDQuantityType< UnitB, Value >(&eigenVectors)[n][n])
 
static SBDQuantityType< Unit, Value > fromLinearInterpolation (const SBDQuantityType< Unit, Value > &q0, const SBDQuantityType< Unit, Value > &q1, double alpha)
 Returns a linear interpolation between two physical quantities q0 and q1 for a parameter alpha in the closed unit interval [0, 1].
 

Constructors

constexpr SBDQuantityType () noexcept
 Constructs a physical quantity with default value.
 
constexpr SBDQuantityType (Value v) noexcept
 Constructs a physical quantity with value v.
 
constexpr SBDQuantityType (const SBDQuantityType< Unit, Value > &q)
 Constructs a physical quantity from quantity q.
 

Serialization

void serialize (SBCSerializer *serializer, const SBVersionNumber &sdkVersionNumber=SB_SDK_VERSION_NUMBER) const
 Serializes the quantity using the provided serializer.
 
void unserialize (SBCSerializer *serializer, const SBVersionNumber &sdkVersionNumber=SB_SDK_VERSION_NUMBER)
 Unserializes the quantity using the provided serializer.
 

Value

constexpr Value const & getValue () const noexcept
 Returns the value.
 
void getValue (double *array) const
 Stores the value as a double in array[0].
 
void getValue (float *array) const
 Stores the value as a float in array[0].
 
void setValue (const Value &v)
 Sets the value to v.
 
void setZero () noexcept
 Sets the value to zero.
 

Operators

SBDQuantityType< Unit, Value > & operator= (const SBDQuantityType< Unit, Value > &q)
 Copy the physical quantity q.
 
SBDQuantityType< Unit, Value > & operator= (double d) noexcept
 Assign the double d to the physical quantity (for dimensionless physical quantities only)
 
constexpr SBDQuantityType< Unit, Value > operator- () const noexcept
 Returns the opposite of the physical quantity.
 
constexpr SBDQuantityType< Unit, Value > operator+ (const SBDQuantityType< Unit, Value > &q) const
 Returns the sum of this physical quantity with physical quantity q.
 
constexpr SBDQuantityType< Unit, Value > operator+ (double d) const noexcept
 Returns the sum of this physical quantity with double d (for dimensionless physical quantities only)
 
constexpr SBDQuantityType< Unit, Value > & operator+= (const SBDQuantityType< Unit, Value > &q)
 Adds physical quantity q to this physical quantity.
 
constexpr SBDQuantityType< Unit, Value > & operator+= (double d) noexcept
 Add double d to this physical quantity (for dimensionless physical quantities only)
 
constexpr SBDQuantityType< Unit, Value > operator- (const SBDQuantityType< Unit, Value > &q) const
 Returns the difference between this physical quantity and physical quantity q

 
constexpr SBDQuantityType< Unit, Value > operator- (double d) const noexcept
 Returns the difference between this physical quantity and double d (for dimensionless physical quantities only)
 
constexpr SBDQuantityType< Unit, Value > & operator-= (const SBDQuantityType< Unit, Value > &q)
 Subtracts physical quantity q from this physical quantity.
 
constexpr SBDQuantityType< Unit, Value > & operator-= (double d) noexcept
 Subtracts double d from this physical quantity (for dimensionless physical quantities only)
 
constexpr SBDQuantityType< Unit, Value > operator* (double d) const noexcept
 Returns the product of this physical quantity with double d.
 
constexpr SBDQuantityType< Unit, Value > & operator*= (double d) noexcept
 Multiplies this physical quantity with double d.
 
template<typename UnitB >
constexpr SBDQuantityType< Unit, Value > & operator*= (const SBDQuantityType< UnitB, Value > &q)
 Multiplies this physical quantity with physical quantity q (for dimensionless physical quantities only)
 
constexpr SBDQuantityType< Unit, Value > operator/ (double d) const noexcept
 Returns the division of this physical quantity by double d.
 
constexpr SBDQuantityType< Unit, Value > & operator/= (double d) noexcept
 Divides this physical quantity by double d.
 
template<typename UnitB >
constexpr SBDQuantityType< Unit, Value > & operator/= (const SBDQuantityType< UnitB, Value > &q)
 Divides this physical quantity by physical quantity q (for dimensionless physical quantities only)
 
template<typename UnitB >
SBDQuantityType< typename SBDQuantityUnitMultiplication< Unit, UnitB >::UnitType, Value > operator* (const SBDQuantityType< UnitB, Value > &q) const
 Returns the product of this physical quantity with physical quantity q.
 
template<typename UnitB >
SBDQuantityType< typename SBDQuantityUnitDivision< Unit, UnitB >::UnitType, Value > operator/ (const SBDQuantityType< UnitB, Value > &q) const
 Returns the division of this physical quantity by physical quantity q.
 
template<typename UnitB >
 operator SBDQuantityType< UnitB, Value > () const
 Converts this physical quantity to unit UnitB.
 
template<typename UnitB >
constexpr bool operator== (const SBDQuantityType< UnitB, Value > &q) const
 Returns true if this physical quantity is equal to physical quantity q.
 
template<typename UnitB >
constexpr bool operator!= (const SBDQuantityType< UnitB, Value > &q) const
 Returns true if this physical quantity is different from physical quantity q.
 
template<typename UnitB >
constexpr bool operator< (const SBDQuantityType< UnitB, Value > &q) const
 Returns true if this physical quantity is smaller than physical quantity q.
 
template<typename UnitB >
constexpr bool operator> (const SBDQuantityType< UnitB, Value > &q) const
 Returns true if this physical quantity is larger than physical quantity q.
 
template<typename UnitB >
constexpr bool operator<= (const SBDQuantityType< UnitB, Value > &q) const
 Returns true if this physical quantity is smaller than or equal to physical quantity q.
 
template<typename UnitB >
constexpr bool operator>= (const SBDQuantityType< UnitB, Value > &q) const
 Returns true if this physical quantity is larger than or equal to physical quantity q.
 
constexpr bool operator== (double d) const
 Returns true if this physical quantity is equal to double d (for dimensionless physical quantities only)
 
constexpr bool operator!= (double d) const
 Returns true if this physical quantity is different from double d (for dimensionless physical quantities only)
 
constexpr bool operator< (double d) const
 Returns true if this physical quantity is smaller than double d (for dimensionless physical quantities only)
 
constexpr bool operator> (double d) const
 Returns true if this physical quantity is larger than double d (for dimensionless physical quantities only)
 
constexpr bool operator<= (double d) const
 Returns true if this physical quantity is smaller than or equal to double d (for dimensionless physical quantities only)
 
constexpr bool operator>= (double d) const
 Returns true if this physical quantity is larger than or equal to double d (for dimensionless physical quantities only)
 

Detailed Description

template<typename Unit, typename Value = double>
class SBDQuantityType< Unit, Value >
Template Parameters
UnitThe unit type of the physical quantity
ValueThe value type of the physical quantity

This template class is used to define physical quantity types, i.e. types that represent values associated to units. Precisely, a physical quantity has a both a value of type Value (e.g. double), and a unit type.

SBQuantity::force f = SBQuantity::nanonewton(17.0); // f = 17 nanonewton
SBQuantity::length l = SBQuantity::picometer(8.0); // l = 8 picometer
SBQuantity::energy w = f * l; // w = 136 zeptojoule
SBDQuantityType< SBDQuantityUnitType< SBUnitSystemSI, -12, 1, -27, 1, -15, -2, 0, 0, 0, 0, 0, 0, 0, 0 > > nanonewton
The nanonewton type.
Definition: SBDQuantity.hpp:454
SBDQuantityType< SBDQuantityUnitType< SBUnitSystemSI, -12, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 > > picometer
The picometer type.
Definition: SBDQuantity.hpp:82
This template class defines physical quantity types.
Definition: SBDQuantityType.hpp:43

Most of the time, developers of SAMSON Extensions do not have to use this template, but may directly use some predefined types, e.g. SBQuantity::nanonewton, SBQuantity::angstrom, etc.

Please refer to the description of SAMSON's unit system for more information.

Short name: SBQuantityType

See also
SAMSON's unit system
The SBDType library