Exemplo n.º 1
0
            public WcsSolution GetSolution()
            {
                WcsSolution s = new WcsSolution();

                s.CenterX  = RA;
                s.CenterY  = Dec;
                s.Scale    = Scale;
                s.Rotation = Rotation;


                return(s);
            }
Exemplo n.º 2
0
        private WcsSolution SolveLM()
        {
            Vector2d temp             = Points[0].Image - Points[1].Image;
            double   imageLength      = temp.Length;
            double   angularSperation = CAAAngularSeparation.Separation(Points[0].Celestial.RA, Points[0].Celestial.Dec, Points[1].Celestial.RA, Points[1].Celestial.Dec);

            // Degrees per pixel
            double scale = angularSperation / imageLength;

            WcsSolution sinit = Solve(Points[0], Points[1]);


            TanSolver ts = new TanSolver(sinit.CenterX, sinit.CenterY, sinit.Rotation - 180, sinit.Scale);

            foreach (CorresponencePoint cp in Points)
            {
                SolveList.Add(new CoorespondenceSolver(ts, cp, width, height));
            }


            regressionParameters.AddRange(ts.Parameters);

            int count = SolveList.Count;

            double[,] data = new double[2, count];
            for (int i = 0; i < count; i++)
            {
                data[0, i] = i;
                data[1, i] = 0;
            }
            Parameter[] observed = new Parameter[] { ParmeterIndex };

            lm = new LevenbergMarquardt(new functionDelegate(SolveFunction), regressionParameters.ToArray(), observed, data);

            for (int d = 0; d < 50; d++)
            {
                lm.Iterate();
            }

            WcsSolution s = ts.GetSolution();

            s.OffsetX = width / 2;
            s.OfsetY  = height / 2;


            return(s);
        }
Exemplo n.º 3
0
        private WcsSolution SolveOld(CorresponencePoint a, CorresponencePoint b)
        {
            WcsSolution s                = new WcsSolution();
            Vector2d    center           = new Vector2d(width / 2, height / 2);
            Vector2d    temp             = a.Image - b.Image;
            double      imageLength      = temp.Length;
            double      angularSperation = CAAAngularSeparation.Separation(a.Celestial.RA, a.Celestial.Dec, b.Celestial.RA, b.Celestial.Dec);

            // Degrees per pixel
            s.Scale = angularSperation / imageLength;
            double imageRotation = Math.Atan2(temp.X, temp.Y) / Math.PI * 180;
            double positionAngle = CAAAngularSeparation.PositionAngle(a.Celestial.RA, a.Celestial.Dec, b.Celestial.RA, b.Celestial.Dec);

            //          Earth3d.MainWindow.Text = "pa:" + positionAngle.ToString() + ", imrot:" + imageRotation.ToString() + ", scale:" + s.Scale.ToString();
            s.Rotation = -((imageRotation - positionAngle));
            double rotationRads = s.Rotation / 180 * Math.PI;

            s.OffsetX = width / 2;
            s.OfsetY  = height / 2;

            // Calculate center point
            Vector2d centerDistA    = center - a.Image;
            Vector2d centerDistB    = center - b.Image;
            double   centerRotaionA = Math.Atan2(centerDistA.X, centerDistA.Y);
            double   centerRotaionB = Math.Atan2(centerDistB.X, centerDistB.Y);
            double   raA            = a.Celestial.RA + (Math.Sin(centerRotaionA + rotationRads) * s.Scale / 15 * centerDistA.Length / Math.Cos(a.Celestial.Dec / 180 * Math.PI));
            double   raB            = b.Celestial.RA + (Math.Sin(centerRotaionB + rotationRads) * s.Scale / 15 * centerDistB.Length / Math.Cos(b.Celestial.Dec / 180 * Math.PI));
            double   decA           = a.Celestial.Dec + (Math.Cos(centerRotaionA + rotationRads) * s.Scale * centerDistA.Length);
            double   decB           = b.Celestial.Dec + (Math.Cos(centerRotaionB + rotationRads) * s.Scale * centerDistB.Length);

            s.CenterX = (raA + raB) / 2;
            s.CenterY = (decA + decB) / 2;

            s.Flip = false;

            return(s);
        }
