Example #1
0
        private static void MakePrecessionChart()
        {
            double   obliquity = Coordinates.MeanObliquityOfEcliptic(SpaceTimeController.JNow);
            Matrix3d mat       = Matrix3d.RotationX((obliquity / 360.0 * (Math.PI * 2)));
            Color    col       = Colors.White;

            if (precLineList == null)
            {
                precLineList = new SimpleLineList();
                precLineList.DepthBuffered = false;

                for (double l = 0; l < 360; l++)
                {
                    double b = 90 - obliquity;
                    precLineList.AddLine(Vector3d.TransformCoordinate(Coordinates.RADecTo3dAu(l / 15, b, 1), mat), Vector3d.TransformCoordinate(Coordinates.RADecTo3dAu((l + 1) / 15, b, 1), mat));
                }

                for (double l = -12000; l < 13000; l += 2000)
                {
                    double b = 90 - obliquity;
                    double p = -((l - 2000) / 25772 * 24) - 6;
                    precLineList.AddLine(Vector3d.TransformCoordinate(Coordinates.RADecTo3dAu(p, b - .5, 1), mat), Vector3d.TransformCoordinate(Coordinates.RADecTo3dAu(p, b + .5, 1), mat));
                }
            }
            if (PrecTextBatch == null)
            {
                PrecTextBatch = new Text3dBatch(50);

                int index = 0;
                for (double l = -12000; l < 13000; l += 2000)
                {
                    double b = 90 - obliquity + 3;

                    double p    = -((l - 2000) / 25772 * 24) - 6;
                    string text = l.ToString();

                    if (l == 0)
                    {
                        b    = 90 - obliquity + 2;
                        text = "1 CE";
                    }
                    else if (l < 0)
                    {
                        text = "  " + (Math.Abs(l).ToString()) + " BCE";
                    }
                    else
                    {
                        text = (Math.Abs(l).ToString()) + " CE";
                    }

                    if (text.Length == 9)
                    {
                        text = "   " + text;
                    }

                    PrecTextBatch.Add(new Text3d(Vector3d.TransformCoordinate(Coordinates.RADecTo3dAu(p, b, 1), mat), Vector3d.TransformCoordinate(Coordinates.RADecTo3dAu(p + .01, b, 1), mat), text, 75, .00015));
                }
            }
            return;
        }
        public static void InitializeConstellationNames()
        {
            if (ConstellationCentroids == null)
            {
                return;
            }


            NamesBatch = new Text3dBatch(80);


            foreach (string key in ConstellationCentroids.Keys)
            {
                IPlace centroid = ConstellationCentroids[key];

                Vector3d center = Coordinates.RADecTo3dAu(centroid.RA, centroid.Dec, 1);
                Vector3d up     = Vector3d.Create(0, 1, 0);
                string   name   = centroid.Name;

                if (centroid.Name == "Triangulum Australe")
                {
                    name = name.Replace(" ", "\n   ");
                }
                NamesBatch.Add(new Text3d(center, up, name, 80, .000125));
            }
        }
Example #3
0
        public static void InitStarVertexBuffer(RenderContext renderContext)
        {
            if (!starsDownloading)
            {
                GetStarFile("http://www.worldwidetelescope.org/wwtweb/catalog.aspx?Q=hipparcos");
                starsDownloading = true;
            }

            if (starSprites == null && starCount > 0)
            {
                double ecliptic = Coordinates.MeanObliquityOfEcliptic(SpaceTimeController.JNow) / 180.0 * Math.PI;

                int count = stars.Count;
                starCount = count;

                starSprites = new PointList(renderContext);
                starSprites.DepthBuffered = false;
                foreach (Star star in stars)
                {
                    Vector3d pos = Coordinates.RADecTo3dAu(star.RA, star.Dec, star.Distance);
                    pos.RotateX(ecliptic);
                    star.Position = pos;
                    double radDec = (1200000) / Math.Pow(1.6, star.AbsoluteMagnitude);
                    starSprites.AddPoint(pos, star.Col, new Dates(0, 1), (float)radDec * 100);
                }
            }
        }
