Libraries/AP_Math/AP_Math.cpp
/*
 * linear interpolation based on a variable in a range
 */
linear interpolation based on a variable in a range
linear interpolation based on a variable in a range
float linear_interpolate(float low_output, float high_output,
                         float var_value,
                         float var_low, float var_high)
{
    if (var_value <= var_low) {
        return low_output;
    }
    if (var_value >= var_high) {
        return high_output;
    }
    float p = (var_value - var_low) / (var_high - var_low);
    return low_output + p * (high_output - low_output);
}
float linear_interpolate ( float low_output , float high_output , float var_value , float var_low , float var_high ) { if ( var_value <= var_low ) { return low_output ; } if ( var_value >= var_high ) { return high_output ; } float p = ( var_value - var_low ) / ( var_high - var_low ) ; return low_output + p * ( high_output - low_output ) ; }
linear interpolation based on a variable in a range
linear interpolation based on a variable in a range