OptoMMP2
Opto22.Linearization.Linear Class Reference

Linear scaling object. This is the "good ole" y = m * x + b equation. More...

Public Member Functions

 Linear ()
 Constructor More...
 
bool SetEquation (double dInput1, double dOutput1, double dInput2, double dOutput2)
 Set the parameters of this object. More...
 
double Compute (double dInput)
 Compute the output More...
 

Detailed Description

Linear scaling object. This is the "good ole" y = m * x + b equation.

(C#) Linear linear = new Linear();

// set linear to convert temperature F to C bool bResult = linear.SetEquation(32.0, 0.0, 212.0, 100.0);

double dDegreesF; double dDegreesC;

// freezing point dDegreesF = 32.0; dDegreesC = linear.Compute(dDegreesF); Console.WriteLine("Freezing temperature {0} F is {1} in C", dDegreesF, dDegreesC.ToString("F1"));

// a typical Temecula summer day dDegreesF = 102.0; dDegreesC = linear.Compute(dDegreesF); Console.WriteLine("Temecula temperature {0} F is {1} in C", dDegreesF, dDegreesC.ToString("F1"));

// boiling point of water at sealevel dDegreesF = 212.0; dDegreesC = linear.Compute(dDegreesF); Console.WriteLine("Boiling temperature {0} F is {1} in C", dDegreesF, dDegreesC.ToString("F1"));

// where the two lines cross each other dDegreesF = -40.0; dDegreesC = linear.Compute(dDegreesF); Console.WriteLine("Cross temperature {0} F is {1} in C", dDegreesF, dDegreesC.ToString("F1"));

Constructor & Destructor Documentation

Opto22.Linearization.Linear.Linear ( )

Constructor

Member Function Documentation

double Opto22.Linearization.Linear.Compute ( double  dInput)

Compute the output

Parameters
dInputInput to compute.
Returns
The output if the parameters are properly set using SetEquation() or double.Nan if not.
bool Opto22.Linearization.Linear.SetEquation ( double  dInput1,
double  dOutput1,
double  dInput2,
double  dOutput2 
)

Set the parameters of this object.

Two points of a linear line are required to set the equation parameters. We call these points P1 and P2; with input and output values of Input1, Input2, Output1 and Output2.

Parameters
dInput1The input for point P1.
dOutput1The output for point P1.
dInput2The input for point P2.
dOutput2The output for point P2.
Returns
True if the method was successful, false if not (because dInput1 and dInput2 are the same value. If this is not checked, it will result in a divide-by-zero exception.

The documentation for this class was generated from the following file: