private Rotation3 correction_;   // correction rotation to be done

        public PolarCorrectedAlignment(Vect3 newEquAxis, Vect3 prevEquAxis, double altOffset, Rotation3 prevRotationToStand, double equAngle0, double equAngleFactor, AlignStar[] stars)
        {
            equAxis_        = newEquAxis;
            altOffset_      = altOffset;
            equAngleFactor_ = equAngleFactor;

            // calculate RotationToStand for equatorial angle = 0
            prevRotationToStand = prevRotationToStand * new Rotation3(-equAngle0 * equAngleFactor_, prevEquAxis);

            // convert coordinates of pole to scope coordinates
            Vect3 oldScopePoleAxis = prevRotationToStand.Apply(prevEquAxis);
            Vect3 newScopePoleAxis = prevRotationToStand.Apply(equAxis_);

            // correct first altitude, then correct azimuth
            correction_ = new Rotation3(newScopePoleAxis.Alt - oldScopePoleAxis.Alt, new Vect3(newScopePoleAxis.Azm + Math.PI / 2, 0));
            correction_ = new Rotation3(newScopePoleAxis.Azm - oldScopePoleAxis.Azm, new Vect3(0, 0, -1)) * correction_;

            rotationToStand_ = correction_.Conj * prevRotationToStand;

            if (stars != null && stars.Length > 0)
            {
                stars_ = new AlignStar[stars.Length];
                for (int i = 0; i < stars.Length; ++i)
                {
                    if (stars[i] != null)
                    {
                        PairA newScope = DoHorz2Scope((PairA)stars[i].Horz, stars[i].EquAngle);
                        stars_[i] = new AlignStar(stars[i].Name, stars[i].Horz, newScope, stars[i].EquAngle);
                    }
                }
            }
        }
 public AlignStar(string name, Vect3 horz, PairA scope, double equAngle)
 {
     name_     = name;
     horz_     = horz;
     scope_    = scope;
     equAngle_ = equAngle;
 }
        public override PairA Scope2Horz(PairA scope, double equAngle)
        {
            ForceAlignment();
            double da = (equAngle - stars_[0].EquAngle) * equHorzDiff_ / equScopeDiff_;

            return((new Rotation3(-da, equAxis_) * rotationToStand_.Conj).Apply(scope.Offset(0, -altOffset_)));
        }
Example #4
0
        public override bool CorrectOffsets(AlignStar star)
        {
            if (star == null)
            {
                return(false);
            }

            ForceAlignment();
            PairA  scopeOld = Horz2Scope((PairA)star.Horz, star.EquAngle);
            double deltaAlt = star.Scope.Alt - scopeOld.Alt, deltaAzm = star.Scope.Azm - scopeOld.Azm;

            altOffset_      += deltaAlt;
            rotationToStand_ = new Rotation3(-deltaAzm, new Vect3(0, 0, 1)) * rotationToStand_;

            //PairA scopeNew = Horz2Scope((PairA)star.Horz, star.EquAngle);

            foreach (AlignStar s in stars_)
            {
                if (s != null)
                {
                    //scopeNew = Horz2Scope((PairA)s.Horz, s.EquAngle);
                    s.Scope = s.Scope.Offset(+deltaAzm, +deltaAlt);
                }
            }
            return(true);
        }
        public override PairA Horz2Scope(PairA horz, double equAngle)
        {
            ForceAlignment();
            double da = (equAngle - stars_[0].EquAngle) * equHorzDiff_ / equScopeDiff_;

            return((rotationToStand_ * new Rotation3(da, equAxis_)).Apply(horz).Offset(0, altOffset_));
        }
Example #6
0
        private static double CalcAltOffset(Vect3 horz0, PairA scope0, Vect3 horz1, PairA scope1)
        {
            double cosA1A2 = Math.Cos(scope0.Azm - scope1.Azm);
            double den     = 1 - cosA1A2;

            if (den == 0)
            {
                throw new ApplicationException("Error2");
            }

            double x = (Math.Cos(scope0.Alt - scope1.Alt) * (cosA1A2 + 1) - 2 * Vect3.SMul(horz0, horz1)) / den;

            if (x < -1 || x > 1)
            {
                throw new ApplicationException("Error3");
            }

            return((-Math.Acos(x) + scope0.Alt + scope1.Alt) / 2);
        }