Exemplo n.º 4
0
        private WcsSolution Solve(CorresponencePoint a, CorresponencePoint b)
        {
            WcsSolution s                = new WcsSolution();
            Vector2d    center           = new Vector2d(width / 2, height / 2);
            Vector2d    temp             = a.Image - b.Image;
            double      imageLength      = temp.Length;
            double      angularSperation = CAAAngularSeparation.Separation(a.Celestial.RA, a.Celestial.Dec, b.Celestial.RA, b.Celestial.Dec);

            // Degrees per pixel
            s.Scale = angularSperation / imageLength;
            double imageRotation = Math.Atan2(temp.X, temp.Y) / Math.PI * 180;

            temp = center - b.Image;

            double centerRotation = Math.Atan2(temp.X, temp.Y) / Math.PI * 180;

            s.OffsetX = width / 2;
            s.OfsetY  = height / 2;

            Coordinates cent = a.Celestial;

            int iters = 4;

            while (iters-- > 0)
            {
                // Calculate Center
                Vector2d tanA = Coordinates.RaDecToTan(cent, a.Celestial);
                Vector2d tanB = Coordinates.RaDecToTan(cent, b.Celestial);

                temp = tanA - tanB;
                double tanLength = temp.Length;


                s.Scale = (tanLength / Math.PI * 180) / imageLength;

                double tanRotation = Math.Atan2(temp.X, temp.Y) / Math.PI * 180;

                double tRotRad = -((imageRotation - tanRotation) / 180 * Math.PI);

                Vector2d centerDistA    = center - a.Image;
                double   centerRotaionA = Math.Atan2(centerDistA.X, centerDistA.Y);

                double ratio = tanLength / imageLength;

                double tanCx = tanA.X + Math.Sin(centerRotaionA + tRotRad) * ratio * centerDistA.Length;
                double tanCy = tanA.Y + Math.Cos(centerRotaionA + tRotRad) * ratio * centerDistA.Length;

                Vector2d result = Coordinates.TanToRaDec(cent, new Vector2d(tanCx, tanCy));
                s.CenterX = result.X;
                s.CenterY = result.Y;

                cent = Coordinates.FromRaDec(result.X, result.Y);
            }

            double positionAngle = CAAAngularSeparation.PositionAngle(s.CenterX, s.CenterY, b.Celestial.RA, b.Celestial.Dec);

            s.Rotation = -((centerRotation - positionAngle));



            s.Flip = false;

            return(s);
        }
Exemplo n.º 5
0
 public void Solve()
 {
     //Solution = Solve(Points[0],Points[1]);
     Solution = SolveLM();
 }
Exemplo n.º 6
0
 public void Solve()
 {
     //Solution = Solve(Points[0],Points[1]);
     Solution = SolveLM();
 }
Exemplo n.º 7
0
            public WcsSolution GetSolution()
            {
                WcsSolution s = new WcsSolution();

                s.CenterX = RA;
                s.CenterY = Dec;
                s.Scale = Scale;
                s.Rotation = Rotation;

                return s;
            }
