branch for cuboid
LinearCharacteristics.cpp@0:72b60c5271cc, 2019-03-07 (annotated)
- Committer:
- altb2
- Date:
- Thu Mar 07 07:03:44 2019 +0000
- Revision:
- 0:72b60c5271cc
- Child:
- 1:dd5d116ace8f
System running
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 | 0:72b60c5271cc | 8 | } |
altb2 | 0:72b60c5271cc | 9 | |
altb2 | 0:72b60c5271cc | 10 | LinearCharacteristics::LinearCharacteristics(float xmin,float xmax, float ymin, float ymax){ // standard lin characteristics |
altb2 | 0:72b60c5271cc | 11 | this->gain = (ymax - ymin)/(xmax - xmin); |
altb2 | 0:72b60c5271cc | 12 | this->offset = xmax - ymax/this->gain; |
altb2 | 0:72b60c5271cc | 13 | this->ulim = 999999.0; |
altb2 | 0:72b60c5271cc | 14 | this->llim = -999999.0; |
altb2 | 0:72b60c5271cc | 15 | |
altb2 | 0:72b60c5271cc | 16 | } |
altb2 | 0:72b60c5271cc | 17 | LinearCharacteristics::LinearCharacteristics(float xmin,float xmax, float ymin, float ymax,float ll, float ul){ // standard lin characteristics |
altb2 | 0:72b60c5271cc | 18 | this->gain = (ymax - ymin)/(xmax - xmin); |
altb2 | 0:72b60c5271cc | 19 | this->offset = xmax - ymax/this->gain; |
altb2 | 0:72b60c5271cc | 20 | this->llim = ll; |
altb2 | 0:72b60c5271cc | 21 | this->ulim = ul; |
altb2 | 0:72b60c5271cc | 22 | |
altb2 | 0:72b60c5271cc | 23 | } |
altb2 | 0:72b60c5271cc | 24 | |
altb2 | 0:72b60c5271cc | 25 | LinearCharacteristics::~LinearCharacteristics() {} |
altb2 | 0:72b60c5271cc | 26 | |
altb2 | 0:72b60c5271cc | 27 | |
altb2 | 0:72b60c5271cc | 28 | float LinearCharacteristics::evaluate(float x) |
altb2 | 0:72b60c5271cc | 29 | { |
altb2 | 0:72b60c5271cc | 30 | float dum = this->gain*(x - this->offset); |
altb2 | 0:72b60c5271cc | 31 | if(dum > this->ulim) |
altb2 | 0:72b60c5271cc | 32 | dum = this->ulim; |
altb2 | 0:72b60c5271cc | 33 | if(dum < this->llim) |
altb2 | 0:72b60c5271cc | 34 | dum = this->llim; |
altb2 | 0:72b60c5271cc | 35 | return dum; |
altb2 | 0:72b60c5271cc | 36 | } |
altb2 | 0:72b60c5271cc | 37 | |
altb2 | 0:72b60c5271cc | 38 | void LinearCharacteristics::setup(float xmin,float xmax, float ymin, float ymax){ // standard lin characteristics |
altb2 | 0:72b60c5271cc | 39 | this->gain = (ymax - ymin)/(xmax - xmin); |
altb2 | 0:72b60c5271cc | 40 | this->offset = xmax - ymax/this->gain; |
altb2 | 0:72b60c5271cc | 41 | this->ulim = 999999.0; |
altb2 | 0:72b60c5271cc | 42 | this->llim = -999999.0; |
altb2 | 0:72b60c5271cc | 43 | } |
altb2 | 0:72b60c5271cc | 44 | void LinearCharacteristics::setup(float xmin,float xmax, float ymin, float ymax,float ll, float ul){ // standard lin characteristics |
altb2 | 0:72b60c5271cc | 45 | this->gain = (ymax - ymin)/(xmax - xmin); |
altb2 | 0:72b60c5271cc | 46 | this->offset = xmax - ymax/this->gain; |
altb2 | 0:72b60c5271cc | 47 | this->llim = ll; |
altb2 | 0:72b60c5271cc | 48 | this->ulim = ul; |
altb2 | 0:72b60c5271cc | 49 | } |
altb2 | 0:72b60c5271cc | 50 |