private void LoadAlignment() { try { AlignStar[] stars = settings_.AlignmentStars; if (stars == null) { alignment_ = null; } else { alignment_ = new DSCAlignment(settings_.AlignmentEquAxis, Precisions.Default); for (int i = 0; i < stars.Length; ++i) { alignment_.AddStar(stars[i]); } alignment_.ForceAlignment(); alignmentConnectionAltAzm_ = settings_.AlignmentConnectionAltAzm; alignmentConnectionEqu_ = settings_.AlignmentConnectionEqu; } } catch (Exception) { alignment_ = null; } AlignmentChanged(); }
private void buttonAddObject_Click(object sender, EventArgs e) { if (!init_) { return; } double d = ClientCommonAPI.CalcTime(); SkyObjectPosCalc.SkyPosition obj = GetObject(); double azm, alt; obj.CalcAzimuthal(d, latitude_, longitude_, out azm, out alt); try { DSCAlignment alignmentNew = (DSCAlignment)alignment_.Clone(); alignmentNew.AddStar(new AlignStar(obj.Name, new Vect3(azm * Const.toRad, alt * Const.toRad), new PairA(host_.AzmAngle, host_.AltAngle), host_.EquAngle)); alignmentNew.ForceAlignment(); alignment_ = alignmentNew; } catch (Exception ex) { MessageBox.Show(ex.Message, "Alignment Error", MessageBoxButtons.OK); return; } AlignmentChanged(); }
private int MakeDynamic4StarAlignment(Vect3 star0, string name0, PairA stand0, double eqAngle0, Vect3 star1, string name1, PairA stand1, double eqAngle1, Vect3 star2, string name2, PairA stand2, double eqAngle2, Vect3 star3, string name3, PairA stand3, double eqAngle3, out Alignment calc) { Vect3 eqNorth = new Vect3(0, latitude_); Vect3 eqAxis = eqNorth; double equAngleFactor = 1; calc = null; int i = 0; for (; i < 50; ++i) { Vect3 star1_corrected = new Rotation3((eqAngle1 - eqAngle0) * equAngleFactor, eqAxis).Apply(star1); Vect3 star3_corrected = new Rotation3((eqAngle3 - eqAngle2) * equAngleFactor, eqAxis).Apply(star3); calc = new DSCAlignment(new Vect3(0, latitude_), precesions_); calc.AddStar(new AlignStar(name0, star0, stand0, eqAngle0)); calc.AddStar(new AlignStar(name1, star1_corrected, stand1, eqAngle0)); calc.AddStar(new AlignStar(name2, star2, stand2, eqAngle2)); calc.AddStar(new AlignStar(name3, star3_corrected, stand3, eqAngle2)); Vect3 equAxis = calc.EquAxis; PairA correction = new PairA(-equAxis.Azm, latitude_ - equAxis.Alt); Vect3 eqAxisNew = new Vect3(eqNorth.Azm - correction.Azm, eqNorth.Alt - correction.Alt); double diff = Vect3.VMul(eqAxis, eqAxisNew).Abs; if (diff < toRad / 240) { break; } eqAxis = eqAxisNew; equAngleFactor = calc.EquAngleFactor; } return(i); }
private void buttonLoadAlignment_Click(object sender, EventArgs e) { OpenFileDialog openfile = new OpenFileDialog(); openfile.InitialDirectory = Application.StartupPath + @"\"; openfile.Filter = "XML files (*.xml)|*.xml|All files (*.*)|*.*"; openfile.FilterIndex = 1; openfile.RestoreDirectory = true; try { DialogResult res = openfile.ShowDialog(); if (res != DialogResult.OK) { return; } XmlProfile profile = new XmlProfile(openfile.FileName); AlignStar[] stars = (AlignStar[])profile.GetValue("entries", "AlignmentStars", null, typeof(AlignStar[])); Vect3 alignmentEquAxis = (Vect3)profile.GetValue("entries", "AlignmentEquAxis", new Vect3()); if (stars != null) { alignment_ = new DSCAlignment(alignmentEquAxis, Precisions.Default); for (int i = 0; i < stars.Length; ++i) { alignment_.AddStar(stars[i]); } alignment_.ForceAlignment(); AlignmentChanged(); } } catch (Exception ex) { MessageBox.Show(ex.Message); return; } }
private void CalcAndOutputResults() { if (!init_) { return; } // if true, make four start alignment (i.e. actually the same two alignment starts, but twice for two equatorial angles) bool fourStars = textBoxPlatformA2.Enabled = textBoxPlatformDA2.Enabled = checkBox4StarAlignment.Checked; string s = ""; try { { //rnd_ = new Random(0); PairA stand1 = ToScope(Star1, equAngle_).Offset(RndAngleErr(), RndAngleErr()); s += "Eq angle = " + (equAngle_ * toDeg).ToString() + ", Star1 in scope coordinates = " + PrintV(stand1) + Environment.NewLine; if (stand1.Below(minAlt_ + altOff_)) { throw new ApplicationException("Star1 is below min altitude"); } PairA stand2 = ToScope(Star2, equAngle_ + equAngleD_).Offset(RndAngleErr(), RndAngleErr()); s += "Eq angle = " + ((equAngle_ + equAngleD_) * toDeg).ToString() + ", Star2 in scope coordinates = " + PrintV(stand2) + Environment.NewLine; if (stand2.Below(minAlt_ + altOff_)) { throw new ApplicationException("Star2 is below min altitude"); } s += Environment.NewLine; PairA stand21 = new PairA(), stand22 = new PairA(); if (fourStars) { stand21 = ToScope(Star1, equAngle2_).Offset(RndAngleErr(), RndAngleErr()); stand22 = ToScope(Star2, equAngle2_ + equAngleD2_).Offset(RndAngleErr(), RndAngleErr()); s += "Eq angle = " + (equAngle2_ * toDeg).ToString() + ", Star1 in scope coordinates = " + PrintV(stand21) + Environment.NewLine; s += "Eq angle = " + ((equAngle2_ + equAngleD2_) * toDeg).ToString() + ", Star2 in scope coordinates = " + PrintV(stand22) + Environment.NewLine; s += Environment.NewLine; } Alignment calc; /* * if (fourStars && (equAngleD_ != 0 || equAngleD2_ != 0)) * { * Vect3 star1 = new Vect3(Star1); * Vect3 star2 = new Vect3(Star2); * int iterations = MakeDynamic4StarAlignment(star1, "Star1", stand1, equAngle_ * equAngleFactor_, * star2, "Star2", stand2, (equAngle_ + equAngleD_) * equAngleFactor_, * star1, "Star1", stand21, equAngle2_ * equAngleFactor_, * star2, "Star2", stand22, (equAngle2_ + equAngleD2_) * equAngleFactor_, * out calc); * s += "Iterations: " + iterations.ToString(); * s += Environment.NewLine; * } * else * */ { calc = new DSCAlignment(new Vect3(0, latitude_), precesions_); calc.AddStar(new AlignStar("Star1", new Vect3(Star1), stand1, equAngle_ * equAngleFactor_)); calc.AddStar(new AlignStar("Star2", new Vect3(Star2), stand2, (equAngle_ + equAngleD_) * equAngleFactor_)); if (fourStars) { calc.AddStar(new AlignStar("Star1", new Vect3(Star1), stand21, equAngle2_ * equAngleFactor_)); calc.AddStar(new AlignStar("Star2", new Vect3(Star2), stand22, (equAngle2_ + equAngleD2_) * equAngleFactor_)); } } s += calc.ToString(true); if (IsEquAxisCorrectionNeeded(latitude_, calc)) { s += Environment.NewLine + AddEquAxisCorrectionText(latitude_, calc); } s += Environment.NewLine; s += Environment.NewLine; s += "OBJECT POSITION" + Environment.NewLine; PairA standObj = ToScope(Obj, objEquAngle_); s += "Object in scope coordinates = " + PrintV(standObj); s += Environment.NewLine; if (standObj.Below(minAlt_ + altOff_)) { throw new ApplicationException("Object is below min altitude"); } PairA calcObj = calc.Scope2Horz(standObj, objEquAngle_ * equAngleFactor_); double errorMin = Math.Asin(Vect3.VMul(new Vect3(Obj), new Vect3(calcObj)).Abs) * toDeg * 60; s += "Calculated Horizontal Object: " + PrintV(calcObj) + ", error " + errorMin.ToString("F2") + " arc min"; s += Environment.NewLine; s += Environment.NewLine; alignment_ = calc; // (Alignment)calc.Clone(); if (IsEquAxisCorrectionNeeded(latitude_, calc)) { calc.CorrectEquAxis(new Vect3(0, latitude_)); s += calc.ToString(true); } } } catch (Exception e) { s += e.Message; s += Environment.NewLine; } textBoxResults.Text = s; }