This template class is used to describe physical intervals. More...
Public Attributes | |
Quantity | i [2] |
The components of the interval. | |
Static Public Attributes | |
static const SBDTypePhysicalInterval< Quantity > | zero |
The zero physical interval. | |
static const SBDTypePhysicalInterval< Quantity > | empty |
The empty physical interval (+infinite, -infinite) | |
static const SBDTypePhysicalInterval< Quantity > | infinite |
The infinite physical interval (-infinite, +infinite) | |
Constructors | |
SBDTypePhysicalInterval () | |
The default constructor initializes all components to zero. | |
SBDTypePhysicalInterval (Quantity x) | |
Constructs a physical interval [x , x ]. | |
SBDTypePhysicalInterval (Quantity x, Quantity y) | |
Constructs a physical interval [x , y ]. | |
SBDTypePhysicalInterval (Quantity val[2]) | |
Constructs a physical interval [val [0], val [1]]. | |
Serialization | |
void | serialize (SBCSerializer *serializer, const SBVersionNumber &sdkVersionNumber=SB_SDK_VERSION_NUMBER) const |
Serializes the physical interval using the provided serializer . | |
void | unserialize (SBCSerializer *serializer, const SBVersionNumber &sdkVersionNumber=SB_SDK_VERSION_NUMBER) |
Unserializes the physical interval using the provided serializer . | |
Accessors | |
SBDTypePhysicalInterval< SBQuantity::dimensionless > | getValue () const |
Returns a dimensionless physical interval whose bounds are equal to those of this physical interval. | |
void | setValue (const SBDTypePhysicalInterval< SBQuantity::dimensionless > &u) |
Sets the bounds of this physical interval equal to those of the dimensionless physical interval u . | |
Operators | |
SBDTypePhysicalInterval< Quantity > | operator+ (const SBDTypePhysicalInterval< Quantity > &u) const |
Returns the sum of this physical interval and the physical interval u . | |
SBDTypePhysicalInterval< Quantity > | operator- (const SBDTypePhysicalInterval< Quantity > &u) const |
Returns the difference between this physical interval and the physical interval u . | |
SBDTypePhysicalInterval< Quantity > | operator* (double d) const |
Returns the result of the product of this physical interval by the double d . | |
template<typename QuantityB > | |
SBDTypePhysicalInterval< SBQuantityType< typename SBDQuantityUnitMultiplication< typename Quantity::UnitType, typename QuantityB::UnitType >::UnitType > > | operator* (const QuantityB &d) const |
Returns the product of this physical interval by the quantity d . More... | |
template<typename QuantityB > | |
SBDTypePhysicalInterval< SBQuantityType< typename SBDQuantityUnitMultiplication< typename Quantity::UnitType, typename QuantityB::UnitType >::UnitType > > | operator* (const SBDTypePhysicalInterval< QuantityB > &in) const |
Returns the product of this physical interval with the physical interval in . | |
template<typename QuantityB > | |
SBDTypePhysicalInterval< Quantity > & | operator*= (QuantityB d) const |
Returns the product of this physical interval by the quantity d . More... | |
template<typename QuantityB > | |
SBDTypePhysicalInterval< Quantity > & | operator*= (SBDTypePhysicalInterval< QuantityB > in) const |
Returns the product of this physical interval with the physical interval in . | |
SBDTypePhysicalInterval< Quantity > | operator/ (double d) const |
Returns the result of the division of this physical interval by the double d . | |
template<typename QuantityB > | |
SBDTypePhysicalInterval< SBQuantityType< typename SBDQuantityUnitDivision< typename Quantity::UnitType, typename QuantityB::UnitType >::UnitType > > | operator/ (QuantityB d) const |
Returns the result of the division of this physical interval by the quantity d . | |
template<typename QuantityB > | |
SBDTypePhysicalInterval< SBQuantityType< typename SBDQuantityUnitDivision< typename Quantity::UnitType, typename QuantityB::UnitType >::UnitType > > | operator/ (const SBDTypePhysicalInterval< QuantityB > &in) const |
Returns the result of the division of this physical interval by the physical interval in . | |
template<typename QuantityB > | |
SBDTypePhysicalInterval< Quantity > & | operator/= (QuantityB d) const |
Returns the result of the division of this physical interval by the quantity d . | |
template<typename QuantityB > | |
SBDTypePhysicalInterval< Quantity > & | operator/= (const SBDTypePhysicalInterval< QuantityB > &in) const |
Returns the result of the division of this physical interval by the physical interval in . | |
SBDTypePhysicalInterval< Quantity > | operator- () const |
Returns the opposite of this physical interval. | |
SBDTypePhysicalInterval< Quantity > & | operator+= (const SBDTypePhysicalInterval< Quantity > &u) |
Adds the physical interval u to this physical interval. | |
SBDTypePhysicalInterval< Quantity > & | operator-= (const SBDTypePhysicalInterval< Quantity > &u) |
Subtracts the physical interval u from this physical interval. | |
bool | operator^ (const SBDTypePhysicalInterval< Quantity > &u) |
Intersects this physical interval with the physical interval u . More... | |
template<typename QuantityB > | |
operator SBDTypePhysicalInterval< QuantityB > () const | |
Converts this physical interval to a physical interval with units QuantityB . | |
template<typename QuantityB > | |
bool | operator== (const SBDTypePhysicalInterval< QuantityB > &u) const |
Returns true when this physical interval is equal to physical interval u . | |
template<typename QuantityB > | |
bool | operator!= (const SBDTypePhysicalInterval< QuantityB > &u) const |
Returns true when this physical interval is different from physical interval u . | |
Quantity & | operator[] (int index) |
Returns a reference to component index of this physical interval. | |
const Quantity & | operator[] (int index) const |
Returns a reference to component index of this physical interval (const version) | |
Useful functions | |
bool | isEmpty (Quantity l, Quantity r) |
Determines whether the intersection between this physical interval and the physical interval [l , r ] is empty,. | |
Quantity | getAbsLower () const |
Returns the lower bound of the absolute value of this physical interval. | |
Quantity | getAbsUpper () const |
Returns the upper bound of the absolute value of this physical interval. | |
bool | contains (Quantity v) |
Returns true when this physical interval contains v . | |
void | bound (Quantity v) |
Enlarges this physical interval to contain v . | |
void | bound (const SBDTypePhysicalInterval< Quantity > &j) |
Enlarges this physical interval to contain the physical interval j . | |
void | expand (Quantity r) |
Expands this physical interval by offset r . More... | |
void | shrink (Quantity r) |
Shrinks this physical interval by offset r . More... | |
Quantity | center () const |
Returns the center 0.5*(i[0]+i[1]) of the physical interval. | |
Quantity | diameter () const |
Returns the diameter i[1]-i[0] of the physical interval. | |
void | setZero () |
Sets the physical interval to [0,0]. | |
void | print () const |
Prints the physical interval. | |
template<typename QuantityLower , typename QuantityUpper > | |
void | updateBounds (SBDTypePhysicalInterval< QuantityLower > &lower, SBDTypePhysicalInterval< QuantityUpper > &upper) const |
Updates the lower and upper bounds with this physical interval. More... | |
Quantity | The quantity type of the interval |
This template class is used to describe physical intervals.
Physical intervals are physical quantities, and thus use SAMSON's unit system. In a physical interval (e.g. an energy interval), both bounds have the same unit, so that physical intervals are defined by only one unit, and the SBDTypePhysicalInterval template class is parameterized by only one type: Quantity
.
This class may be used to perform interval arithmetics (IA), i.e. arithmetics with intervals instead of numbers, with physical quantities.
Most of the time, developers of SAMSON Elements do not have to use this template, but may directly use some predefined types that correspond to specific instantiations of this template class, e.g. SBInterval (dimensionless interval), SBEnergyInterval (energy interval), SBPositionInterval (position interval), etc.
Interval arithmetics may be particulary useful to compute bounds on physical quantities:
Short name: SBPhysicalInterval
|
inline |
r | The offset size |
This function expands this physical interval by offset r:
[a
, b
] becomes [a-r
, b+r
].
|
inline |
d | A quantity with unit QuantityB |
This function returns the product of this physical interval by the quantity d
. Note that the unit of the returned physical interval is the product of the physical interval's unit and the quantity's unit.
|
inline |
d | A quantity with unit QuantityB |
This function returns the product of this physical interval by the quantity d
. Note that the unit of the returned physical interval is the product of the physical interval's unit and the quantity's unit.
|
inline |
u | A physical interval |
u
is emptyThis operator returns true when the intersection between this physical interval and the physical interval u
is empty. When it is not, this interval is replaced by the intersection.
|
inline |
r | The offset size |
This function shrinks this physical interval by offset r:
[a
, b
] becomes [a+r
, b-r
]. When the offset r
is larger than the half-size of the physical interval, the interval becomes [m
, m
], where m
is the center of the interval.
|
inline |
lower | The lower bound |
upper | The upper bound |
If necessary, this function updates the lower
and upper
bounds to ensure that they contain this physical interval.