enhanced functionality in V01 vs. V00, V02 finished, conversion to double precsision in V03

Dependencies:   mbed

LinearCharacteristics.cpp

Committer:
pmic
Date:
18 months ago
Revision:
22:c895fa4d7319
Parent:
0:15be70d21d7c

File content as of revision 22:c895fa4d7319:

#include "LinearCharacteristics.h"

using namespace std;

LinearCharacteristics::LinearCharacteristics(float k, float offset){
    this->k = k;
    this->offset = offset;
    this->upper_limit = 9.99e19;
    this->lower_limit = -9.99e19;
    }
LinearCharacteristics::LinearCharacteristics(float k, float offset,float lim){
    this->k = k;
    this->offset = offset;
    this->upper_limit = lim;
    this->lower_limit = -lim;
    }
LinearCharacteristics::LinearCharacteristics(float k, float offset,float ulim,float llim){
    this->k = k;
    this->offset = offset;
    this->upper_limit = ulim;
    this->lower_limit = llim;
    }


LinearCharacteristics::~LinearCharacteristics() {} 
    
float LinearCharacteristics::eval(float u){
    float val = k * (u-offset);
    if(val > upper_limit)
        return upper_limit;
    else if(val < lower_limit)
        return lower_limit;
    else
        return val;
    }