Example #4
0
        private void LoadData(string data)
        {
            string[] rows = data.Replace("\r\n", "\n").Split("\n");

            bool      firstRow = true;
            PointType type     = PointType.Move;
            Star      star     = null;

            foreach (string row in rows)
            {
                if (firstRow)
                {
                    firstRow = false;
                    continue;
                }

                if (row.Trim().Length > 5)
                {
                    star          = new Star(row);
                    star.Position = Coordinates.RADecTo3dAu(star.RA, star.Dec, 1);

                    stars.Add(star);
                }
            }
        }
Example #5
0
        private static void MakeAltAzGridText()
        {
            Color drawColor = Colors.White;

            int index = 0;

            if (AltAzTextBatch == null)
            {
                AltAzTextBatch = new Text3dBatch(30);
                for (double l = 0; l < 360; l += 10)
                {
                    string text = "       " + l.ToString();
                    if (l < 10)
                    {
                        text = "   " + l.ToString();
                    }
                    else if (l < 100)
                    {
                        text = "     " + l.ToString();
                    }
                    double lc = 360 - l;
                    AltAzTextBatch.Add(new Text3d(Coordinates.RADecTo3dAu(lc / 15 - 6, .4, 1), Coordinates.RADecTo3dAu(lc / 15 - 6, .5, 1), text, 75, .00018));
                }

                index = 0;
                for (double l = 0; l < 360; l += 90)
                {
                    for (double b = -80; b <= 80; b += 10)
                    {
                        if (b == 0)
                        {
                            continue;
                        }
                        string text = b.ToString();
                        if (b > 0)
                        {
                            text = "  +" + b.ToString();
                            AltAzTextBatch.Add(new Text3d(Coordinates.RADecTo3dAu(l / 15, b - .4, 1), Coordinates.RADecTo3dAu(l / 15, b - .3, 1), text, 75, .00018));
                        }
                        else
                        {
                            text = "  - " + text.Substr(1);
                            AltAzTextBatch.Add(new Text3d(Coordinates.RADecTo3dAu(l / 15, b + .4, 1), Coordinates.RADecTo3dAu(l / 15, b + .5, 1), text, 75, .00018));
                        }
                        index++;
                    }
                }
            }
            return;
        }
Example #6
0
        private static void MakeEclipticGridText()
        {
            Color    drawColor = Colors.White;
            double   obliquity = Coordinates.MeanObliquityOfEcliptic(SpaceTimeController.JNow);
            Matrix3d mat       = Matrix3d.RotationX((float)(-obliquity / 360.0 * (Math.PI * 2)));

            if (EclipticTextBatch == null)
            {
                EclipticTextBatch = new Text3dBatch(30);
                for (double l = 0; l < 360; l += 10)
                {
                    string text = "       " + l.ToString();
                    if (l < 10)
                    {
                        text = "   " + l.ToString();
                    }
                    else if (l < 100)
                    {
                        text = "     " + l.ToString();
                    }
                    EclipticTextBatch.Add(new Text3d(Vector3d.TransformCoordinate(Coordinates.RADecTo3dAu(l / 15, .4, 1), mat), Vector3d.TransformCoordinate(Coordinates.RADecTo3dAu(l / 15, .5, 1), mat), text, 75, .00018));
                }

                for (double l = 0; l < 360; l += 90)
                {
                    for (double b = -80; b <= 80; b += 10)
                    {
                        if (b == 0)
                        {
                            continue;
                        }
                        string text = b.ToString();
                        if (b > 0)
                        {
                            text = "  +" + b.ToString();
                            EclipticTextBatch.Add(new Text3d(Vector3d.TransformCoordinate(Coordinates.RADecTo3dAu(l / 15, b - .4, 1), mat), Vector3d.TransformCoordinate(Coordinates.RADecTo3dAu(l / 15, b - .3, 1), mat), text, 75, .00018));
                        }
                        else
                        {
                            text = "  - " + text.Substr(1);
                            EclipticTextBatch.Add(new Text3d(Vector3d.TransformCoordinate(Coordinates.RADecTo3dAu(l / 15, b + .4, 1), mat), Vector3d.TransformCoordinate(Coordinates.RADecTo3dAu(l / 15, b + .5, 1), mat), text, 75, .00018));
                        }
                    }
                }
            }
            return;
        }
