Cuboid

Dependencies:   mbed

Revision:
21:cef093edb441
Parent:
0:15be70d21d7c
--- a/LinearCharacteristics.cpp	Tue Apr 10 12:25:13 2018 +0000
+++ b/LinearCharacteristics.cpp	Thu May 17 11:15:36 2018 +0000
@@ -2,35 +2,20 @@
 
 using namespace std;
 
-LinearCharacteristics::LinearCharacteristics(float k, float offset){
-    this->k = k;
-    this->offset = offset;
-    this->upper_limit = 9.99e19;
-    this->lower_limit = -9.99e19;
-    }
-LinearCharacteristics::LinearCharacteristics(float k, float offset,float lim){
-    this->k = k;
+LinearCharacteristics::LinearCharacteristics(float gain,float offset){    // standard lin characteristics
+    this->gain = gain;
     this->offset = offset;
-    this->upper_limit = lim;
-    this->lower_limit = -lim;
-    }
-LinearCharacteristics::LinearCharacteristics(float k, float offset,float ulim,float llim){
-    this->k = k;
-    this->offset = offset;
-    this->upper_limit = ulim;
-    this->lower_limit = llim;
-    }
+}
+
+LinearCharacteristics::LinearCharacteristics(float xmin,float xmax, float ymin, float ymax){    // standard lin characteristics
+    this->gain = (ymax - ymin)/(xmax - xmin);
+    this->offset = xmax - ymax/this->gain;
+}
+
+LinearCharacteristics::~LinearCharacteristics() {}
 
 
-LinearCharacteristics::~LinearCharacteristics() {} 
-    
-float LinearCharacteristics::eval(float u){
-    float val = k * (u-offset);
-    if(val > upper_limit)
-        return upper_limit;
-    else if(val < lower_limit)
-        return lower_limit;
-    else
-        return val;
+float LinearCharacteristics::evaluate(float x)
+{   
+return this->gain*(x - this->offset);
     }
-