Ejemplo n.º 1
0
        public SkyLabel(RenderContext11 renderContext, double ra, double dec, string text, LabelSytle style, double distance)
        {
            RA = ra;
            Dec = dec;
            Text = text;
            Style = style;

            Distance = distance;

            if (texture == null)
            {
                texture = Texture11.FromBitmap(Resources.circle, 0);
            }

            var up = new Vector3d();
            var textPos = new Vector3d();
            if (Earth3d.MainWindow.SolarSystemMode)
            {
                pos = Coordinates.RADecTo3d(ra, -dec, distance);
                up = Coordinates.RADecTo3d(ra, -dec + 90, distance);

                pos.RotateX(Coordinates.MeanObliquityOfEcliptic(SpaceTimeController.JNow) / 180.0 * Math.PI);
                pos.Add(Planets.GetPlanet3dLocation(SolarSystemObjects.Earth));

                up.RotateX(Coordinates.MeanObliquityOfEcliptic(SpaceTimeController.JNow) / 180.0 * Math.PI);
                up.Add(Planets.GetPlanet3dLocation(SolarSystemObjects.Earth));
               }
            else
            {
                pos = Coordinates.RADecTo3d(ra+12, dec, distance);
                textPos = Coordinates.RADecTo3d(ra + 12, dec + 2, distance);
                up = Coordinates.RADecTo3d(ra+12, dec + 92, distance);

            }
            center = new Vector3(9, 9, 0);

            textBatch = new Text3dBatch(24);
            if (style == LabelSytle.Telrad)
            {
                // Telrad-style labels are always screen-aligned
                var t3 = new Text3d(new Vector3d(0, 0, 0.1), new Vector3d(0, 1, 0), text, 20, .01);
                t3.alignment = Text3d.Alignment.Left;
                textBatch.Add(t3);
            }
            else
            {
                up.Normalize();
                textPos.Normalize();
                textBatch.Add(new Text3d(textPos, up, text, 20, .0005));
            }
        }
Ejemplo n.º 2
0
        // Get the position of a Solar System object using a 'direct' calculation that
        // avoids including an aberration correction.
        //
        // The returned position is in ecliptic coordinate system with the origin at the center
        // of the parent body (i.e. the Sun for planets, a planet for moons). The position of moons
        // is _not_ modified by the SolarSystemScale, making it possible to use function to
        // a calculate valid Keplerian elements.
        public static Vector3d GetPlanetPositionDirect(SolarSystemObjects id, double jd)
        {
            var L = 0.0;
            var B = 0.0;
            var R = 0.0;

            switch (id)
            {
                case SolarSystemObjects.Mercury:
                    L = CAAMercury.EclipticLongitude(jd);
                    B = CAAMercury.EclipticLatitude(jd);
                    R = CAAMercury.RadiusVector(jd);
                    break;
                case SolarSystemObjects.Venus:
                    L = CAAVenus.EclipticLongitude(jd);
                    B = CAAVenus.EclipticLatitude(jd);
                    R = CAAVenus.RadiusVector(jd);
                    break;
                case SolarSystemObjects.Earth:
                    {
                        //double x = HiResTimer.TickCount;
                        L = CAAEarth.EclipticLongitude(jd);
                        B = CAAEarth.EclipticLatitude(jd);
                        R = CAAEarth.RadiusVector(jd);
                        //x = (HiResTimer.TickCount - x) / HiResTimer.Frequency;
                        //System.Console.WriteLine("Earth orbit time: " + x * 1000.0 + "ms");
                    }
                    break;
                case SolarSystemObjects.Mars:
                    L = CAAMars.EclipticLongitude(jd);
                    B = CAAMars.EclipticLatitude(jd);
                    R = CAAMars.RadiusVector(jd);
                    break;
                case SolarSystemObjects.Jupiter:
                    L = CAAJupiter.EclipticLongitude(jd);
                    B = CAAJupiter.EclipticLatitude(jd);
                    R = CAAJupiter.RadiusVector(jd);
                    break;
                case SolarSystemObjects.Saturn:
                    L = CAASaturn.EclipticLongitude(jd);
                    B = CAASaturn.EclipticLatitude(jd);
                    R = CAASaturn.RadiusVector(jd);
                    break;
                case SolarSystemObjects.Uranus:
                    L = CAAUranus.EclipticLongitude(jd);
                    B = CAAUranus.EclipticLatitude(jd);
                    R = CAAUranus.RadiusVector(jd);
                    break;
                case SolarSystemObjects.Neptune:
                    L = CAANeptune.EclipticLongitude(jd);
                    B = CAANeptune.EclipticLatitude(jd);
                    R = CAANeptune.RadiusVector(jd);
                    break;
                case SolarSystemObjects.Pluto:
                    L = CAAPluto.EclipticLongitude(jd);
                    B = CAAPluto.EclipticLatitude(jd);
                    R = CAAPluto.RadiusVector(jd);
                    break;
                case SolarSystemObjects.Moon:
                    L = CAAMoon.EclipticLongitude(jd);
                    B = CAAMoon.EclipticLatitude(jd);
                    R = CAAMoon.RadiusVector(jd)/149598000;
                    break;
                case SolarSystemObjects.Io:
                    {
                        var galileanInfo = CAAGalileanMoons.Calculate(jd);
                        var position = galileanInfo.Satellite1.EclipticRectangularCoordinates;
                        return new Vector3d(position.X, position.Z, position.Y);
                    }
                case SolarSystemObjects.Europa:
                    {
                        var galileanInfo = CAAGalileanMoons.Calculate(jd);
                        var position = galileanInfo.Satellite2.EclipticRectangularCoordinates;
                        return new Vector3d(position.X, position.Z, position.Y);
                    }
                case SolarSystemObjects.Ganymede:
                    {
                        var galileanInfo = CAAGalileanMoons.Calculate(jd);
                        var position = galileanInfo.Satellite3.EclipticRectangularCoordinates;
                        return new Vector3d(position.X, position.Z, position.Y);
                    }
                case SolarSystemObjects.Callisto:
                    {
                        var galileanInfo = CAAGalileanMoons.Calculate(jd);
                        var position = galileanInfo.Satellite4.EclipticRectangularCoordinates;
                        return new Vector3d(position.X, position.Z, position.Y);
                    }
            }

            // Enabling this code transforms planet positions from the mean ecliptic/equinox of
            // date to the J2000 ecliptic. It is necessary because the VSOP87D series used
            // for planet positions is in the mean-of-date frame. The transformation is currently
            // disabled in order to better match planet positions calculated elsewhere in the code.
            //CAA2DCoordinate prec = CAAPrecession.PrecessEcliptic(L, B, jd, 2451545.0);
            //L = prec.X;
            //B = prec.Y;

            L = CAACoordinateTransformation.DegreesToRadians(L);
            B = CAACoordinateTransformation.DegreesToRadians(B);
            var eclPos = new Vector3d(Math.Cos(L) * Math.Cos(B), Math.Sin(L) * Math.Cos(B), Math.Sin(B)) * R;

            // Transform from the ecliptic of date to the J2000 ecliptic; this transformation should be deleted
            // once the precession is turned one.
            var eclipticOfDateRotation = (Coordinates.MeanObliquityOfEcliptic(jd) - Coordinates.MeanObliquityOfEcliptic(2451545.0)) * RC;
            eclPos.RotateX(eclipticOfDateRotation);

            return new Vector3d(eclPos.X, eclPos.Z, eclPos.Y);
        }