Example #7
0
        private static void MakeEquitorialGridText()
        {
            if (EquTextBatch == null)
            {
                EquTextBatch = new Text3dBatch(30);
                int index = 0;

                for (int ra = 0; ra < 24; ra++)
                {
                    string text = ra.ToString() + " hr";
                    if (ra < 10)
                    {
                        text = "  " + ra.ToString() + " hr";
                    }

                    EquTextBatch.Add(new Text3d(Coordinates.RADecTo3dAu(ra + 0.005, 0.4, 1), Coordinates.RADecTo3dAu(ra + 0.005, 0.5, 1), text, 45, .00018));
                }

                index = 0;
                for (double ra = 0; ra < 24; ra += 3)
                {
                    for (double dec = -80; dec <= 80; dec += 10)
                    {
                        if (dec == 0)
                        {
                            continue;
                        }
                        string text = dec.ToString();
                        if (dec > 0)
                        {
                            text = "  +" + dec.ToString();
                            EquTextBatch.Add(new Text3d(Coordinates.RADecTo3dAu(ra, dec - .4, 1), Coordinates.RADecTo3dAu(ra, dec - .3, 1), text, 45, .00018));
                        }
                        else
                        {
                            text = "  - " + text.Substr(1);
                            EquTextBatch.Add(new Text3d(Coordinates.RADecTo3dAu(ra, dec + .4, 1), Coordinates.RADecTo3dAu(ra, dec + .5, 1), text, 45, .00018));
                        }

                        index++;
                    }
                }
            }
        }
Example #8
0
        private static void CreateCosmosVertexBuffer(RenderContext renderContext)
        {
            GL device = Tile.PrepDevice;

            int bucketCount = 256;

            if (cosmosSprites != null)
            {
                for (int ij = 0; ij < bucketCount; ij++)
                {
                    if (cosmosSprites[ij] != null)
                    {
                        cosmosSprites[ij] = null;
                    }
                }
            }
            cosmosSprites = null;
            double ecliptic = Coordinates.MeanObliquityOfEcliptic(SpaceTimeController.JNow) / 180.0 * Math.PI;

            cosmosSprites = new PointList[bucketCount];

            int[] indexList = new int[bucketCount];
            for (int i = 0; i < bucketCount; i++)
            {
                int count = galaxyVertexCounts[i];
                cosmosSprites[i] = new PointList(renderContext);
                cosmosSprites[i].DepthBuffered = false;
                indexList[i] = 0;
            }

            foreach (Galaxy galaxy in cosmos)
            {
                int bucket = galaxy.eTypeBucket;
                int index  = indexList[bucket];

                Vector3d pos = Coordinates.RADecTo3dAu(galaxy.RA, galaxy.Dec, (galaxy.Distance * UiTools.AuPerParsec * 1000000.0) / .73);
                pos.RotateX(ecliptic);
                galaxy.Position = pos;
                cosmosSprites[bucket].AddPoint(pos, Colors.White, new Dates(0, 1), (float)(1000000000f * galaxy.Size * 100));
                indexList[bucket]++;
            }

            cosmosReady = true;
        }
Example #9
0
        public void SetupMatricesSpace3d(double canvasWidth, double canvasHeight)
        {
            Lighting = false;
            if (!firstTimeInit)
            {
                galacticMatrix = Matrix3d.Identity;
                // -28.9361739586894, 17.7603329867975
                galacticMatrix.Multiply(Matrix3d.RotationY(-(270 - (17.7603329867975 * 15)) / 180.0 * Math.PI));
                galacticMatrix.Multiply(Matrix3d.RotationX(-((-28.9361739586894)) / 180.0 * Math.PI));
                galacticMatrix.Multiply(Matrix3d.RotationZ(((31.422052860102041270114993238783) - 90) / 180.0 * Math.PI));
                //galacticMatrix.Transpose();
                //galacticMatrix.Invert();
                firstTimeInit = true;
            }


            Space = true;
            RenderTriangle.CullInside = true;

            Matrix3d WorldMatrix = Matrix3d.Identity;

            if (Settings.Active.GalacticMode)
            {
                WorldMatrix.Multiply(galacticMatrix);
                WorldMatrix.Multiply(Matrix3d.RotationY(((az)) / 180.0 * Math.PI));
                WorldMatrix.Multiply(Matrix3d.RotationX(-((alt)) / 180.0 * Math.PI));
                double[] gPoint = Coordinates.GalactictoJ2000(az, alt);

                viewPoint        = Coordinates.RADecTo3dAu(gPoint[0] / 15, gPoint[1], 1.0);
                TargetCamera.Lng = this.RAtoViewLng(gPoint[0] / 15);
                TargetCamera.Lat = gPoint[1];
                ViewCamera.Lat   = TargetCamera.Lat;
                ViewCamera.Lng   = TargetCamera.Lng;
            }
            else
            {
                WorldMatrix.Multiply(Matrix3d.RotationY(-((ViewCamera.Lng - 90)) / 180.0 * Math.PI));
                WorldMatrix.Multiply(Matrix3d.RotationX(-((ViewCamera.Lat)) / 180.0 * Math.PI));
                viewPoint = Coordinates.RADecTo3dAu(RA, Dec, 1.0);
            }



            double camLocal = ((ViewCamera.Rotation /*+ 90*/));

            fovAngle = ((this.ViewCamera.Zoom) / FOVMULT) / Math.PI * 180;
            fovScale = (fovAngle / canvasHeight) * 3600;

            //Settings.Global.LocalHorizonMode = true;

            // altaz
            if (Settings.Active.LocalHorizonMode && backgroundImageset.DataSetType == ImageSetType.Sky)
            {
                Coordinates zenithAltAz = new Coordinates(0, 0);

                zenithAltAz.Az = 0;

                zenithAltAz.Alt = 0;

                Coordinates zenith = Coordinates.HorizonToEquitorial(zenithAltAz, SpaceTimeController.Location, SpaceTimeController.Now);
                //Coordinates zenith2 = Coordinates.HorizonToEquitorial(zenithAltAz, Coordinates.FromLatLng(1, 1), SpaceTimeController.Now);
                //Coordinates zenith3 = Coordinates.HorizonToEquitorial(zenithAltAz, Coordinates.FromLatLng(-1, 1), SpaceTimeController.Now);

                double raPart  = -((zenith.RA - 6) / 24.0 * (Math.PI * 2));
                double decPart = -(((zenith.Dec)) / 360.0 * (Math.PI * 2));
                string raText  = Coordinates.FormatDMS(zenith.RA);
                WorldMatrix = Matrix3d.RotationY(-raPart - Math.PI);
                WorldMatrix.Multiply(Matrix3d.RotationX(decPart));

                if (SpaceTimeController.Location.Lat < 0)
                {
                    WorldMatrix.Multiply(Matrix3d.RotationY(((az) / 180.0 * Math.PI)));

                    WorldMatrix.Multiply(Matrix3d.RotationX(((alt) / 180.0 * Math.PI)));
                    camLocal += Math.PI;
                }
                else
                {
                    WorldMatrix.Multiply(Matrix3d.RotationY(((-az) / 180.0 * Math.PI)));

                    WorldMatrix.Multiply(Matrix3d.RotationX(((-alt) / 180.0 * Math.PI)));
                }

                Coordinates currentRaDec = Coordinates.HorizonToEquitorial(Coordinates.FromLatLng(alt, az), SpaceTimeController.Location, SpaceTimeController.Now);

                ViewCamera.Lat = TargetCamera.Lat = currentRaDec.Dec;
                ViewCamera.Lng = TargetCamera.Lng = RAtoViewLng(currentRaDec.RA);
            }
            World     = WorldMatrix;
            WorldBase = WorldMatrix.Clone();
            // altaz



            double localZoomFactor = ViewCamera.Zoom;

            double FovAngle = ((localZoomFactor) / FOVMULT) / Math.PI * 180;

            CameraPosition = Vector3d.Create(0.0, 0.0, 0.0);
            // This is for distance Calculation. For space everything is the same distance, so camera target is key.

            View     = Matrix3d.LookAtLH(CameraPosition, Vector3d.Create(0.0, 0.0, -1.0), Vector3d.Create(Math.Sin(camLocal), Math.Cos(camLocal), 0.0));
            ViewBase = View.Clone();

            double m_nearPlane = .1;

            nearPlane  = .1f;
            Projection = Matrix3d.PerspectiveFovLH((localZoomFactor) / FOVMULT, (double)canvasWidth / (double)canvasHeight, .1, -2.0);


            SetMatrixes();

            MakeFrustum();
        }
