private double calculateNewScanCentre(ScanParameters scanParameters, double[] fitCoefficients)
{
double newCentroid = new double();
if (fitCoefficients[1] - scanWidth > LOWER_CC_VOLTAGE_LIMIT
&& fitCoefficients[1] + scanWidth < UPPER_CC_VOLTAGE_LIMIT
&& fitCoefficients[1] < scanParameters.High
&& fitCoefficients[1] > scanParameters.Low) //Only change limits if fits are reasonable.
{
newCentroid = fitCoefficients[1];
}
else
{
newCentroid = scanParameters.High - scanWidth;
}
Console.WriteLine(newCentroid);
return newCentroid;
}