WarpTwin
Documentation for WarpTwin models and classes.
Loading...
Searching...
No Matches
warptwin::InterpolateTrilinear Class Reference

A class for performing simple a-b-c-d trilinear interpolation. More...

#include <InterpolateTrilinear.h>

Public Member Functions

int setData (const std::vector< double > &valuesA, const std::vector< double > &valuesB, const std::vector< double > &valuesC, const std::vector< double > &valuesD)
 Sets the data for the interpolator.
int getMinA (double &minA) const
 Returns the minimum value from the 1st column of stored data.
int getMaxA (double &maxA) const
 Returns the maximum value from the 1st column of stored data.
int getMinB (double &minB) const
 Returns the minimum value from the 2nd column of stored data.
int getMaxB (double &maxB) const
 Returns the maximum value from the 2nd column of stored data.
int getMinC (double &minC) const
 Returns the minimum value from the 3rd column of stored data.
int getMaxC (double &maxC) const
 Returns the maximum value from the 3rd column of stored data.
int interpolate (const double &a, const double &b, const double &c, double &interpolated_out)
 Performs trilinear interpolation given an (x, y) value pair.

Detailed Description

A class for performing simple a-b-c-d trilinear interpolation.

This class allows you to store tabulated a, b, c, and d values, and then to compute interpolated d values for any (a, b, c) within the bounds of the stored data. The trilinear interpolation is performed between successive data points.

Methodology:

  • Given three sets of points a[i], b[i], c[i] sorted in increasing order. A is held constant while B increases, and B is held constant while C increases. Once C has gone through its data points, B is increased and C starts over. For Example: A | B | C | D(outputs) 0 | 0 | 0 | 0 0 | 0 | 1 | 10 0 | 0 | 2 | 40 0 | 1 | 0 | 30 0 | 1 | 1 | 60 0 | 1 | 2 | 20 0 | 2 | 0 | 60 0 | 2 | 1 | 30 0 | 2 | 2 | 35 1 | 0 | 0 | 20 1 | 0 | 1 | 10 1 | 0 | 2 | 40 1 | 1 | 0 | 25 1 | 1 | 1 | 30 1 | 1 | 2 | 50 1 | 2 | 0 | 40 1 | 2 | 1 | 26 1 | 2 | 2 | 70 2 | 0 | 0 | 80 2 | 0 | 1 | 90 2 | 0 | 2 | 20 2 | 1 | 0 | 25 2 | 1 | 1 | 40 2 | 1 | 2 | 30 2 | 2 | 0 | 10 2 | 2 | 1 | 25 2 | 2 | 2 | 60

When inputting data, each column as seen above is input and reorganized into a 4d vector.

  • To interpolate at a point pair (a', b', c'), this code finds the 8 points: f000 = (a1, b1, c1), f001 = (a1, b1, c2), f010 = (a1, b1, c1), f011 = (a1, b2, c2), f100 = (a2, b1, c1), f101 = (a2, b1, c2), f110 = (a2, b2, c1), f111 = (a2, b2, c2) such that: a1 <= a' < a2, b1 <= b' < b2, and c1 <= c1 < c2 and interpolates between the three coordinate points. Error Handling:
  • The class returns integer error codes rather than using exceptions.
    • 0 indicates success
    • Any non-zero integer indicates an error
  • If interpolation is requested for (a, b, c) below the minimum a/b/c or above the maximum a/b/c, a non-zero error code is returned.

Author: William Burken will..nosp@m.burk.nosp@m.en@at.nosp@m.tx.t.nosp@m.ech

Member Function Documentation

◆ getMaxA()

int warptwin::InterpolateTrilinear::getMaxA ( double & maxA) const

Returns the maximum value from the 1st column of stored data.

Parameters
[out]maxAThe maximum value will be written here if the function succeeds.
Returns
Integer error code (0 for success, non-zero for error).

This function returns an error if there is no data stored.

◆ getMaxB()

int warptwin::InterpolateTrilinear::getMaxB ( double & maxB) const

Returns the maximum value from the 2nd column of stored data.

Parameters
[out]maxBThe maximum value will be written here if the function succeeds.
Returns
Integer error code (0 for success, non-zero for error).

This function returns an error if there is no data stored.

◆ getMaxC()

int warptwin::InterpolateTrilinear::getMaxC ( double & maxC) const

Returns the maximum value from the 3rd column of stored data.

Parameters
[out]maxCThe maximum value will be written here if the function succeeds.
Returns
Integer error code (0 for success, non-zero for error).

This function returns an error if there is no data stored.

◆ getMinA()

int warptwin::InterpolateTrilinear::getMinA ( double & minA) const

Returns the minimum value from the 1st column of stored data.

Parameters
[out]minAThe minimum value will be written here if the function succeeds.
Returns
Integer error code (0 for success, non-zero for error).

This function returns an error if there is no data stored.

◆ getMinB()

int warptwin::InterpolateTrilinear::getMinB ( double & minB) const

Returns the minimum value from the 2nd column of stored data.

Parameters
[out]minBThe minimum value will be written here if the function succeeds.
Returns
Integer error code (0 for success, non-zero for error).

This function returns an error if there is no data stored.

◆ getMinC()

int warptwin::InterpolateTrilinear::getMinC ( double & minC) const

Returns the minimum value from the 3rd column of stored data.

Parameters
[out]minCThe minimum value will be written here if the function succeeds.
Returns
Integer error code (0 for success, non-zero for error).

This function returns an error if there is no data stored.

◆ interpolate()

int warptwin::InterpolateTrilinear::interpolate ( const double & a,
const double & b,
const double & c,
double & interpolated_out )

Performs trilinear interpolation given an (x, y) value pair.

Parameters
[in]aThe column 1 value for which to interpolate.
[in]bThe column 2 value for which to interpolate.
[in]cThe column 3 value for which to interpolate.
[out]interpolated_outThe interpolated z-value will be written here if the function succeeds.
Returns
Integer error code (0 for success, non-zero for error).

If a, b, or c is out of the bounds of the stored table, this function returns a non-zero error code. If there are not enough points to perform interpolation, it returns a non-zero error code as well.

◆ setData()

int warptwin::InterpolateTrilinear::setData ( const std::vector< double > & valuesA,
const std::vector< double > & valuesB,
const std::vector< double > & valuesC,
const std::vector< double > & valuesD )

Sets the data for the interpolator.

Parameters
valuesAA vector of a-values (must be sorted in ascending order).
valuesBA vector of b-values (must be sorted in ascending order in region of static a).
valuesCA vector of c-values (must be sorted in ascending order in region of static b).
valuesDA vector of output values for each combination of a, b, and c values
Returns
An integer error code (0 for success, non-zero for error).

This function replaces any previously stored data with the new a, b, c, and output values. It is required that valuesA.size() == valuesB.size() == valuesC.size() == valuesD.size() It is also required that valuesA is sorted in ascending order and B/C are in order in the regions of static A/B, respectively. If these conditions are not met, a non-zero error code is returned.


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