Example #1
0
        public void generate_irregular_galaxy(bool rotate, int galaxysize, int starscount)//fix
        {
            Double x;
            Double y;
            Double r;
            Double t;
            Double z     = 0;
            Double curve = 0;
            Random rand  = new Random();

            for (int j = 0; j < (starscount / 80); j++)
            {
                r = 0;
                t = 0;
                for (int i = 0; i < 40; i++)
                {
                    r    += rand.Next(4) + 2 + galaxysize;
                    curve = Math.Pow((r - 2), 2);
                    curve = curve / 150;

                    t += 0.2;
                    z  = t + (rand.NextDouble() - 0.5) * 2;
                    x  = curve + rand.Next(30) - 15;
                    y  = curve * Math.Sin(z) + rand.Next(100) - 15;

                    StarSystem s = new StarSystem();
                    s.x    = x;
                    s.y    = -10.0 + rand.NextDouble() * 20.0;
                    s.z    = y;
                    s.type = rand.Next(7);  //type impact on size and color
                    s.name = "";
                    switch (s.type)
                    {
                    //O - Blue, t =30 000 — 60 000 K
                    case 0:
                        s.br = BlueBrush;
                        break;

                    //B - Light blue, t = 10 500 — 30 000 K
                    case 1:
                        s.br = LightBlueBrush;
                        break;

                    //A - White, t = 7500—10 000 K
                    case 2:
                        s.br = WhiteBrush;
                        break;

                    //F - Light Yellow, t = 6000—7200 K
                    case 3:
                        s.br = LightYellowBrush;
                        break;

                    //G - Yellow, t = 5500 — 6000 K
                    case 4:
                        s.br = YellowBrush;
                        break;

                    //K - Orange, t = 4000 — 5250 K
                    case 5:
                        s.br = OrangeBrush;
                        break;

                    //M - Red, t = 2600 — 3850 K
                    case 6:
                        s.br = RedBrush;
                        break;
                    }
                    galaxy.stars.Add(s);
                }
            }
        }
Example #2
0
        public void generate_sphere_galaxy(bool rotate, int galaxysize, int starscount)
        {
            Double x;
            Double y;
            Double z = 1;
            Double r;
            Double t;
            Double tX;
            Double tY;
            Double tZ;

            Random rand = new Random();

            t = 0;
            for (int j = 0; j < starscount / 40; j++)
            {
                r  = 0;
                t += 5;
                for (int i = 0; i < 40; i++)
                {
                    r += 1;

                    x = Math.Cos(r) * 100 * (galaxysize + 1);
                    y = Math.Sin(r) * 100 * (galaxysize + 1);

                    tX = x * Math.Cos(t) + z * Math.Sin(t);
                    tZ = x * Math.Sin(t) - z * Math.Cos(t);
                    tY = y * Math.Cos(t) + tZ * Math.Sin(t);

                    StarSystem s = new StarSystem();
                    s.x    = tX;
                    s.y    = tZ;
                    s.z    = tY;
                    s.type = rand.Next(7);  //type impact on size and color
                    s.name = "";
                    switch (s.type)
                    {
                    //O - Blue, t =30 000 — 60 000 K
                    case 0:
                        s.br = BlueBrush;
                        break;

                    //B - Light blue, t = 10 500 — 30 000 K
                    case 1:
                        s.br = LightBlueBrush;
                        break;

                    //A - White, t = 7500—10 000 K
                    case 2:
                        s.br = WhiteBrush;
                        break;

                    //F - Light Yellow, t = 6000—7200 K
                    case 3:
                        s.br = LightYellowBrush;
                        break;

                    //G - Yellow, t = 5500 — 6000 K
                    case 4:
                        s.br = YellowBrush;
                        break;

                    //K - Orange, t = 4000 — 5250 K
                    case 5:
                        s.br = OrangeBrush;
                        break;

                    //M - Red, t = 2600 — 3850 K
                    case 6:
                        s.br = RedBrush;
                        break;
                    }
                    galaxy.stars.Add(s);
                }
            }

            //MessageBox.Show(galaxy.stars.Count.ToString(), "Draw Galaxy", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
        }
Example #3
0
        public void generate_spiral_galaxy(bool rotate, int galaxysize, int starscount)
        {
            Double x;
            Double y;
            Double z = 0;
            Double r;           //radius
            Double t;           //space beetwen stars
            Double curve = 0;   //statching spirals
            Random rand  = new Random();

            //we got 40 times for inner loop, so we need divide all stars coun for 40
            //and we have 2 spirals, so divide agan dy 40
            //as result (starscount/80)
            for (int j = 0; j < (starscount / 80); j++)
            {
                r = 0;
                t = 0;
                for (int i = 0; i < 40; i++)
                {
                    r    += rand.Next(4) + 2 + galaxysize;
                    curve = Math.Pow((r - 4), 2);
                    curve = curve / 150;
                    t    += 0.2;

                    z = t + (rand.NextDouble() - 0.5) * 2;
                    x = curve * Math.Cos(z) + rand.Next(30) - 15;
                    y = curve * Math.Sin(z) + rand.Next(30) - 15;

                    if (rotate == true)
                    {
                        x = -x;
                        y = -y;
                    }

                    StarSystem s = new StarSystem();
                    s.x    = x;
                    s.y    = -5.0 + rand.NextDouble() * 10.0;
                    s.z    = y;
                    s.type = rand.Next(7);  //type impact on size and color
                    s.name = "";
                    switch (s.type)
                    {
                    //O - Blue, t =30 000 — 60 000 K
                    case 0:
                        s.br = BlueBrush;
                        break;

                    //B - Light blue, t = 10 500 — 30 000 K
                    case 1:
                        s.br = LightBlueBrush;
                        break;

                    //A - White, t = 7500—10 000 K
                    case 2:
                        s.br = WhiteBrush;
                        break;

                    //F - Light Yellow, t = 6000—7200 K
                    case 3:
                        s.br = LightYellowBrush;
                        break;

                    //G - Yellow, t = 5500 — 6000 K
                    case 4:
                        s.br = YellowBrush;
                        break;

                    //K - Orange, t = 4000 — 5250 K
                    case 5:
                        s.br = OrangeBrush;
                        break;

                    //M - Red, t = 2600 — 3850 K
                    case 6:
                        s.br = RedBrush;
                        break;
                    }
                    galaxy.stars.Add(s);
                }
            }
        }