Exemplo n.º 8
0
        private WcsSolution SolveOld(CorresponencePoint a, CorresponencePoint b)
        {
            WcsSolution s = new WcsSolution();
            Vector2d center = new Vector2d(width / 2, height / 2);
            Vector2d temp = a.Image - b.Image;
            double imageLength = temp.Length;
            double angularSperation = CAAAngularSeparation.Separation(a.Celestial.RA, a.Celestial.Dec, b.Celestial.RA, b.Celestial.Dec);

            // Degrees per pixel
            s.Scale = angularSperation / imageLength;
            double imageRotation = Math.Atan2(temp.X, temp.Y) / Math.PI * 180;
            double positionAngle = CAAAngularSeparation.PositionAngle(a.Celestial.RA, a.Celestial.Dec, b.Celestial.RA, b.Celestial.Dec);
            //          Earth3d.MainWindow.Text = "pa:" + positionAngle.ToString() + ", imrot:" + imageRotation.ToString() + ", scale:" + s.Scale.ToString();
            s.Rotation = -((imageRotation - positionAngle));
            double rotationRads = s.Rotation / 180 * Math.PI;
            s.OffsetX = width / 2;
            s.OfsetY = height / 2;

            // Calculate center point
            Vector2d centerDistA = center - a.Image;
            Vector2d centerDistB = center - b.Image;
            double centerRotaionA = Math.Atan2(centerDistA.X, centerDistA.Y);
            double centerRotaionB = Math.Atan2(centerDistB.X, centerDistB.Y);
            double raA = a.Celestial.RA + (Math.Sin(centerRotaionA + rotationRads) * s.Scale / 15 * centerDistA.Length / Math.Cos(a.Celestial.Dec / 180 * Math.PI));
            double raB = b.Celestial.RA + (Math.Sin(centerRotaionB + rotationRads) * s.Scale / 15 * centerDistB.Length / Math.Cos(b.Celestial.Dec / 180 * Math.PI));
            double decA = a.Celestial.Dec + (Math.Cos(centerRotaionA + rotationRads) * s.Scale * centerDistA.Length);
            double decB = b.Celestial.Dec + (Math.Cos(centerRotaionB + rotationRads) * s.Scale * centerDistB.Length);

            s.CenterX = (raA + raB) / 2;
            s.CenterY = (decA + decB) / 2;

            s.Flip = false;

            return s;
        }
Exemplo n.º 9
0
        private WcsSolution Solve(CorresponencePoint a, CorresponencePoint b)
        {
            WcsSolution s = new WcsSolution();
            Vector2d center = new Vector2d(width / 2, height / 2);
            Vector2d temp = a.Image - b.Image;
            double imageLength = temp.Length;
            double angularSperation = CAAAngularSeparation.Separation(a.Celestial.RA, a.Celestial.Dec, b.Celestial.RA, b.Celestial.Dec);

            // Degrees per pixel
            s.Scale = angularSperation / imageLength;
            double imageRotation = Math.Atan2(temp.X, temp.Y) / Math.PI * 180;

            temp = center - b.Image;

            double centerRotation = Math.Atan2(temp.X, temp.Y) / Math.PI * 180;

            s.OffsetX = width / 2;
            s.OfsetY = height / 2;

            Coordinates cent = a.Celestial;

            int iters = 4;

            while (iters-- > 0)
            {

                // Calculate Center
                Vector2d tanA = Coordinates.RaDecToTan(cent, a.Celestial);
                Vector2d tanB = Coordinates.RaDecToTan(cent, b.Celestial);

                temp = tanA - tanB;
                double tanLength = temp.Length;

                s.Scale = (tanLength/Math.PI*180) / imageLength;

                double tanRotation = Math.Atan2(temp.X, temp.Y) / Math.PI * 180;

                double tRotRad = -((imageRotation - tanRotation) / 180 * Math.PI);

                Vector2d centerDistA = center - a.Image;
                double centerRotaionA = Math.Atan2(centerDistA.X, centerDistA.Y);

                double ratio = tanLength / imageLength;

                double tanCx = tanA.X + Math.Sin(centerRotaionA + tRotRad) * ratio * centerDistA.Length;
                double tanCy = tanA.Y + Math.Cos(centerRotaionA + tRotRad) * ratio * centerDistA.Length;

                Vector2d result = Coordinates.TanToRaDec(cent, new Vector2d(tanCx, tanCy));
                s.CenterX = result.X;
                s.CenterY = result.Y;

                cent = Coordinates.FromRaDec(result.X, result.Y);
            }

            double positionAngle = CAAAngularSeparation.PositionAngle(s.CenterX, s.CenterY, b.Celestial.RA, b.Celestial.Dec);
            s.Rotation = -((centerRotation - positionAngle));

            s.Flip = false;

            return s;
        }