Example #10
0
        public static bool DrawAltAzGrid(RenderContext renderContext, float opacity, Color drawColor)
        {
            Coordinates zenithAltAz = new Coordinates(0, 0);
            Coordinates zenith      = Coordinates.HorizonToEquitorial(zenithAltAz, SpaceTimeController.Location, SpaceTimeController.Now);

            double   raPart  = -((zenith.RA + 6) / 24.0 * (Math.PI * 2));
            double   decPart = -(((zenith.Dec)) / 360.0 * (Math.PI * 2));
            string   raText  = Coordinates.FormatDMS(zenith.RA);
            Matrix3d mat     = Matrix3d.RotationY((float)-raPart);

            mat.Multiply(Matrix3d.RotationX((float)decPart));
            mat.Invert();

            if (altAzLineList == null)
            {
                altAzLineList = new SimpleLineList();
                altAzLineList.DepthBuffered = false;

                for (double l = 0; l < 360; l += 10)
                {
                    for (double b = -80; b < 80; b += 2)
                    {
                        altAzLineList.AddLine(Coordinates.RADecTo3dAu(l / 15, b, 1), Coordinates.RADecTo3dAu(l / 15, b + 2, 1));
                    }
                }

                for (double b = -80; b <= 80; b += 10)
                {
                    for (double l = 0; l < 360; l += 5)
                    {
                        altAzLineList.AddLine(Coordinates.RADecTo3dAu(l / 15, b, 1), Coordinates.RADecTo3dAu((l + 5) / 15, b, 1));
                    }
                }

                int counter = 0;
                for (double l = 0; l < 360; l += 1)
                {
                    double b = 0.25;
                    switch (counter % 10)
                    {
                    case 0:
                        counter++;
                        continue;

                    case 5:
                        b = .5;
                        break;
                    }
                    counter++;

                    altAzLineList.AddLine(Coordinates.RADecTo3dAu(l / 15, b, 1), Coordinates.RADecTo3dAu(l / 15, -b, 1));
                }

                counter = 0;
                for (double l = 0; l < 360; l += 90)
                {
                    counter = 0;
                    for (double b = -80; b <= 80; b += 1)
                    {
                        double width = 0.5 / 2;
                        switch (counter % 10)
                        {
                        case 0:
                            counter++;
                            continue;

                        case 5:
                            width = .5;
                            break;
                        }
                        counter++;

                        altAzLineList.AddLine(Coordinates.RADecTo3dAu((l + width) / 15, b, 1), Coordinates.RADecTo3dAu((l - width) / 15, b, 1));
                    }
                }
            }

            Matrix3d matOldWorld     = renderContext.World.Clone();
            Matrix3d matOldWorldBase = renderContext.WorldBase.Clone();

            renderContext.WorldBase = Matrix3d.MultiplyMatrix(mat, renderContext.World);
            renderContext.World     = renderContext.WorldBase.Clone();
            renderContext.MakeFrustum();

            altAzLineList.ViewTransform = Matrix3d.InvertMatrix(mat);

            altAzLineList.DrawLines(renderContext, opacity, drawColor);

            renderContext.WorldBase = matOldWorldBase;
            renderContext.World     = matOldWorld;
            renderContext.MakeFrustum();
            return(true);
        }
