![](/media/cache/profiles/altb_JGUSAOG.jpg.50x50_q85.jpg)
Simple program for introduction of mirror actuator.
LinearCharacteristics.cpp@0:a56e9c932891, 2019-03-07 (annotated)
- Committer:
- altb2
- Date:
- Thu Mar 07 06:52:26 2019 +0000
- Revision:
- 0:a56e9c932891
Redesign, no Libs
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
altb2 | 0:a56e9c932891 | 1 | #include "LinearCharacteristics.h" |
altb2 | 0:a56e9c932891 | 2 | |
altb2 | 0:a56e9c932891 | 3 | using namespace std; |
altb2 | 0:a56e9c932891 | 4 | |
altb2 | 0:a56e9c932891 | 5 | LinearCharacteristics::LinearCharacteristics(float gain,float offset){ // standard lin characteristics |
altb2 | 0:a56e9c932891 | 6 | this->gain = gain; |
altb2 | 0:a56e9c932891 | 7 | this->offset = offset; |
altb2 | 0:a56e9c932891 | 8 | } |
altb2 | 0:a56e9c932891 | 9 | |
altb2 | 0:a56e9c932891 | 10 | LinearCharacteristics::LinearCharacteristics(float xmin,float xmax, float ymin, float ymax){ // standard lin characteristics |
altb2 | 0:a56e9c932891 | 11 | this->gain = (ymax - ymin)/(xmax - xmin); |
altb2 | 0:a56e9c932891 | 12 | this->offset = xmax - ymax/this->gain; |
altb2 | 0:a56e9c932891 | 13 | this->ulim = 999999.0; |
altb2 | 0:a56e9c932891 | 14 | this->llim = -999999.0; |
altb2 | 0:a56e9c932891 | 15 | |
altb2 | 0:a56e9c932891 | 16 | } |
altb2 | 0:a56e9c932891 | 17 | LinearCharacteristics::LinearCharacteristics(float xmin,float xmax, float ymin, float ymax,float ll, float ul){ // standard lin characteristics |
altb2 | 0:a56e9c932891 | 18 | this->gain = (ymax - ymin)/(xmax - xmin); |
altb2 | 0:a56e9c932891 | 19 | this->offset = xmax - ymax/this->gain; |
altb2 | 0:a56e9c932891 | 20 | this->llim = ll; |
altb2 | 0:a56e9c932891 | 21 | this->ulim = ul; |
altb2 | 0:a56e9c932891 | 22 | |
altb2 | 0:a56e9c932891 | 23 | } |
altb2 | 0:a56e9c932891 | 24 | |
altb2 | 0:a56e9c932891 | 25 | LinearCharacteristics::~LinearCharacteristics() {} |
altb2 | 0:a56e9c932891 | 26 | |
altb2 | 0:a56e9c932891 | 27 | |
altb2 | 0:a56e9c932891 | 28 | float LinearCharacteristics::evaluate(float x) |
altb2 | 0:a56e9c932891 | 29 | { |
altb2 | 0:a56e9c932891 | 30 | float dum = this->gain*(x - this->offset); |
altb2 | 0:a56e9c932891 | 31 | if(dum > this->ulim) |
altb2 | 0:a56e9c932891 | 32 | dum = this->ulim; |
altb2 | 0:a56e9c932891 | 33 | if(dum < this->llim) |
altb2 | 0:a56e9c932891 | 34 | dum = this->llim; |
altb2 | 0:a56e9c932891 | 35 | return dum; |
altb2 | 0:a56e9c932891 | 36 | } |
altb2 | 0:a56e9c932891 | 37 | |
altb2 | 0:a56e9c932891 | 38 | void LinearCharacteristics::setup(float xmin,float xmax, float ymin, float ymax){ // standard lin characteristics |
altb2 | 0:a56e9c932891 | 39 | this->gain = (ymax - ymin)/(xmax - xmin); |
altb2 | 0:a56e9c932891 | 40 | this->offset = xmax - ymax/this->gain; |
altb2 | 0:a56e9c932891 | 41 | this->ulim = 999999.0; |
altb2 | 0:a56e9c932891 | 42 | this->llim = -999999.0; |
altb2 | 0:a56e9c932891 | 43 | } |
altb2 | 0:a56e9c932891 | 44 | void LinearCharacteristics::setup(float xmin,float xmax, float ymin, float ymax,float ll, float ul){ // standard lin characteristics |
altb2 | 0:a56e9c932891 | 45 | this->gain = (ymax - ymin)/(xmax - xmin); |
altb2 | 0:a56e9c932891 | 46 | this->offset = xmax - ymax/this->gain; |
altb2 | 0:a56e9c932891 | 47 | this->llim = ll; |
altb2 | 0:a56e9c932891 | 48 | this->ulim = ul; |
altb2 | 0:a56e9c932891 | 49 | } |
altb2 | 0:a56e9c932891 | 50 |