2nd try
LinearCharacteristics.cpp@1:dd5d116ace8f, 2019-03-07 (annotated)
- Committer:
- altb2
- Date:
- Thu Mar 07 09:16:03 2019 +0000
- Revision:
- 1:dd5d116ace8f
- Parent:
- 0:72b60c5271cc
- Child:
- 2:8706bb4e8f93
corrected LinChar
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
altb2 | 0:72b60c5271cc | 1 | #include "LinearCharacteristics.h" |
altb2 | 0:72b60c5271cc | 2 | |
altb2 | 0:72b60c5271cc | 3 | using namespace std; |
altb2 | 0:72b60c5271cc | 4 | |
altb2 | 0:72b60c5271cc | 5 | LinearCharacteristics::LinearCharacteristics(float gain,float offset){ // standard lin characteristics |
altb2 | 0:72b60c5271cc | 6 | this->gain = gain; |
altb2 | 0:72b60c5271cc | 7 | this->offset = offset; |
altb2 | 1:dd5d116ace8f | 8 | this->ulim = 999999.0; |
altb2 | 1:dd5d116ace8f | 9 | this->llim = -999999.0; |
altb2 | 0:72b60c5271cc | 10 | } |
altb2 | 0:72b60c5271cc | 11 | |
altb2 | 0:72b60c5271cc | 12 | LinearCharacteristics::LinearCharacteristics(float xmin,float xmax, float ymin, float ymax){ // standard lin characteristics |
altb2 | 0:72b60c5271cc | 13 | this->gain = (ymax - ymin)/(xmax - xmin); |
altb2 | 0:72b60c5271cc | 14 | this->offset = xmax - ymax/this->gain; |
altb2 | 0:72b60c5271cc | 15 | this->ulim = 999999.0; |
altb2 | 0:72b60c5271cc | 16 | this->llim = -999999.0; |
altb2 | 0:72b60c5271cc | 17 | |
altb2 | 0:72b60c5271cc | 18 | } |
altb2 | 0:72b60c5271cc | 19 | LinearCharacteristics::LinearCharacteristics(float xmin,float xmax, float ymin, float ymax,float ll, float ul){ // standard lin characteristics |
altb2 | 0:72b60c5271cc | 20 | this->gain = (ymax - ymin)/(xmax - xmin); |
altb2 | 0:72b60c5271cc | 21 | this->offset = xmax - ymax/this->gain; |
altb2 | 0:72b60c5271cc | 22 | this->llim = ll; |
altb2 | 0:72b60c5271cc | 23 | this->ulim = ul; |
altb2 | 0:72b60c5271cc | 24 | |
altb2 | 0:72b60c5271cc | 25 | } |
altb2 | 0:72b60c5271cc | 26 | |
altb2 | 0:72b60c5271cc | 27 | LinearCharacteristics::~LinearCharacteristics() {} |
altb2 | 0:72b60c5271cc | 28 | |
altb2 | 0:72b60c5271cc | 29 | |
altb2 | 0:72b60c5271cc | 30 | float LinearCharacteristics::evaluate(float x) |
altb2 | 0:72b60c5271cc | 31 | { |
altb2 | 0:72b60c5271cc | 32 | float dum = this->gain*(x - this->offset); |
altb2 | 0:72b60c5271cc | 33 | if(dum > this->ulim) |
altb2 | 0:72b60c5271cc | 34 | dum = this->ulim; |
altb2 | 0:72b60c5271cc | 35 | if(dum < this->llim) |
altb2 | 0:72b60c5271cc | 36 | dum = this->llim; |
altb2 | 0:72b60c5271cc | 37 | return dum; |
altb2 | 0:72b60c5271cc | 38 | } |
altb2 | 0:72b60c5271cc | 39 | |
altb2 | 0:72b60c5271cc | 40 | void LinearCharacteristics::setup(float xmin,float xmax, float ymin, float ymax){ // standard lin characteristics |
altb2 | 0:72b60c5271cc | 41 | this->gain = (ymax - ymin)/(xmax - xmin); |
altb2 | 0:72b60c5271cc | 42 | this->offset = xmax - ymax/this->gain; |
altb2 | 0:72b60c5271cc | 43 | this->ulim = 999999.0; |
altb2 | 0:72b60c5271cc | 44 | this->llim = -999999.0; |
altb2 | 0:72b60c5271cc | 45 | } |
altb2 | 0:72b60c5271cc | 46 | void LinearCharacteristics::setup(float xmin,float xmax, float ymin, float ymax,float ll, float ul){ // standard lin characteristics |
altb2 | 0:72b60c5271cc | 47 | this->gain = (ymax - ymin)/(xmax - xmin); |
altb2 | 0:72b60c5271cc | 48 | this->offset = xmax - ymax/this->gain; |
altb2 | 0:72b60c5271cc | 49 | this->llim = ll; |
altb2 | 0:72b60c5271cc | 50 | this->ulim = ul; |
altb2 | 0:72b60c5271cc | 51 | } |
altb2 | 0:72b60c5271cc | 52 |