Example #11
0
        public static bool DrawEquitorialGrid(RenderContext renderContext, float opacity, Color drawColor)
        {
            if (equLineList == null)
            {
                equLineList = new SimpleLineList();
                equLineList.DepthBuffered = false;

                for (double hour = 0; hour < 24; hour++)
                {
                    for (double dec = -80; dec < 80; dec += 2)
                    {
                        equLineList.AddLine(Coordinates.RADecTo3dAu(hour, dec, 1), Coordinates.RADecTo3dAu(hour, dec + 2, 1));
                    }
                }


                for (double dec = -80; dec <= 80; dec += 10)
                {
                    for (double hour = 0; hour < 23.8; hour += .2)
                    {
                        equLineList.AddLine(Coordinates.RADecTo3dAu(hour, dec, 1), Coordinates.RADecTo3dAu(hour + .2, dec, 1));
                        //todo fix for color bright
                    }
                }


                int counter = 0;
                for (double ra = 0; ra < 24; ra += .25)
                {
                    double dec = 0.5;

                    switch (counter % 4)
                    {
                    case 0:
                        counter++;
                        continue;

                    case 3:
                    case 1:
                        dec = .25;
                        break;
                    }
                    counter++;

                    equLineList.AddLine(Coordinates.RADecTo3dAu(ra, dec, 1), Coordinates.RADecTo3dAu(ra, -dec, 1));
                }
                counter = 0;
                for (double ra = 0; ra < 24; ra += 3)
                {
                    counter = 0;
                    for (double dec = -80; dec <= 80; dec += 1)
                    {
                        double width = 0.5 / 30;
                        switch (counter % 10)
                        {
                        case 0:
                            counter++;
                            continue;

                        case 5:
                            width = .5 / 15;
                            break;
                        }

                        counter++;

                        equLineList.AddLine(Coordinates.RADecTo3dAu(ra + width, dec, 1), Coordinates.RADecTo3dAu(ra - width, dec, 1));
                    }
                }
            }

            equLineList.DrawLines(renderContext, opacity, drawColor);

            return(true);
        }
Example #12
0
        public static bool DrawEclipticGrid(RenderContext renderContext, float opacity, Color drawColor)
        {
            if (eclipticLineList == null)
            {
                eclipticLineList = new SimpleLineList();
                eclipticLineList.DepthBuffered = false;

                double   obliquity = Coordinates.MeanObliquityOfEcliptic(2451545);
                Matrix3d mat       = Matrix3d.RotationX((-obliquity / 360.0 * (Math.PI * 2)));


                for (double l = 0; l < 360; l += 10)
                {
                    for (double b = -80; b < 80; b += 2)
                    {
                        eclipticLineList.AddLine(Vector3d.TransformCoordinate(Coordinates.RADecTo3dAu(l / 15, b, 1), mat), Vector3d.TransformCoordinate(Coordinates.RADecTo3dAu(l / 15, b + 2, 1), mat));
                    }
                }

                for (double b = -80; b <= 80; b += 10)
                {
                    for (double l = 0; l < 360; l += 5)
                    {
                        eclipticLineList.AddLine(Vector3d.TransformCoordinate(Coordinates.RADecTo3dAu(l / 15, b, 1), mat), Vector3d.TransformCoordinate(Coordinates.RADecTo3dAu((l + 5) / 15, b, 1), mat));
                    }
                }

                int counter = 0;
                for (double l = 0; l < 360; l += 1)
                {
                    double b = 0.25;
                    switch (counter % 10)
                    {
                    case 0:
                        counter++;
                        continue;

                    case 5:
                        b = .5;
                        break;
                    }
                    counter++;

                    eclipticLineList.AddLine(Vector3d.TransformCoordinate(Coordinates.RADecTo3dAu(l / 15, b, 1), mat), Vector3d.TransformCoordinate(Coordinates.RADecTo3dAu(l / 15, -b, 1), mat));
                }

                counter = 0;
                for (double l = 0; l < 360; l += 90)
                {
                    counter = 0;
                    for (double b = -80; b <= 80; b += 1)
                    {
                        double width = 0.5 / 2;
                        switch (counter % 10)
                        {
                        case 0:
                            counter++;
                            continue;

                        case 5:
                            width = .5;
                            break;
                        }
                        counter++;

                        eclipticLineList.AddLine(Vector3d.TransformCoordinate(Coordinates.RADecTo3dAu((l + width) / 15, b, 1), mat), Vector3d.TransformCoordinate(Coordinates.RADecTo3dAu((l - width) / 15, b, 1), mat));
                    }
                }
            }

            eclipticLineList.DrawLines(renderContext, opacity, drawColor);

            return(true);
        }