Class SBDTypePhysicalInterval#
template <typename Quantity>
ClassList > SBDTypePhysicalInterval
This template class is used to describe physical intervals. More...
#include <SBDTypePhysicalInterval.hpp>
Public Attributes#
Type | Name |
---|---|
Quantity | i The components of the interval. |
Public Static Attributes#
Type | Name |
---|---|
const SBDTypePhysicalInterval< Quantity > | empty The empty physical interval (+infinite, -infinite) |
const SBDTypePhysicalInterval< Quantity > | infinite The infinite physical interval (-infinite, +infinite) |
const SBDTypePhysicalInterval< Quantity > | zero The zero physical interval. |
Public Functions#
Type | Name |
---|---|
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) Constructs a physical interval [ val [0],val [1]]. |
|
SBDTypePhysicalInterval (const SBDTypePhysicalInterval< Quantity > & u) Copy constructor. |
|
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 . |
Quantity | center () const Returns the center 0.5*(i[0]+i[1]) of the physical interval. |
bool | contains (Quantity v) const Returns true when this physical interval contains v . |
bool | contains (const SBDTypePhysicalInterval< Quantity > & j) const Returns true when this physical interval contains physical interval j . |
Quantity | diameter () const Returns the diameter i[1]-i[0] of the physical interval. |
void | expand (Quantity r) Expands this physical interval by offset r . |
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. |
SBDTypePhysicalInterval< SBQuantity::dimensionless > | getValue () const Returns a dimensionless physical interval whose bounds are equal to those of this physical interval. |
bool | isEmpty (const SBDTypePhysicalInterval< Quantity > u) const Determines whether the intersection between this physical interval and the physical interval u is empty,. |
bool | isEmpty (Quantity l, Quantity r) const Determines whether the intersection between this physical interval and the physical interval [ l ,r ] is empty,. |
operator SBDTypePhysicalInterval< QuantityB > () const Converts this physical interval to a physical interval with units QuantityB . |
|
bool | operator!= (const SBDTypePhysicalInterval< QuantityB > & u) const Returns true when this physical interval is different from physical interval u . |
SBDTypePhysicalInterval< Quantity > | operator* (double d) const Returns the result of the product of this physical interval with the double d . |
SBDTypePhysicalInterval< SBQuantityType< typename SBDQuantityUnitMultiplication< typename Quantity::UnitType, typename QuantityB::UnitType >::UnitType > > | operator* (const QuantityB & d) const Returns the product of this physical interval with the quantity d . |
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 . |
SBDTypePhysicalInterval< Quantity > & | operator*= (QuantityB d) const Multiplies this physical interval with the quantity d . |
SBDTypePhysicalInterval< Quantity > & | operator*= (SBDTypePhysicalInterval< QuantityB > in) const Multiplies this physical interval with the physical interval in . |
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) Adds the physical interval u to this physical interval. |
SBDTypePhysicalInterval< Quantity > | operator- (const SBDTypePhysicalInterval< Quantity > & u) const Returns the difference between this physical interval and the physical interval u . |
SBDTypePhysicalInterval< Quantity > | operator- () const Returns the opposite of this physical interval. |
SBDTypePhysicalInterval< Quantity > & | operator-= (const SBDTypePhysicalInterval< Quantity > & u) Subtracts the physical interval u from this physical interval. |
SBDTypePhysicalInterval< Quantity > | operator/ (double d) const Returns the result of the division of this physical interval by the double d . |
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 . |
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 . |
SBDTypePhysicalInterval< Quantity > & | operator/= (QuantityB d) const Divides this physical interval by the quantity d . |
SBDTypePhysicalInterval< Quantity > & | operator/= (const SBDTypePhysicalInterval< QuantityB > & in) const Divides this physical interval by the physical interval in . |
SBDTypePhysicalInterval< Quantity > & | operator= (const SBDTypePhysicalInterval< Quantity > & u) Copy assignment. |
bool | operator== (const SBDTypePhysicalInterval< QuantityB > & u) const Returns true when this physical interval is equal to 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) |
bool | operator^ (const SBDTypePhysicalInterval< Quantity > & u) Intersects this physical interval with the physical interval u . |
void | print () const Prints the physical interval. |
void | serialize (SBCSerializer * serializer, const SBVersionNumber & sdkVersionNumber=SB_SDK_VERSION_NUMBER) const Serializes the physical interval using the provided serializer . |
void | setValue (const SBDTypePhysicalInterval< SBQuantity::dimensionless > & u) Sets the bounds of this physical interval equal to those of the dimensionless physical interval u . |
void | setZero () Sets the physical interval to [0,0]. |
void | shrink (Quantity r) Shrinks this physical interval by offset r . |
void | unserialize (SBCSerializer * serializer, const SBVersionNumber & sdkVersionNumber=SB_SDK_VERSION_NUMBER) Unserializes the physical interval using the provided serializer . |
void | updateBounds (SBDTypePhysicalInterval< QuantityLower > & lower, SBDTypePhysicalInterval< QuantityUpper > & upper) const Updates the lower andupper bounds with this physical interval. |
Detailed Description#
Template parameters:
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 Extensions 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 particularly useful to compute bounds on physical quantities:
// bound on the first position
SBIAPosition3 x1(
SBQuantity::angstrom(1.7), SBQuantity::angstrom(1.8),
SBQuantity::angstrom(0.8), SBQuantity::angstrom(0.9),
SBQuantity::angstrom(7.5), SBQuantity::angstrom(7.6)
);
// bound on the second position
SBIAPosition3 x2(
SBQuantity::angstrom(0.2), SBQuantity::angstrom(0.3),
SBQuantity::angstrom(0.4), SBQuantity::angstrom(0.5),
SBQuantity::angstrom(7.7), SBQuantity::angstrom(7.8)
);
// bound on the squared distance
SBSquareLengthInterval l2 = ((x2 - x1) | (x2 - x1));
Short name: SBPhysicalInterval
See also: SBDTypePhysicalIAVector3
See also: SAMSON's unit system
Public Attributes Documentation#
variable i#
The components of the interval.
Public Static Attributes Documentation#
variable empty#
The empty physical interval (+infinite, -infinite)
variable infinite#
The infinite physical interval (-infinite, +infinite)
variable zero#
The zero physical interval.
Public Functions Documentation#
function SBDTypePhysicalInterval [1/5]#
The default constructor initializes all components to zero.
function SBDTypePhysicalInterval [2/5]#
Constructs a physical interval [ x
,x
].
function SBDTypePhysicalInterval [3/5]#
Constructs a physical interval [ x
,y
].
function SBDTypePhysicalInterval [4/5]#
Constructs a physical interval [ val
[0],val
[1]].
function SBDTypePhysicalInterval [5/5]#
Copy constructor.
inline SBDTypePhysicalInterval::SBDTypePhysicalInterval (
const SBDTypePhysicalInterval < Quantity > & u
)
function bound [1/2]#
Enlarges this physical interval to contain v
.
function bound [2/2]#
Enlarges this physical interval to contain the physical interval j
.
function center#
Returns the center 0.5*(i[0]+i[1]) of the physical interval.
function contains [1/2]#
Returns true when this physical interval contains v
.
function contains [2/2]#
Returns true when this physical interval contains physical interval j
.
inline bool SBDTypePhysicalInterval::contains (
const SBDTypePhysicalInterval < Quantity > & j
) const
function diameter#
Returns the diameter i[1]-i[0] of the physical interval.
function expand#
Expands this physical interval by offset r
.
Parameters:
r
The offset size
This function expands this physical interval by offset r:
[a
, b
] becomes [a-r
, b+r
].
function getAbsLower#
Returns the lower bound of the absolute value of this physical interval.
function getAbsUpper#
Returns the upper bound of the absolute value of this physical interval.
function getValue#
Returns a dimensionless physical interval whose bounds are equal to those of this physical interval.
inline SBDTypePhysicalInterval < SBQuantity::dimensionless > SBDTypePhysicalInterval::getValue () const
function isEmpty [1/2]#
Determines whether the intersection between this physical interval and the physical interval u
is empty,.
function isEmpty [2/2]#
Determines whether the intersection between this physical interval and the physical interval [ l
,r
] is empty,.
function operator SBDTypePhysicalInterval< QuantityB >#
Converts this physical interval to a physical interval with units QuantityB
.
template<typename QuantityB>
inline SBDTypePhysicalInterval::operator SBDTypePhysicalInterval< QuantityB > () const
function operator!=#
Returns true when this physical interval is different from physical interval u
.
template<typename QuantityB>
inline bool SBDTypePhysicalInterval::operator!= (
const SBDTypePhysicalInterval < QuantityB > & u
) const
function operator*#
Returns the result of the product of this physical interval with the double d
.
function operator*#
Returns the product of this physical interval with the quantity d
.
template<typename QuantityB>
inline SBDTypePhysicalInterval < SBQuantityType< typename SBDQuantityUnitMultiplication< typename Quantity::UnitType, typename QuantityB::UnitType >::UnitType > > SBDTypePhysicalInterval::operator* (
const QuantityB & d
) const
Parameters:
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.
function operator*#
Returns the product of this physical interval with the physical interval in
.
template<typename QuantityB>
inline SBDTypePhysicalInterval < SBQuantityType< typename SBDQuantityUnitMultiplication< typename Quantity::UnitType, typename QuantityB::UnitType >::UnitType > > SBDTypePhysicalInterval::operator* (
const SBDTypePhysicalInterval < QuantityB > & in
) const
function operator*=#
Multiplies this physical interval with the quantity d
.
template<typename QuantityB>
inline SBDTypePhysicalInterval < Quantity > & SBDTypePhysicalInterval::operator*= (
QuantityB d
) const
Parameters:
d
A dimensionless physical quantity or a numeric type (i.e. int, float, double, etc)
This function multiplies this physical interval with the quantity d
.
function operator*=#
Multiplies this physical interval with the physical interval in
.
template<typename QuantityB>
inline SBDTypePhysicalInterval < Quantity > & SBDTypePhysicalInterval::operator*= (
SBDTypePhysicalInterval < QuantityB > in
) const
Parameters:
in
A dimensionless physical interval
function operator+#
Returns the sum of this physical interval and the physical interval u
.
inline SBDTypePhysicalInterval < Quantity > SBDTypePhysicalInterval::operator+ (
const SBDTypePhysicalInterval < Quantity > & u
) const
function operator+=#
Adds the physical interval u
to this physical interval.
inline SBDTypePhysicalInterval < Quantity > & SBDTypePhysicalInterval::operator+= (
const SBDTypePhysicalInterval < Quantity > & u
)
function operator-#
Returns the difference between this physical interval and the physical interval u
.
inline SBDTypePhysicalInterval < Quantity > SBDTypePhysicalInterval::operator- (
const SBDTypePhysicalInterval < Quantity > & u
) const
function operator-#
Returns the opposite of this physical interval.
function operator-=#
Subtracts the physical interval u
from this physical interval.
inline SBDTypePhysicalInterval < Quantity > & SBDTypePhysicalInterval::operator-= (
const SBDTypePhysicalInterval < Quantity > & u
)
function operator/#
Returns the result of the division of this physical interval by the double d
.
function operator/#
Returns the result of the division of this physical interval by the quantity d
.
template<typename QuantityB>
inline SBDTypePhysicalInterval < SBQuantityType< typename SBDQuantityUnitDivision< typename Quantity::UnitType, typename QuantityB::UnitType >::UnitType > > SBDTypePhysicalInterval::operator/ (
QuantityB d
) const
function operator/#
Returns the result of the division of this physical interval by the physical interval in
.
template<typename QuantityB>
inline SBDTypePhysicalInterval < SBQuantityType< typename SBDQuantityUnitDivision< typename Quantity::UnitType, typename QuantityB::UnitType >::UnitType > > SBDTypePhysicalInterval::operator/ (
const SBDTypePhysicalInterval < QuantityB > & in
) const
function operator/=#
Divides this physical interval by the quantity d
.
template<typename QuantityB>
inline SBDTypePhysicalInterval < Quantity > & SBDTypePhysicalInterval::operator/= (
QuantityB d
) const
Parameters:
d
A dimensionless physical quantity or a numeric type (i.e. int, float, double, etc)
function operator/=#
Divides this physical interval by the physical interval in
.
template<typename QuantityB>
inline SBDTypePhysicalInterval < Quantity > & SBDTypePhysicalInterval::operator/= (
const SBDTypePhysicalInterval < QuantityB > & in
) const
Parameters:
in
A dimensionless physical interval
function operator=#
Copy assignment.
inline SBDTypePhysicalInterval < Quantity > & SBDTypePhysicalInterval::operator= (
const SBDTypePhysicalInterval < Quantity > & u
)
function operator==#
Returns true when this physical interval is equal to physical interval u
.
template<typename QuantityB>
inline bool SBDTypePhysicalInterval::operator== (
const SBDTypePhysicalInterval < QuantityB > & u
) const
function operator[]#
Returns a reference to component index
of this physical interval.
function operator[]#
Returns a reference to component index
of this physical interval (const version)
function operator^#
Intersects this physical interval with the physical interval u
.
Parameters:
u
A physical interval
Returns:
True when the intersection with u
is empty
This 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.
function print#
Prints the physical interval.
function serialize#
Serializes the physical interval using the provided serializer
.
inline void SBDTypePhysicalInterval::serialize (
SBCSerializer * serializer,
const SBVersionNumber & sdkVersionNumber=SB_SDK_VERSION_NUMBER
) const
function setValue#
Sets the bounds of this physical interval equal to those of the dimensionless physical interval u
.
inline void SBDTypePhysicalInterval::setValue (
const SBDTypePhysicalInterval < SBQuantity::dimensionless > & u
)
function setZero#
Sets the physical interval to [0,0].
function shrink#
Shrinks this physical interval by offset r
.
Parameters:
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.
function unserialize#
Unserializes the physical interval using the provided serializer
.
inline void SBDTypePhysicalInterval::unserialize (
SBCSerializer * serializer,
const SBVersionNumber & sdkVersionNumber=SB_SDK_VERSION_NUMBER
)
function updateBounds#
Updates the lower
andupper
bounds with this physical interval.
template<typename QuantityLower, typename QuantityUpper>
inline void SBDTypePhysicalInterval::updateBounds (
SBDTypePhysicalInterval < QuantityLower > & lower,
SBDTypePhysicalInterval < QuantityUpper > & upper
) const
Parameters:
lower
The lower boundupper
The upper bound
If necessary, this function updates the lower
and upper
bounds to ensure that they contain this physical interval.