public void HumTempCalcByCoordinate()
{
//this is not working properly why i dont know...
var results = chart1.HitTest(xCoord, yCoord, false, ChartElementType.PlottingArea);
foreach (var result in results)
{
if (result.ChartElementType == ChartElementType.PlottingArea)
{
// double xVal = xCoord - chart1.ChartAreas[0].Position.X ;
//double yVal = yCoord-chart1.ChartAreas[0].Position.Y;
var xVal = result.ChartArea.AxisX.PixelPositionToValue(xCoord);
var yVal = result.ChartArea.AxisY.PixelPositionToValue(yCoord);
/*
we need to calc phi value given by ycord/30 as the max value is 30..
* second pg which is calculated by temperature pulled from the text file we need to fist
* calculate the round up value of x coord to an integer...
*/
//this part is not correct yet we need to do this again....
double phi = 0.00000;
//double y_axis = yVal;
//now for pg..
ArrayList temperature_value = new ArrayList();
ArrayList pg_value_from_txtfile = new ArrayList();
temperature_value = t;
pg_value_from_txtfile = pg;
double temperature = (double)Math.Round((double)xVal);
double corres_pg_value = 0.000000;
for (int i = 0; i < temperature_value.Count; i++)
{
if (temperature == Double.Parse(temperature_value[i].ToString()))
{
corres_pg_value = Double.Parse(pg_value_from_txtfile[i].ToString());
break;
}
}//close of for
double patm = form1Object.AirPressureFromDB * 0.001;// in kpa//101.325;//this is constant...
// double w = 622*phi*corres_pg_value/(patm-phi*corres_pg_value);
//double w1 = 622*phi*pg/(patm-phi*pg);
double w = yVal;
phi = w * patm / (622 * corres_pg_value + w * corres_pg_value);//this phi gives the relative humidty..
phi = phi * 100;//changing into percent..
//now lets calculate the dew point...
double humidity = phi;
double temperature1 = xVal;
humidityValue = humidity;
temperatureValue = temperature1;
}
}
}