Version: SMASH-3.4
smash::InterpolateLinear< T > Class Template Reference

#include <interpolation.h>

template<typename T>
class smash::InterpolateLinear< T >

Represent a linear interpolation.

Parameters
TType of interpolated values.

Definition at line 37 of file interpolation.h.

Collaboration diagram for smash::InterpolateLinear< T >:
[legend]

Public Member Functions

 InterpolateLinear (T x0, T y0, T x1, T y1)
 Linear interpolation given two points (x0, y0) and (x1, y1). More...
 
operator() (T x) const
 Calculate linear interpolation at x. More...
 

Private Attributes

slope_ {}
 Slope of the linear interpolation. More...
 
yintercept_ {}
 y-axis intercept of the linear interpolation. More...
 

Constructor & Destructor Documentation

◆ InterpolateLinear()

template<typename T >
smash::InterpolateLinear< T >::InterpolateLinear ( x0,
y0,
x1,
y1 
)

Linear interpolation given two points (x0, y0) and (x1, y1).

Returns
The interpolation function.

Definition at line 115 of file interpolation.h.

115  {
116  assert(x0 != x1);
117  slope_ = (y1 - y0) / (x1 - x0);
118  yintercept_ = y0 - slope_ * x0;
119 }
T yintercept_
y-axis intercept of the linear interpolation.
Definition: interpolation.h:58
T slope_
Slope of the linear interpolation.
Definition: interpolation.h:56

Member Function Documentation

◆ operator()()

template<typename T >
T smash::InterpolateLinear< T >::operator() ( x) const

Calculate linear interpolation at x.

Parameters
xInterpolation argument.
Returns
Interpolated value.

Definition at line 122 of file interpolation.h.

122  {
123  return slope_ * x + yintercept_;
124 }

Member Data Documentation

◆ slope_

template<typename T >
T smash::InterpolateLinear< T >::slope_ {}
private

Slope of the linear interpolation.

Definition at line 56 of file interpolation.h.

◆ yintercept_

template<typename T >
T smash::InterpolateLinear< T >::yintercept_ {}
private

y-axis intercept of the linear interpolation.

Definition at line 58 of file interpolation.h.


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