Miscellaneous Library, read Encoder etc.

Dependents:   My_Libraries

Committer:
altb
Date:
Mon Mar 04 11:03:51 2019 +0000
Revision:
0:3312872854c4
New Lib Folder

Who changed what in which revision?

UserRevisionLine numberNew contents of line
altb 0:3312872854c4 1 #include "LinearCharacteristics.h"
altb 0:3312872854c4 2
altb 0:3312872854c4 3 using namespace std;
altb 0:3312872854c4 4
altb 0:3312872854c4 5 LinearCharacteristics::LinearCharacteristics(float gain,float offset){ // standard lin characteristics
altb 0:3312872854c4 6 this->gain = gain;
altb 0:3312872854c4 7 this->offset = offset;
altb 0:3312872854c4 8 }
altb 0:3312872854c4 9
altb 0:3312872854c4 10 LinearCharacteristics::LinearCharacteristics(float xmin,float xmax, float ymin, float ymax){ // standard lin characteristics
altb 0:3312872854c4 11 this->gain = (ymax - ymin)/(xmax - xmin);
altb 0:3312872854c4 12 this->offset = xmax - ymax/this->gain;
altb 0:3312872854c4 13 this->ulim = 999999.0;
altb 0:3312872854c4 14 this->llim = -999999.0;
altb 0:3312872854c4 15
altb 0:3312872854c4 16 }
altb 0:3312872854c4 17 LinearCharacteristics::LinearCharacteristics(float xmin,float xmax, float ymin, float ymax,float ll, float ul){ // standard lin characteristics
altb 0:3312872854c4 18 this->gain = (ymax - ymin)/(xmax - xmin);
altb 0:3312872854c4 19 this->offset = xmax - ymax/this->gain;
altb 0:3312872854c4 20 this->llim = ll;
altb 0:3312872854c4 21 this->ulim = ul;
altb 0:3312872854c4 22
altb 0:3312872854c4 23 }
altb 0:3312872854c4 24
altb 0:3312872854c4 25 LinearCharacteristics::~LinearCharacteristics() {}
altb 0:3312872854c4 26
altb 0:3312872854c4 27
altb 0:3312872854c4 28 float LinearCharacteristics::evaluate(float x)
altb 0:3312872854c4 29 {
altb 0:3312872854c4 30 float dum = this->gain*(x - this->offset);
altb 0:3312872854c4 31 if(dum > this->ulim)
altb 0:3312872854c4 32 dum = this->ulim;
altb 0:3312872854c4 33 if(dum < this->llim)
altb 0:3312872854c4 34 dum = this->llim;
altb 0:3312872854c4 35 return dum;
altb 0:3312872854c4 36 }
altb 0:3312872854c4 37
altb 0:3312872854c4 38 void LinearCharacteristics::setup(float xmin,float xmax, float ymin, float ymax){ // standard lin characteristics
altb 0:3312872854c4 39 this->gain = (ymax - ymin)/(xmax - xmin);
altb 0:3312872854c4 40 this->offset = xmax - ymax/this->gain;
altb 0:3312872854c4 41 this->ulim = 999999.0;
altb 0:3312872854c4 42 this->llim = -999999.0;
altb 0:3312872854c4 43 }
altb 0:3312872854c4 44 void LinearCharacteristics::setup(float xmin,float xmax, float ymin, float ymax,float ll, float ul){ // standard lin characteristics
altb 0:3312872854c4 45 this->gain = (ymax - ymin)/(xmax - xmin);
altb 0:3312872854c4 46 this->offset = xmax - ymax/this->gain;
altb 0:3312872854c4 47 this->llim = ll;
altb 0:3312872854c4 48 this->ulim = ul;
altb 0:3312872854c4 49 }