private void button1_Click(object sender, EventArgs e) { double DrLong = CelestialTool.ConvertInput(maskedTextBox1.Text); int localTimeZone = int.Parse(numericUpDown1.Text); DateTime timeOfMeridianPassageAlmanac = DateTime.Parse(maskedTextBox2.Text); double timeToArc = DrLong / 15; double timeToArcHours = Math.Floor(timeToArc); double timeToArcMinutes = (timeToArc - timeToArcHours) * 60; DateTime timeOfMeridianPassageUTC = timeOfMeridianPassageAlmanac. AddHours(-timeToArcHours). AddMinutes(-timeToArcMinutes); DateTime timeOfMeridianPassageLocal = timeOfMeridianPassageUTC.AddHours(localTimeZone); maskedTextBox3.Text = timeOfMeridianPassageUTC.ToString("dd/MM/yyyy HH:mm:ss"); maskedTextBox4.Text = timeOfMeridianPassageLocal.ToString("dd/MM/yyyy HH:mm:ss"); }
private void button2_Click(object sender, EventArgs e) { textBox10.Text = CelestialTool.CalculateInterpFactor(maskedTextBox4.Text).ToString("N4"); double interpFactor = Double.Parse(textBox10.Text); double DEC0 = CelestialTool.ConvertInput(textBox6.Text); if (DEC0 == 111111) { textBox6.Text = "Input?"; } double DEC1 = CelestialTool.ConvertInput(textBox7.Text); if (DEC1 == 111111) { textBox7.Text = "Input?"; } double DEC = DEC0 + (interpFactor * (DEC1 - DEC0)); double h = Double.Parse(textBox3.Text); double D = 0.0293 * Math.Sqrt(h); double HS = CelestialTool.ConvertInput(textBox5.Text); if (HS == 111111) { textBox5.Text = "Input?"; } double I = CelestialTool.ConvertInput(textBox4.Text); if (I == 111111) { textBox4.Text = "Input?"; } double H = HS + I - D; double Hrad = H * Math.PI / 180; double sd = Double.Parse(textBox8.Text); double SD = sd / 60; double Hcalc = (H + (7.32 / (H + 4.32))) * Math.PI / 180; double temp = Double.Parse(numericUpDown2.Text); double pressure = Double.Parse(numericUpDown3.Text); double f = (0.28 * pressure) / (temp + 273); double refractionConstant = 0.0167 * Math.PI / 180; double Rrad = refractionConstant / Math.Tan(Hcalc); double Ro = Rrad / (Math.PI / 180); double R = f * Ro; double HP = 0.0024; double HPrad = HP * Math.PI / 180; double PArad = HPrad * Math.Cos(Hrad); double PA = PArad / (Math.PI / 180); double HO = H - R + PA + SD; double MZD = 90 - HO; string nameOfMZD = CelestialTool.NameOfMZD(checkBox1.Checked); string nameOfDEC = CelestialTool.NameOfDEC(DEC); double lattitudeDec = CelestialTool.CalculateLattitude(MZD, DEC, nameOfMZD, nameOfDEC); string lattitudeHemisphere = CelestialTool.CalculateHemisphere(MZD, DEC, nameOfMZD, nameOfDEC); double lattitudeDegree = Math.Floor(lattitudeDec); double lattitudeMinute = (lattitudeDec - lattitudeDegree) * 60; textBox9.Text = lattitudeDegree.ToString() + " " + lattitudeMinute.ToString("N1") + " " + lattitudeHemisphere; }
private void sunCalculation() { double Z = 0.0; double P = 0.0; double interpFactor = Double.Parse(textBox1.Text); double temp = Double.Parse(numericUpDown2.Text); double pressure = Double.Parse(numericUpDown3.Text); double h = Double.Parse(textBox2.Text); double sd = Double.Parse(textBox10.Text); double HS = CelestialTool.ConvertInput(textBox11.Text); if (HS == 111111) { textBox11.Text = "Input?"; } double I = CelestialTool.ConvertInput(textBox3.Text); if (I == 111111) { textBox3.Text = "Input?"; } double GHA0 = CelestialTool.ConvertInput(textBox4.Text); if (GHA0 == 111111) { textBox4.Text = "Input?"; } double GHA1 = CelestialTool.ConvertInput(textBox5.Text); if (GHA1 == 111111) { textBox5.Text = "Input?"; } double DEC0 = CelestialTool.ConvertInput(textBox6.Text); if (DEC0 == 111111) { textBox6.Text = "Input?"; } double DEC1 = CelestialTool.ConvertInput(textBox7.Text); if (DEC1 == 111111) { textBox7.Text = "Input?"; } double DrLAT = CelestialTool.ConvertInput(textBox8.Text); if (DrLAT == 111111) { textBox8.Text = "Input?"; } double DrLong = CelestialTool.ConvertInput(textBox9.Text); if (DrLong == 111111) { textBox9.Text = "Input?"; } double GHA = GHA0 + (interpFactor * (GHA1 - GHA0)); if (GHA > 360) { GHA = GHA - 360; } Double DEC = DEC0 + (interpFactor * (DEC1 - DEC0)); Double LHA = GHA + DrLong; if (LHA > 360) { LHA = LHA - 360; } else if (LHA < 0) { LHA = LHA + 360; } Double DECrad = DEC * Math.PI / 180; Double S = Math.Sin(DECrad); Double LHArad = LHA * Math.PI / 180; Double C = Math.Cos(DECrad) * Math.Cos(LHArad); Double DrLATrad = DrLAT * Math.PI / 180; Double HCrad = Math.Asin((S * Math.Sin(DrLATrad)) + (C * Math.Cos(DrLATrad))); Double HC = HCrad / (Math.PI / 180); Double X = ((S * Math.Cos(DrLATrad)) - (C * Math.Sin(DrLATrad))) / Math.Cos(HCrad); if (X > 1) { X = 1; } else if (X < -1) { X = -1; } Double Zrad = Math.Acos(X); if (LHA > 180) { Z = Zrad / (Math.PI / 180); } else { Z = 360 - (Zrad / (Math.PI / 180)); } Z = Math.Round(Z); Double D = 0.0293 * Math.Sqrt(h); Double H = HS + I - D; Double Hrad = H * Math.PI / 180; Double SD = sd / 60; Double Hcalc = (H + (7.32 / (H + 4.32))) * Math.PI / 180; Double f = (0.28 * pressure) / (temp + 273); Double refractionConstant = 0.0167 * Math.PI / 180; Double Rrad = refractionConstant / Math.Tan(Hcalc); Double Ro = Rrad / (Math.PI / 180); Double R = f * Ro; Double HP = 0.0024; Double HPrad = HP * Math.PI / 180; Double PArad = HPrad * Math.Cos(Hrad); Double PA = PArad / (Math.PI / 180); Double HO = H - R + PA + SD; P = (HO - HC) * 60; textBox12.Text = CelestialTool.PlotAzimuthAndIntercept(Z, P); }