Beispiel #1
0
        private void SetPositionText()
        {
            if (!posTextChanged_)
            {
                return;
            }
            posTextChanged_ = false;

            string s = "";

            if (connectionAltAzm_ == null || connectionEqu_ == null || alignment_ == null || !alignment_.IsAligned || object_ == null)
            {
                s += "--, --";
            }
            else
            {
                double d = ClientCommonAPI.CalcTime();
                double azm, alt;
                object_.CalcAzimuthal(d, latitude_, longitude_, out azm, out alt);
                PairA objScope = alignment_.Horz2Scope(new PairA(azm * Const.toRad, alt * Const.toRad), EquAngle);

                if (!showNearestAzmRotation_)
                {
                    s += ClientCommonAPI.PrintAzmAltDifference(SkyObjectPosCalc.Rev(objScope.Azm * Const.toDeg) - AzmAngle * Const.toDeg, (objScope.Alt - AltAngle) * Const.toDeg, oppositeHorzPositioningDir_);
                }
                else
                {
                    double azmd = SkyObjectPosCalc.Rev(objScope.Azm * Const.toDeg - AzmAngle * Const.toDeg);
                    if (azmd > 180)
                    {
                        azmd -= 360;
                    }
                    s += ClientCommonAPI.PrintAzmAltDifference(azmd, (objScope.Alt - AltAngle) * Const.toDeg, oppositeHorzPositioningDir_);
                }
            }

            textBoxPosition.Text = s;
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        private void SetScopePositionAndObjectText(bool sendPositionToStellarium)
        {
            if (!scopePosAndObjTextChanged_ && !sendPositionToStellarium)
            {
                return;
            }
            scopePosAndObjTextChanged_ = false;

            double d = ClientCommonAPI.CalcTime();

            string s = "";

            if (connectionAltAzm_ == null)
            {
                s += "Encoder Abs Positions Unknown" + Environment.NewLine;
            }
            else
            {
                s += "Encoder Abs Positions: Azm = " + ClientCommonAPI.PrintAngle(AzmAngle * Const.toDeg, false, false) + ", Alt = " + ClientCommonAPI.PrintAngle(AltAngle * Const.toDeg, false, false) + Environment.NewLine;
                s += "ErrCnt = " + errorCnt_ + Environment.NewLine;
            }

            if (connectionEqu_ == null)
            {
                s += "Equ Angle Unknown" + Environment.NewLine;
            }
            else
            {
                s += "Equ Angle = " + ClientCommonAPI.PrintAngle(EquAngle * Const.toDeg) + Environment.NewLine;
            }

            s += Environment.NewLine;
            if (connectionAltAzm_ == null || connectionEqu_ == null)
            {
                s += "Scope Position Unknown";
            }
            else if (alignment_ != null && alignment_.IsAligned)
            {
                PairA horz = alignment_.Scope2Horz(new PairA(AzmAngle, AltAngle), EquAngle);

                s += "Scope Position: Azm = " + ClientCommonAPI.PrintAngle(SkyObjectPosCalc.Rev(horz.Azm * Const.toDeg), false, false);
                s += ", Alt = " + ClientCommonAPI.PrintAngle(SkyObjectPosCalc.Rev(horz.Alt * Const.toDeg), false, false) + Environment.NewLine;

                double dec, ra;
                SkyObjectPosCalc.AzAlt2Equ(d, latitude_, longitude_, SkyObjectPosCalc.Rev(horz.Azm * Const.toDeg), SkyObjectPosCalc.Rev(horz.Alt * Const.toDeg), out dec, out ra);
                s += "R.A.\t= " + ClientCommonAPI.PrintTime(ra) + " (" + ra.ToString("F5") + "\x00B0)" + Environment.NewLine;
                s += "Dec.\t= " + ClientCommonAPI.PrintAngle(dec, true) + " (" + ClientCommonAPI.PrintDec(dec, "F5") + "\x00B0)" + Environment.NewLine;

                if (sendPositionToStellarium && stellariumConnection_ != null && stellariumConnection_.IsConnected)
                {
                    stellariumConnection_.SendPosition(dec, ra);
                }
            }

            s += Environment.NewLine;
            if (object_ == null)
            {
                s += "No Object Selected";
            }
            else
            {
                double azm, alt;
                object_.CalcAzimuthal(d, latitude_, longitude_, out azm, out alt);
                s += object_.Name + ": Azm = " + ClientCommonAPI.PrintAngle(azm, false, false);
                s += ", Alt = " + ClientCommonAPI.PrintAngle(alt, false, false) + Environment.NewLine;

                double dec, ra;
                object_.CalcTopoRaDec(d, latitude_, longitude_, out dec, out ra);
                s += "R.A.\t= " + ClientCommonAPI.PrintTime(ra) + " (" + ra.ToString("F5") + "\x00B0)" + Environment.NewLine;
                s += "Dec.\t= " + ClientCommonAPI.PrintAngle(dec, true) + " (" + ClientCommonAPI.PrintDec(dec, "F5") + "\x00B0)" + Environment.NewLine;

                /*
                 * double azm, alt;
                 * object_.CalcAzimuthal(d, latitude_, longitude_, out azm, out alt);
                 * s += "Azm.\t= " + ScopeDSCClient.PrintAngle(azm) + " (" + azm.ToString("F5") + "\x00B0)" + Environment.NewLine;
                 * s += "Alt.\t= " + ScopeDSCClient.PrintAngle(alt) + " (" + alt.ToString("F5") + "\x00B0)";
                 * */
            }

            textBoxObject.Text = s;
        }
Beispiel #4
0
 private string PrintV(PairA v)
 {
     return("{A = " + (v.Azm * toDeg).ToString("F5") + ", h = " + (v.Alt * toDeg).ToString("F5") + "}");
 }
Beispiel #5
0
 private PairA ToScope(PairA h, double equAngle, Vect3 equAxis, Rotation3 standRotation)
 {
     return((new Rotation3(-equAngle, equAxis) * standRotation).Conj.Apply(h).Offset(azmOff_, altOff_));;
 }
Beispiel #6
0
 private PairA ToScope(PairA h, double equAngle)
 {
     return(ToScope(h, equAngle, EquAxis, StandRotation));
 }
Beispiel #7
0
 private PairA FromScope(PairA s, double equAngle, Vect3 equAxis, Rotation3 standRotation)
 {
     return((new Rotation3(-equAngle, equAxis) * standRotation).Apply(s.Offset(-azmOff_, -altOff_)));
 }
Beispiel #8
0
 private PairA FromScope(PairA s, double equAngle)
 {
     return(FromScope(s, equAngle, EquAxis, StandRotation));
 }
Beispiel #9
0
        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;
        }