Hi, I have some C# Code and i need to convert to titanium javascript using math function calculation. I am new for titanium development, I have given below C# code pls any one convert it to javascript and give it to me .
private void AddUpdateRecord()
{
int Id = 0;
if (hdneditId.Value != "")
Id = Convert.ToInt32(hdneditId.Value);
#region Calculation
double k1 = 0.0;
if (txtLFlatK1.Text != "")
k1 = Convert.ToDouble(txtLFlatK1.Text);
double axisOfK1_deg = 0.0;
if (txtLFlatK1Axis.Text != "")
axisOfK1_deg = Convert.ToDouble(txtLFlatK1Axis.Text);
double k2 = 0.0;
if (txtLSteepK2.Text != "")
k2 = Convert.ToDouble(txtLSteepK2.Text);
double axisOfK2_deg = 0.0;
if (txtLSteepK2Axis.Text != "")
axisOfK2_deg = Convert.ToDouble(txtLSteepK2Axis.Text);
int KNotation = (int)Common.KNotation.D;
if (k1 >= 6.75 && k1 <= 9.64)
{
k1 = 1000 * (1.336 - 1) / k1;
KNotation = (int)Common.KNotation.mm;
}
if (k2 >= 6.75 && k2 <= 9.64)
{
k2 = 1000 * (1.336 - 1) / k2;
KNotation = (int)Common.KNotation.mm;
}
double IOL = 10.0;
if (ddlIOLSperical.SelectedValue != "")
IOL = Convert.ToDouble(ddlIOLSperical.SelectedValue);
double M_SIA = 10.0;
if (txtLSIA.Text != "")
M_SIA = Convert.ToDouble(txtLSIA.Text);
double IL_deg = 0.0;
if (txtLAxis.Text != "")
IL_deg = Convert.ToDouble(txtLAxis.Text);
double POA = k2 - k1;
double axisofPOA_deg = axisOfK2_deg;
double SIA = M_SIA;
double axisofSIA_deg = IL_deg;
if (IL_deg > 90)
axisofSIA_deg = axisofSIA_deg - 90;
else if (IL_deg < 90)
axisofSIA_deg = axisofSIA_deg + 90;
// C1 = A1 @ Q1
double A1 = POA;
double Q1_deg = axisofPOA_deg;
// C2 = A2 @ Q2
double A2 = SIA;
double Q2_deg = axisofSIA_deg;
double Crx = A1 * Math.Cos(2 * DegreeToRadian(Q1_deg)) + A2 * Math.Cos(2 * DegreeToRadian(Q2_deg));
double Cry = A1 * Math.Sin(2 * DegreeToRadian(Q1_deg)) + A2 * Math.Sin(2 * DegreeToRadian(Q2_deg));
double CC = Math.Sqrt((Crx * Crx) + (Cry * Cry));
double axisofCC_deg = 0;
#region axisofCC
if (CC < 0)
{
axisofCC_deg = 0;
}
else
{
if (Crx < 0)
{
axisofCC_deg = 90 + 28.66 * Math.Atan(Cry / Crx);
}
else
{
if (Cry < 0)
{
axisofCC_deg = 180 + 28.66 * Math.Atan(Cry / Crx);
}
else
{
if (Crx < 0)
{
axisofCC_deg = 28.66 * Math.Atan(Cry / Crx);
}
else
{
if (Cry < 0)
{
axisofCC_deg = 28.66 * Math.Atan(Cry / Crx);
}
else
{
if (Crx > 0)
{
axisofCC_deg = 28.66 * Math.Atan(Cry / Crx);
}
else
{
if (Cry > 0)
{
axisofCC_deg = 28.66 * Math.Atan(Cry / Crx);
}
}
}
}
}
}
}
Thanks Advance
↧