Suppose we have a set of points that represent the thrust vs. time function of an Estes E9 model rocket engine as shown below, and we want to be able to estimate the thrust for times anywhere between the minimum and maximum sample times.
![](images/Estes_E9.png)
Since these points represent thrust as a function of time, time is the independent variable.
The values of the independent variable where points have been sampled are called **breakpoints**.
### Setting Up Data for the Interpolator
```
/* Number of independent Variables. [Constructor Arg#4] */
unsigned int break_point_array_sizes[E9_INDEPENDENT_VAR_COUNT] = { E9_BP_SIZE };
```
### Constructing the Interpolator
Using the data structures from above, we can construct an interpolator.
```
Trick::Interpolator* motor_thrust_interpolator =
new Trick::Interpolator( E9_thrust_array,
break_point_arrays,
break_point_array_sizes,
E9_INDEPENDENT_VAR_COUNT);
```
### Using the Interpolator
To use the interpolator, we simply call the **```eval()```** member function as follows, assuming that ```time``` and ```thrust``` are of type ```double```.
```
try {
thrust = motor_thrust_interpolator->eval( time );
} catch (std::logic_error e) {
thrust = 0.0;
}
```
---
## Two Independent Variable Example
Suppose we have a table of body-mass-index (BMI) values that have been sampled at each of the heights and weights as shown below, and that we want to estimate BMI between where the samples were measured. For example: What's the BMI for 1.82 meters, and 67 kg?
![](images/bmi.png)
In this situation we have two independent variables. Therefore we have two breakpoint arrays, one for weight, and one for height. The size of the weight, and weight breakpoint sets (arrays) are 13, and 6 respectively.
```
/* Number of independent Variables. [Constructor Arg#4] */
#define BMI_INDEPENDENT_VAR_COUNT 2
/* Number of elements in the weight breakpoint array */
#define WEIGHT_BP_SIZE 13
/* Number of elements in the height breakpoint array */
To use the interpolator, we simply call the **```eval()```** member function as follows, assuming that ```bmi```, ```weight```, and ```height``` are of type ```double```.