Ocean
Ocean::AdvancedLookupCenter2< T, TScalar > Class Template Reference

This class implements an advanced 2D lookup object with values at the bins' center positions defining the individual lookup values. More...

Inheritance diagram for Ocean::AdvancedLookupCenter2< T, TScalar >:

Public Member Functions

 AdvancedLookupCenter2 ()=default
 Creates a new empty lookup object. More...
 
 AdvancedLookupCenter2 (const AdvancedLookupCenter2< T, TScalar > &lookup)
 Copy constructor. More...
 
 AdvancedLookupCenter2 (AdvancedLookupCenter2< T, TScalar > &&lookup) noexcept
 Move constructor. More...
 
 AdvancedLookupCenter2 (const size_t sizeX, const size_t sizeY, const size_t binsX, const size_t binsY)
 Creates a new lookup object by definition of the dimensions and bin numbers. More...
 
 AdvancedLookupCenter2 (const size_t sizeX, const size_t sizeY, const size_t binsX, const size_t binsY, const bool binsValid)
 Creates a new lookup object by definition of the dimensions and bin numbers. More...
 
 AdvancedLookupCenter2 (const size_t sizeX, const size_t sizeY, const size_t binsX, const size_t binsY, const T *binValues, const unsigned char *validBins)
 Creates a new lookup object by definition of the dimensions and bin numbers. More...
 
 AdvancedLookupCenter2 (const size_t sizeX, const size_t sizeY, const AdvancedLookupCenter2< T, TScalar > &lookup)
 Creates a new lookup object by definition of the dimensions and a given lookup object. More...
 
bool binCenterValid (const size_t binX, const size_t binY) const
 Returns whether a specific bin of this lookup object is valid. More...
 
bool nearestValue (const TScalar x, const TScalar y, T &value) const
 Applies a lookup for a specific position in this lookup object. More...
 
bool bilinearValue (const TScalar x, const TScalar y, T &value) const
 Applies a lookup for a specific position in this lookup object. More...
 
bool bilinearValue (const TScalar x, const TScalar y, const unsigned int minimalValidBins, T &value) const
 Applies a lookup for a specific position in this lookup object. More...
 
bool clampedNearestValue (const TScalar x, const TScalar y, T &value) const
 Applies a lookup for a specific position in this lookup object while the position is clamped to match into the domain of the lookup table. More...
 
bool clampedBilinearValue (const TScalar x, const TScalar y, T &value) const
 Applies a lookup for a specific position in this lookup object while the position is clamped to match into the domain of the lookup table. More...
 
void setBinCenterValue (const size_t binX, const size_t binY, const T &value, const bool isValid)
 Sets the value of one specific lookup bin's center and defines whether this bin is valid. More...
 
void setBinCenterValid (const size_t binX, const size_t binY, const bool isValid)
 Sets whether a specific lookup bin is valid. More...
 
AdvancedLookupCenter2< T, TScalar > & operator= (AdvancedLookupCenter2< T, TScalar > &&lookup) noexcept
 Move operator. More...
 
bool operator== (const AdvancedLookupCenter2< T, TScalar > &lookup) const
 Returns whether two lookup objects are identical. More...
 
bool operator!= (const AdvancedLookupCenter2< T, TScalar > &lookup) const
 Returns whether two lookup objects are not identical. More...
 
- Public Member Functions inherited from Ocean::LookupCenter2< T, Scalar >
 LookupCenter2 ()=default
 Creates a new empty lookup object. More...
 
 LookupCenter2 (const LookupCenter2< T, Scalar > &lookup)
 Copy constructor. More...
 
 LookupCenter2 (LookupCenter2< T, Scalar > &&lookup) noexcept
 Move constructor. More...
 
 LookupCenter2 (const size_t sizeX, const size_t sizeY, const size_t binsX, const size_t binsY)
 Creates a new lookup object by definition of the dimensions and bin numbers. More...
 
 LookupCenter2 (const size_t sizeX, const size_t sizeY, const size_t binsX, const size_t binsY, const T *binValues)
 Creates a new lookup object by definition of the dimensions and bin numbers. More...
 
 LookupCenter2 (const size_t sizeX, const size_t sizeY, const LookupCenter2< T, Scalar > &lookup)
 Creates a new lookup object by definition of the dimensions and a given lookup object. More...
 
bool isInside (const Scalar x, const Scalar y) const
 Returns whether a given position lies inside this lookup object and therefore whether this position can be applied for the interpolation functions. More...
 
size_t binX (const Scalar x) const
 Returns the horizontal bin that corresponds to a precise horizontal lookup position. More...
 
size_t binY (const Scalar y) const
 Returns the vertical bin that corresponds to a precise vertical lookup position. More...
 
size_t binTopLeftX (const size_t binX) const
 Returns the horizontal top left position of a specified bin with pixel accuracy. More...
 
size_t binTopLeftY (const size_t binY) const
 Returns the vertical top left position of a specified bin with pixel accuracy. More...
 
size_t binBottomRightX (const size_t binX) const
 Returns the horizontal bottom right position (including) of a specified bin with pixel accuracy. More...
 
size_t binBottomRightY (const size_t binY) const
 Returns the vertical bottom right position of a specified bin with pixel accuracy. More...
 
Scalar binCenterPositionX (const size_t binX) const
 Returns the horizontal center position of a specific bin in relation to the dimension of this lookup object. More...
 
Scalar binCenterPositionY (const size_t binY) const
 Returns the vertical center position of a specific bin in relation to the dimension of this lookup object. More...
 
Vector2 binCenterPosition (const size_t binX, const size_t binY) const
 Returns the center position of a specific bin in relation to the dimension of this lookup object. More...
 
const T & binCenterValue (const size_t binX, const size_t binY) const
 Returns the lookup value of a specific bin's center of this lookup object. More...
 
T & binCenterValue (const size_t binX, const size_t binY)
 Returns the lookup value of a specific bin's center of this lookup object. More...
 
nearestValue (const Scalar x, const Scalar y) const
 Applies a lookup for a specific position in this lookup object. More...
 
bilinearValue (const Scalar x, const Scalar y) const
 Applies a lookup for a specific position in this lookup object. More...
 
bicubicValue (const Scalar x, const Scalar y) const
 Applies a lookup for a specific position in this lookup object. More...
 
clampedNearestValue (const Scalar x, const Scalar y) const
 Applies a lookup for a specific position in this lookup object while the position is clamped to match into the domain of the lookup table. More...
 
clampedBilinearValue (const Scalar x, const Scalar y) const
 Applies a lookup for a specific position in this lookup object while the position is clamped to match into the domain of the lookup table. More...
 
clampedBicubicValue (const Scalar x, const Scalar y) const
 Applies a lookup for a specific position in this lookup object while the position is clamped to match into the domain of the lookup table. More...
 
void setBinCenterValue (const size_t binX, const size_t binY, const T &value)
 Sets the value of one specific lookup bin's center. More...
 
LookupCenter2< T, Scalar > & operator= (LookupCenter2< T, Scalar > &&lookup) noexcept
 Move operator. More...
 
- Public Member Functions inherited from Ocean::Lookup2< T, Scalar >
const T * data () const
 Returns a pointer to the constant bin data (row aligned). More...
 
T * data ()
 Returns a pointer to the bin data (row aligned). More...
 
size_t sizeX () const
 Returns the horizontal dimension of this lookup object. More...
 
size_t sizeY () const
 Returns the vertical dimension of this lookup object. More...
 
size_t binsX () const
 Returns the number of horizontal bins of this lookup object. More...
 
size_t binsY () const
 Returns the number of vertical bins of this lookup object. More...
 
bool isEmpty () const
 Returns whether this lookup object does not hold any lookup bin. More...
 
 operator bool () const
 Returns whether this lookup object holds at least one lookup bin. More...
 
bool operator== (const Lookup2< T, Scalar > &lookup) const
 Returns whether two lookup objects are identical. More...
 
bool operator!= (const Lookup2< T, Scalar > &lookup) const
 Returns whether two lookup objects are not identical. More...
 

Protected Types

typedef std::vector< unsigned char > ValidBins
 Definition of a vector holding 1 byte values. More...
 
- Protected Types inherited from Ocean::Lookup2< T, Scalar >
typedef std::vector< T > Values
 Definition of a vector holding lookup values. More...
 

Protected Attributes

ValidBins validBins_
 The vector individually storing whether a bin is valid or not. More...
 
- Protected Attributes inherited from Ocean::Lookup2< T, Scalar >
size_t sizeX_
 Horizontal dimension of this lookup object. More...
 
size_t sizeY_
 Vertical dimension of this lookup object. More...
 
size_t binsX_
 Number of horizontal bins. More...
 
size_t binsY_
 Number of vertical bins. More...
 
Scalar invSizeX_
 Inverse horizontal dimension of this lookup object. More...
 
Scalar invSizeY_
 Inverse vertical dimension of this lookup object. More...
 
Scalar invBinsX_
 Inverse number of horizontal bins. More...
 
Scalar invBinsY_
 Inverse number of vertical bins. More...
 
Values values_
 The values of the lookup bins. More...
 

Additional Inherited Members

- Public Types inherited from Ocean::Lookup2< T, Scalar >
typedef T Type
 Definition of the lookup data type. More...
 
- Protected Member Functions inherited from Ocean::Lookup2< T, Scalar >
 Lookup2 ()=default
 Creates a new empty lookup object. More...
 
 Lookup2 (const Lookup2< T, Scalar > &lookup)
 Copy constructor. More...
 
 Lookup2 (Lookup2< T, Scalar > &&lookup) noexcept
 Move constructor. More...
 
Lookup2< T, Scalar > & operator= (const Lookup2< T, Scalar > &lookup)
 Assign operator. More...
 
Lookup2< T, Scalar > & operator= (Lookup2< T, Scalar > &&lookup) noexcept
 Move operator. More...
 

Detailed Description

template<typename T, typename TScalar = Scalar>
class Ocean::AdvancedLookupCenter2< T, TScalar >

This class implements an advanced 2D lookup object with values at the bins' center positions defining the individual lookup values.

Further, this lookup object allows to define valid and invalid bins.
Invalid bins are not used for value interpolation.
The lookup table with e.g., 4x2 bins may have the following layout:

  ---   ---   ---   ---
|  x  |  ?  |  x  |  x  |
  ---   ---   ---   ---
|  ?  |  x  |  ?  |  x  |
  ---   ---   ---   ---

With 'x' showing valid center values and '?' showing invalid/undefined center values.
Thus, the lookup table has 4 horizontal bins and 4 horizontal lookup values.
All lookup values are located inside the specified size of the lookup object.
The vertical positions are accordingly.

Template Parameters
TThe data type of the stored lookup values
TScalarThe data type of the scalar values, either 'float' or 'double'
See also
LookupCorner2

Member Typedef Documentation

◆ ValidBins

template<typename T , typename TScalar = Scalar>
typedef std::vector<unsigned char> Ocean::AdvancedLookupCenter2< T, TScalar >::ValidBins
protected

Definition of a vector holding 1 byte values.

Constructor & Destructor Documentation

◆ AdvancedLookupCenter2() [1/7]

template<typename T , typename TScalar = Scalar>
Ocean::AdvancedLookupCenter2< T, TScalar >::AdvancedLookupCenter2 ( )
default

Creates a new empty lookup object.

◆ AdvancedLookupCenter2() [2/7]

template<typename T , typename TScalar >
Ocean::AdvancedLookupCenter2< T, TScalar >::AdvancedLookupCenter2 ( const AdvancedLookupCenter2< T, TScalar > &  lookup)
inline

Copy constructor.

Parameters
lookupThe lookup object to be copied

◆ AdvancedLookupCenter2() [3/7]

template<typename T , typename TScalar >
Ocean::AdvancedLookupCenter2< T, TScalar >::AdvancedLookupCenter2 ( AdvancedLookupCenter2< T, TScalar > &&  lookup)
inlinenoexcept

Move constructor.

Parameters
lookupThe lookup object to be moved

◆ AdvancedLookupCenter2() [4/7]

template<typename T , typename TScalar >
Ocean::AdvancedLookupCenter2< T, TScalar >::AdvancedLookupCenter2 ( const size_t  sizeX,
const size_t  sizeY,
const size_t  binsX,
const size_t  binsY 
)

Creates a new lookup object by definition of the dimensions and bin numbers.

All bins will be set as valid.
Beware: The bin values will be initialized with the default constructor of the template class.

Parameters
sizeXHorizontal dimension of the lookup table, with range [1, infinity)
sizeYVertical dimension of the lookup table, with range [1, infinity)
binsXNumber of horizontal bins, with range [1, sizeX]
binsYNumber of vertical bins, with range [1, sizeY]

◆ AdvancedLookupCenter2() [5/7]

template<typename T , typename TScalar >
Ocean::AdvancedLookupCenter2< T, TScalar >::AdvancedLookupCenter2 ( const size_t  sizeX,
const size_t  sizeY,
const size_t  binsX,
const size_t  binsY,
const bool  binsValid 
)

Creates a new lookup object by definition of the dimensions and bin numbers.

Parameters
sizeXHorizontal dimension of the lookup table, with range [1, infinity)
sizeYVertical dimension of the lookup table, with range [1, infinity)
binsXNumber of horizontal bins, with range [1, sizeX]
binsYNumber of vertical bins, with range [1, sizeY]
binsValidTrue, if all bins are valid; False, if all bins are invalid

◆ AdvancedLookupCenter2() [6/7]

template<typename T , typename TScalar >
Ocean::AdvancedLookupCenter2< T, TScalar >::AdvancedLookupCenter2 ( const size_t  sizeX,
const size_t  sizeY,
const size_t  binsX,
const size_t  binsY,
const T *  binValues,
const unsigned char *  validBins 
)

Creates a new lookup object by definition of the dimensions and bin numbers.

Parameters
sizeXHorizontal dimension of the lookup table, with range [1, infinity)
sizeYVertical dimension of the lookup table, with range [1, infinity)
binsXNumber of horizontal bins, with range [1, sizeX]
binsYNumber of vertical bins, with range [1, sizeY]
binValuesThe bin values of the lookup object (row aligned), binsX * binsY values must be provided
validBinsThe specification whether a bin is valid or not, a zero value specifies an invalid bin, a non-zero value specifies a valid bin

◆ AdvancedLookupCenter2() [7/7]

template<typename T , typename TScalar >
Ocean::AdvancedLookupCenter2< T, TScalar >::AdvancedLookupCenter2 ( const size_t  sizeX,
const size_t  sizeY,
const AdvancedLookupCenter2< T, TScalar > &  lookup 
)

Creates a new lookup object by definition of the dimensions and a given lookup object.

Parameters
sizeXHorizontal dimension of the lookup table, with range [1, infinity)
sizeYVertical dimension of the lookup table, with range [1, infinity)
lookupThe lookup object specifying the lookup values and the number of lookup bins

Member Function Documentation

◆ bilinearValue() [1/2]

template<typename T , typename TScalar >
bool Ocean::AdvancedLookupCenter2< T, TScalar >::bilinearValue ( const TScalar  x,
const TScalar  y,
const unsigned int  minimalValidBins,
T &  value 
) const

Applies a lookup for a specific position in this lookup object.

The resulting value is bilinear interpolated within the 4-neighborhood of valid lookup bins.
The interpolation result is based on valid bins only.

Parameters
xPrecise horizontal position for the resulting lookup value, with range [0, sizeX() - 1]
yPrecise vertical position for the resulting lookup value, with range [0, sizeY() - 1]
minimalValidBinsThe number of minimal valid neighboring/corresponding bins the specified position must have so that interpolation is done, with range [1, 4]
valueThe resulting interpolated value, if at least one corresponding bin is valid
Returns
True, if at least 'minimalValidBins' corresponding bin are valid

◆ bilinearValue() [2/2]

template<typename T , typename TScalar >
bool Ocean::AdvancedLookupCenter2< T, TScalar >::bilinearValue ( const TScalar  x,
const TScalar  y,
T &  value 
) const

Applies a lookup for a specific position in this lookup object.

The resulting value is bilinear interpolated within the 4-neighborhood of valid lookup bins.
The interpolation result is based on valid bins only.

Parameters
xPrecise horizontal position for the resulting lookup value, with range [0, sizeX() - 1]
yPrecise vertical position for the resulting lookup value, with range [0, sizeY() - 1]
valueThe resulting interpolated value, if at least one corresponding bin is valid
Returns
True, if at least one corresponding bin is valid

◆ binCenterValid()

template<typename T , typename TScalar >
bool Ocean::AdvancedLookupCenter2< T, TScalar >::binCenterValid ( const size_t  binX,
const size_t  binY 
) const
inline

Returns whether a specific bin of this lookup object is valid.

Parameters
binXHorizontal bin position, with range [0, binsX() - 1]
binYVertical bin position, with range [0, binsY() - 1]
Returns
True, if so

◆ clampedBilinearValue()

template<typename T , typename TScalar >
bool Ocean::AdvancedLookupCenter2< T, TScalar >::clampedBilinearValue ( const TScalar  x,
const TScalar  y,
T &  value 
) const

Applies a lookup for a specific position in this lookup object while the position is clamped to match into the domain of the lookup table.

The resulting value is bilinear interpolated within the 4-neighborhood of the lookup bins.

Parameters
xPrecise horizontal position for the resulting lookup value, with range -(infinity, infinity)
yPrecise vertical position for the resulting lookup value, with range -(infinity, infinity)
valueThe resulting interpolated value, if at least one corresponding bin is valid
Returns
True, if at least one corresponding bin is valid
See also
clampedNearestValue(), clampedBicubicValue(), bilinearValue().

◆ clampedNearestValue()

template<typename T , typename TScalar >
bool Ocean::AdvancedLookupCenter2< T, TScalar >::clampedNearestValue ( const TScalar  x,
const TScalar  y,
T &  value 
) const

Applies a lookup for a specific position in this lookup object while the position is clamped to match into the domain of the lookup table.

The resulting value is specified by the nearest bin (determined by the bin's corner positions).

Parameters
xPrecise horizontal position for the resulting lookup value, with range -(infinity, infinity)
yPrecise vertical position for the resulting lookup value, with range -(infinity, infinity)
valueThe resulting value, if the corresponding bin is valid
Returns
True, if the corresponding bin is valid
See also
clampedBilinearValue(), clampedBicubicValue(), nearestValue().

◆ nearestValue()

template<typename T , typename TScalar >
bool Ocean::AdvancedLookupCenter2< T, TScalar >::nearestValue ( const TScalar  x,
const TScalar  y,
T &  value 
) const

Applies a lookup for a specific position in this lookup object.

The resulting value is specified by the nearest bin (determined by the bin's center position).

Parameters
xPrecise horizontal position for the resulting lookup value, with range [0, sizeX() - 1]
yPrecise vertical position for the resulting lookup value, with range [0, sizeY() - 1]
valueThe resulting value, if the corresponding bin is valid
Returns
True, if the corresponding bin is valid

◆ operator!=()

template<typename T , typename TScalar >
bool Ocean::AdvancedLookupCenter2< T, TScalar >::operator!= ( const AdvancedLookupCenter2< T, TScalar > &  lookup) const
inline

Returns whether two lookup objects are not identical.

Parameters
lookupSecond lookup object
Returns
True, if so

◆ operator=()

template<typename T , typename TScalar >
AdvancedLookupCenter2< T, TScalar > & Ocean::AdvancedLookupCenter2< T, TScalar >::operator= ( AdvancedLookupCenter2< T, TScalar > &&  lookup)
noexcept

Move operator.

Parameters
lookupThe lookup object that will be moved
Returns
Reference to this object

◆ operator==()

template<typename T , typename TScalar >
bool Ocean::AdvancedLookupCenter2< T, TScalar >::operator== ( const AdvancedLookupCenter2< T, TScalar > &  lookup) const

Returns whether two lookup objects are identical.

Parameters
lookupSecond lookup object
Returns
True, if so

◆ setBinCenterValid()

template<typename T , typename TScalar >
void Ocean::AdvancedLookupCenter2< T, TScalar >::setBinCenterValid ( const size_t  binX,
const size_t  binY,
const bool  isValid 
)
inline

Sets whether a specific lookup bin is valid.

Parameters
binXHorizontal bin position, with range [0, binsX())
binYVertical bin position, with range [0, binsY())
isValidTrue, if the bin is valid; False, if the bin is invalid

◆ setBinCenterValue()

template<typename T , typename TScalar >
void Ocean::AdvancedLookupCenter2< T, TScalar >::setBinCenterValue ( const size_t  binX,
const size_t  binY,
const T &  value,
const bool  isValid 
)
inline

Sets the value of one specific lookup bin's center and defines whether this bin is valid.

Parameters
binXHorizontal bin position, with range [0, binsX())
binYVertical bin position, with range [0, binsY())
valueThe value to be set
isValidTrue, if the bin is valid; False, if the bin is invalid

Field Documentation

◆ validBins_

template<typename T , typename TScalar = Scalar>
ValidBins Ocean::AdvancedLookupCenter2< T, TScalar >::validBins_
protected

The vector individually storing whether a bin is valid or not.


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