Lib_Misc

Dependents:   IndNav_QK3_T265

Committer:
altb2
Date:
Fri Jan 10 16:01:33 2020 +0000
Revision:
14:d5f47a30ef19
Parent:
3:379208083c74
Small changes in double2float

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
altb2 3:379208083c74 38 void LinearCharacteristics::setup(float gain,float offset){ // standard lin characteristics
altb2 3:379208083c74 39 this->gain = gain;
altb2 3:379208083c74 40 this->offset = offset;
altb2 3:379208083c74 41 this->ulim = 999999.0;
altb2 3:379208083c74 42 this->llim = -999999.0;
altb2 3:379208083c74 43 }
altb 0:3312872854c4 44 void LinearCharacteristics::setup(float xmin,float xmax, float ymin, float ymax){ // 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->ulim = 999999.0;
altb 0:3312872854c4 48 this->llim = -999999.0;
altb 0:3312872854c4 49 }
altb 0:3312872854c4 50 void LinearCharacteristics::setup(float xmin,float xmax, float ymin, float ymax,float ll, float ul){ // standard lin characteristics
altb 0:3312872854c4 51 this->gain = (ymax - ymin)/(xmax - xmin);
altb 0:3312872854c4 52 this->offset = xmax - ymax/this->gain;
altb 0:3312872854c4 53 this->llim = ll;
altb 0:3312872854c4 54 this->ulim = ul;
altb 0:3312872854c4 55 }