Cube_Mini_Solution
Dependencies: mbed QEI MPU6050 BLE_API nRF51822 MCP4725 eMPL_MPU6050
LinearCharacteristics.cpp
- Committer:
- BoulusAJ
- Date:
- 2020-05-29
- Revision:
- 18:3b1aa67e11ca
- Parent:
- 0:8e87cdf07037
File content as of revision 18:3b1aa67e11ca:
#include "LinearCharacteristics.h" using namespace std; LinearCharacteristics::LinearCharacteristics(float gain,float offset){ // standard lin characteristics this->gain = gain; this->offset = offset; this->ulim = 999999.0; this->llim = -999999.0; } LinearCharacteristics::LinearCharacteristics(float xmin,float xmax, float ymin, float ymax){ // standard lin characteristics this->gain = (ymax - ymin)/(xmax - xmin); this->offset = xmax - ymax/this->gain; this->ulim = 999999.0; this->llim = -999999.0; } LinearCharacteristics::LinearCharacteristics(float xmin,float xmax, float ymin, float ymax,float ll, float ul){ // standard lin characteristics this->gain = (ymax - ymin)/(xmax - xmin); this->offset = xmax - ymax/this->gain; this->llim = ll; this->ulim = ul; } LinearCharacteristics::~LinearCharacteristics() {} float LinearCharacteristics::evaluate(float x) { float dum = this->gain*(x - this->offset); if(dum > this->ulim) dum = this->ulim; if(dum < this->llim) dum = this->llim; return dum; } void LinearCharacteristics::setup(float xmin,float xmax, float ymin, float ymax){ // standard lin characteristics this->gain = (ymax - ymin)/(xmax - xmin); this->offset = xmax - ymax/this->gain; this->ulim = 999999.0; this->llim = -999999.0; } void LinearCharacteristics::setup(float xmin,float xmax, float ymin, float ymax,float ll, float ul){ // standard lin characteristics this->gain = (ymax - ymin)/(xmax - xmin); this->offset = xmax - ymax/this->gain; this->llim = ll; this->ulim = ul; }