Example #7
0
        public override bool CorrectOffsets(AlignStar star)
        {
            if (star == null || star_ == null)
            {
                return(false);
            }
            PairA  scopeOld = Horz2Scope((PairA)star.Horz, star.EquAngle);
            double deltaAlt = star.Scope.Alt - scopeOld.Alt;
            double deltaAzm = star.Scope.Azm - scopeOld.Azm;

            altOffset_ += deltaAlt;
            azmOffset_ += deltaAzm;

            if (star_ != null)
            {
                star_.Scope = star_.Scope.Offset(+deltaAzm, +deltaAlt);
            }

            return(true);
        }
 public abstract PairA Horz2Scope(PairA horz, double equAngle);
 public abstract PairA Scope2Horz(PairA scope, double equAngle);
Example #10
0
        public static void Align(Vect3 horz0, PairA scope0, Vect3 horz1, PairA scope1, Precisions precesions,
                                 out double altOffset, out Rotation3 rotationToStand, out double quality)
        {
            altOffset = CalcAltOffset(horz0, scope0, horz1, scope1);
            Vect3 s0 = new Vect3(scope0.Offset(0, -altOffset));
            Vect3 s1 = new Vect3(scope1.Offset(0, -altOffset));

            double abs;

            Vect3 n0 = horz0 - s0;

            abs = n0.Abs;
            if (abs < precesions.rotation_)
            {
                double angle = CalcRotationAngle(s0, horz1, s1);
                if (angle == 0 || angle == Math.PI)
                {
                    throw new ApplicationException("Error7");
                }

                quality         = -1;
                rotationToStand = new Rotation3(angle, s0);
                return;
            }
            n0 /= abs;

            Vect3 n1 = horz1 - s1;

            abs = n1.Abs;
            if (abs < precesions.rotation_)
            {
                double angle = CalcRotationAngle(s1, horz0, s0);
                if (angle == 0 || angle == Math.PI)
                {
                    throw new ApplicationException("Error8");
                }

                quality         = -2;
                rotationToStand = new Rotation3(angle, s1);
                return;
            }
            n1 /= abs;

            // axis
            Vect3 axis = Vect3.VMul(n0, n1);

            abs = axis.Abs;
            if (abs < precesions.axis_)
            {
                throw new ApplicationException("Error4");
            }
            axis /= abs;

            double angle0 = CalcRotationAngle(axis, horz0, s0);

            if (angle0 == 0 || angle0 == Math.PI)
            {
                throw new ApplicationException("Error5");
            }

            double angle1 = CalcRotationAngle(axis, horz1, s1);

            if (angle1 == 0 || angle1 == Math.PI)
            {
                throw new ApplicationException("Error6");
            }

            quality         = Math.Abs(angle0 - angle1);
            rotationToStand = new Rotation3((angle0 + angle1) / 2, axis);
        }
Example #11
0
 public PairA Apply(PairA v)
 {
     return((PairA)(this * new Vect3(v) * Conj).Vect);
 }
Example #12
0
 public Vect3(PairA aa)
 {
     Horizontal2Cartesian(aa.Azm, aa.Alt, out x_, out y_, out z_);
 }
Example #13
0
 public override PairA Horz2Scope(PairA horz, double equAngle)
 {
     return((new Rotation3(equAngle, equAxis_)).Apply(horz).Offset(+azmOffset_, +altOffset_));
 }
Example #14
0
 public override PairA Scope2Horz(PairA scope, double equAngle)
 {
     ForceAlignment();
     return((new Rotation3(stars_[0].EquAngle - equAngle, equAxis_) * rotationToStand_.Conj).Apply(scope.Offset(0, -altOffset_)));
 }
Example #15
0
 public override PairA Scope2Horz(PairA scope, double equAngle)
 {
     return(currAlignment_.Scope2Horz(scope, equAngle));
 }
 private PairA DoHorz2Scope(PairA horz, double equAngle)
 {
     return((rotationToStand_ * new Rotation3(equAngle * equAngleFactor_, equAxis_)).Apply(horz).Offset(0, altOffset_));
 }
 public override PairA Horz2Scope(PairA horz, double equAngle)
 {
     return(DoHorz2Scope(horz, equAngle));
 }
 public override PairA Scope2Horz(PairA scope, double equAngle)
 {
     return((new Rotation3(-equAngle * equAngleFactor_, equAxis_) * rotationToStand_.Conj).Apply(scope.Offset(0, -altOffset_)));
 }
Example #19
0
 public override PairA Horz2Scope(PairA horz, double equAngle)
 {
     return(currAlignment_.Horz2Scope(horz, equAngle));
 }
Example #20
0
 public override PairA Scope2Horz(PairA scope, double equAngle)
 {
     return((new Rotation3(-equAngle, equAxis_)).Apply(scope.Offset(-azmOffset_, -altOffset_)));
 }