コード例 #1
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);
        }
コード例 #2
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);
        }