OptoMMP3
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties
Opto22.Linearization.Linear Class Reference

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

Public Member Functions

Boolean 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
Boolean 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 sea level
dDegreesF = 212.0;
dDegreesC = linear.Compute(dDegreesF);
Console.WriteLine("Boiling temperature {0} F is {1} in C", dDegreesF, dDegreesC.ToString("F1"));

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

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.
Boolean 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 dInput1, dInput2, dOutput1 and dOutput2.

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: