branch for cuboid
LinearCharacteristics.cpp@3:b23f59513a90, 2019-11-22 (annotated)
- Committer:
- altb2
- Date:
- Fri Nov 22 16:44:35 2019 +0000
- Revision:
- 3:b23f59513a90
- Parent:
- 2:8706bb4e8f93
Some changes in lib
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 | 2:8706bb4e8f93 | 40 | void LinearCharacteristics::setup(float gain,float offset){ // standard lin characteristics |
altb2 | 2:8706bb4e8f93 | 41 | this->gain = gain; |
altb2 | 2:8706bb4e8f93 | 42 | this->offset = offset; |
altb2 | 2:8706bb4e8f93 | 43 | this->ulim = 999999.0; |
altb2 | 2:8706bb4e8f93 | 44 | this->llim = -999999.0; |
altb2 | 2:8706bb4e8f93 | 45 | } |
altb2 | 2:8706bb4e8f93 | 46 | |
altb2 | 0:72b60c5271cc | 47 | void LinearCharacteristics::setup(float xmin,float xmax, float ymin, float ymax){ // standard lin characteristics |
altb2 | 0:72b60c5271cc | 48 | this->gain = (ymax - ymin)/(xmax - xmin); |
altb2 | 0:72b60c5271cc | 49 | this->offset = xmax - ymax/this->gain; |
altb2 | 0:72b60c5271cc | 50 | this->ulim = 999999.0; |
altb2 | 0:72b60c5271cc | 51 | this->llim = -999999.0; |
altb2 | 0:72b60c5271cc | 52 | } |
altb2 | 0:72b60c5271cc | 53 | void LinearCharacteristics::setup(float xmin,float xmax, float ymin, float ymax,float ll, float ul){ // standard lin characteristics |
altb2 | 0:72b60c5271cc | 54 | this->gain = (ymax - ymin)/(xmax - xmin); |
altb2 | 0:72b60c5271cc | 55 | this->offset = xmax - ymax/this->gain; |
altb2 | 0:72b60c5271cc | 56 | this->llim = ll; |
altb2 | 0:72b60c5271cc | 57 | this->ulim = ul; |
altb2 | 0:72b60c5271cc | 58 | } |
altb2 | 0:72b60c5271cc | 59 |