Example #1
0
        /// <summary>
        /// eine von aussen auf die Hauptsonne zufliegende Sonne mit Planeten wird erstellt
        /// </summary>
        private void AddComingSun()
        {
            if (suncount < _Light.Length - 1)
            {
                float Massfak = (float)rnd.Next(1, 3) * 5 * PlanetAdvanced2.initSunMass;
                float Mass    = (float)rnd.NextDouble() * Massfak;

                Point3 Pos = RndPosToSun(Sun, true, true);
                Pos = (Pos - Sun.Position) * (float)(rnd.Next(10, 20)); // Position weiter von der Sonne entfernen.

                Point3 Dir = new Point3();
                Dir.assign(Sun.Position - Pos);                    // Bewegung auf die Sonne zu.

                Dir.x += (float)rnd.NextDouble();                  // ein wenig Varianz in der Bewegung.
                Dir.y += (float)rnd.NextDouble();                  // ein wenig Varianz in der Bewegung.
                Dir.z += (float)rnd.NextDouble();                  // ein wenig Varianz in der Bewegung.

                Dir.Normalize();                                   // BewegungsRichtung normalisieren.

                Dir *= (float)((rnd.NextDouble() * 3) + 2f) * 10f; // Speed zurechnen;

                float[] Color = { (float)rnd.NextDouble(), (float)rnd.NextDouble(), (float)rnd.NextDouble() };
                suncount++;
                o2Sun __Sun = new o2Sun(Pos, Dir, Mass, Color, _Light[suncount]);
                Objects.Add(__Sun);
                AddPlanet(__Sun, rnd.Next(1, 9)); // 1 bis 8 Planeten auf die Umlaufbahn der neuen Sonne bringen.
            }
        }
Example #2
0
        /// <summary>
        /// Initialisiertung Tangentialebene in P=(x0,y0,z0)
        /// </summary>
        private void initFunctionTangent()
        {
            double dif = 4f;

            m_lPointsFunctionTangent.Clear();

            double x  = x0 - dif; // links unten
            double y  = y0 - dif;
            double z  = tangentPlane(x, y);
            Point3 lu = new Point3((float)x, (float)y, (float)z);

            x = x0 + dif; // rechts unten
            y = y0 - dif;
            z = tangentPlane(x, y);
            Point3 ru = new Point3((float)(x), (float)y, (float)z);

            x = x0 - dif; // links oben
            y = y0 + dif;
            z = tangentPlane(x, y);
            Point3 lo = new Point3((float)(x), (float)(y), (float)z);
            // rechts oben
            Point3 ro = new Point3((float)(x), (float)(y), (float)z);

            Point3 lr = new Point3(lu.x - ru.x, lu.y - ru.y, lu.z - ru.z);
            Point3 ou = new Point3(lo.x - lu.x, lo.y - lu.y, lo.z - lu.z);

            lr.Normalize();
            ou.Normalize();
            z0 = (float)solvef(x0, y0);

            Point3 X0 = new Point3(x0, y0, z0);

            lr *= dif / 2;
            ou *= dif / 2;

            lu.assign(X0);
            lu -= lr;
            lu -= ou;

            lo.assign(X0);
            lo -= lr;
            lo += ou;

            ro.assign(X0);
            ro += lr;
            ro += ou;

            ru.assign(X0);
            ru += lr;
            ru -= ou;

            m_lPointsFunctionTangent.Add(new Square(lu, lo, ro, ru));
        }
Example #3
0
        /// <summary>
        /// Fügt einem Zentralobjekt untergeordnete es umkreisende Objekte hinzu
        /// </summary>
        /// <param name="_ZentralObjekt">Dies ist das Zentralobjekt um welches die hinzugefügten kreisen sollen</param>
        /// <param name="cnt">Anzahl der das Zentralobjekt umkreisenden Objekte</param>
        private void AddPlanet(o2Object _ZentralObjekt, int cnt)
        {
            bool SunIsParent = _ZentralObjekt is o2Sun; // ist das Zentralobjekt eine Sonne?

            for (int i = 0; i < cnt; i++)
            {
                float Mass = 1f;
                if (SunIsParent) // Planet
                {
                    int ps = rnd.Next(28, 30);
                    Mass = (float)rnd.NextDouble() * (float)Math.Pow(10, ps) * PlanetAdvanced2.UniFak; // Größe Abhängig von Basisgröße der Planeten
                }
                else // Mond.
                {
                    float f = rnd.Next(80, 1000);   // Faktor um wie viel der Mond kleiner sein soll, als der Körper um den er kreist.
                    Mass = _ZentralObjekt.Mass / f; // Erd-Mond ist ca. 1/81 der Erdmasse. Da er der Größte im Sonnensystem ist, nehm ich das Verhältnis als max. an.
                }

                Point3 Pos      = RndPosToSun(_ZentralObjekt, false, SunIsParent); // Position soll relativ zum Zentralkörper sein
                float  distance = Point3.Distance(_ZentralObjekt.Position, Pos);

                Point3 Dir = MM.MatDotPoint(RotMatrix90z(), Pos - _ZentralObjekt.Position);                    // Richtung 90Grad zum Sonnenwinkel
                Dir.Normalize();
                Dir *= (float)Math.Sqrt(PlanetAdvanced2.G * _ZentralObjekt.Mass / distance);                   // *fak(); // 1. kosmische Geschwindigkeit (Rotation auf Kreisbahn).
                Dir += Dir * ((float)rnd.NextDouble() / 10f);                                                  //* fak()); // ein wenig Varianz, um es interessannt zu machen.
                Dir += _ZentralObjekt.Direction;                                                               // Bewegung der Bezugssonne draufrechnen, damit Sich Planet mitbewegt.
                float[] Color = { (float)rnd.NextDouble(), (float)rnd.NextDouble(), (float)rnd.NextDouble() }; // Farbe ist zufällig

                o2Object p = new o2Object(Pos, Dir, Mass, Color, null);

                Objects.Add(p);
                getList().Add(p);

                if (SunIsParent)
                {
                    int c = rnd.Next(0, 4);
                    AddPlanet(p, c);
                }
            }
        }
Example #4
0
        private void AddPlanet()
        {
            lock (Objects)
            {
                Point3 P1Pos = new Point3(0f, 0f, 0f);

                int fak = rnd.Next(2) - 1 < 0 ? -1 : 1;
                P1Pos.x = fak * (float)rnd.Next(100, 100 + (int)Sun.Size);
                fak     = rnd.Next(2) - 1 < 0 ? -1 : 1;
                P1Pos.y = fak * (float)rnd.Next(100, 100 + (int)Sun.Size);

                Point3 P1Dir = new Point3(0f, 0f, 0f);
                Matrix rot   = new Matrix();
                Point3 ZAxis = new Point3(0f, 0f, 1f);
                rot.RotMatrix(90, ZAxis);
                P1Dir = MM.MatDotPoint(rot, P1Pos);
                P1Dir.Normalize();
                P1Dir = P1Dir * rnd.NextDouble() * 3f;

                Objects.Add(new oPlanet(P1Pos, P1Dir, Sun, ((float)rnd.NextDouble() * 3f) + 2f, (float)rnd.NextDouble(), (float)rnd.NextDouble(), (float)rnd.NextDouble()));
            }
        }
Example #5
0
        /// <summary>
        /// Eine um die Hauptsonne kreisende Sonne wird erstellt. Diese kann auch größer sein, was sie aber nicht zur Hauptsonne macht.
        /// </summary>
        private void AddSun()
        {
            if (suncount < _Light.Length - 1)
            {
                float  Massfak = (float)rnd.Next(1, 3) * 5 * PlanetAdvanced2.initSunMass;
                float  Mass    = (float)rnd.NextDouble() * Massfak;
                Point3 Pos     = RndPosToSun(Sun, true, false);                  // Zufällige Position bezgl der Sonne

                Point3 Dir = MM.MatDotPoint(RotMatrix90z(), Pos - Sun.Position); // Richtung 90Grad zum SonnenVektor

                Dir.Normalize();                                                 // BewegungsRichtung normalisieren.
                //Dir *= (float)((rnd.NextDouble() * 3) + 2f) * 40f; // Speed zurechnen. Kosmische Gesch. schlug hier immer fehl.

                float distance = Point3.Distance(Sun.Position, Pos);

                Dir *= (float)Math.Sqrt(G * Sun.Mass / distance); // *fak(); // 1. kosmische Geschwindigkeit (Rotation auf Kreisbahn).
                Dir += Sun.Direction;                             // Bewegung der Bezugssonne draufrechnen, damit Sich Planet mitbewegt.

                float[] Color = { (float)rnd.NextDouble(), (float)rnd.NextDouble(), (float)rnd.NextDouble() };
                suncount++; // Sonnenzähler erhöhen. (wichtig für Lichtquellen);
                Objects.Add(new o2Sun(Pos, Dir, Mass, Color, _Light[suncount]));
            }
        }
Example #6
0
        private void AddPlanet()
        {
            lock (Objects)
            {
                Point3 P1Pos = new Point3(0f, 0f, 0f);

                int fak = rnd.Next(2) - 1 < 0 ? -1 : 1;
                P1Pos.x = fak * (float)rnd.Next(100, 100 + (int)Sun.Size);
                fak = rnd.Next(2) - 1 < 0 ? -1 : 1;
                P1Pos.y = fak * (float)rnd.Next(100, 100 + (int)Sun.Size);

                Point3 P1Dir = new Point3(0f, 0f, 0f);
                Matrix rot = new Matrix();
                Point3 ZAxis = new Point3(0f, 0f, 1f);
                rot.RotMatrix(90, ZAxis);
                P1Dir = MM.MatDotPoint(rot, P1Pos);
                P1Dir.Normalize();
                P1Dir = P1Dir * rnd.NextDouble() * 3f;

                Objects.Add(new oPlanet(P1Pos, P1Dir, Sun, ((float)rnd.NextDouble() * 3f) + 2f, (float)rnd.NextDouble(), (float)rnd.NextDouble(), (float)rnd.NextDouble()));
            }
        }
Example #7
0
        /// <summary>
        /// Initialisiertung Tangentialebene in P=(x0,y0,z0)
        /// </summary>
        private void initFunctionTangent()
        {
            double dif = 4f;

            m_lPointsFunctionTangent.Clear();

            double x = x0 - dif; // links unten
            double y = y0 - dif;
            double z = tangentPlane(x, y);
            Point3 lu = new Point3((float)x, (float)y, (float)z);

            x = x0 + dif; // rechts unten
            y = y0 - dif;
            z = tangentPlane(x, y);
            Point3 ru = new Point3((float)(x), (float)y, (float)z);

            x = x0 - dif; // links oben
            y = y0 + dif;
            z = tangentPlane(x, y);
            Point3 lo = new Point3((float)(x), (float)(y), (float)z);
            // rechts oben
            Point3 ro = new Point3((float)(x), (float)(y), (float)z);

            Point3 lr = new Point3(lu.x - ru.x, lu.y - ru.y, lu.z - ru.z);
            Point3 ou = new Point3(lo.x - lu.x, lo.y - lu.y, lo.z - lu.z);
            lr.Normalize();
            ou.Normalize();
            z0 = (float)solvef(x0, y0);

            Point3 X0 = new Point3(x0, y0, z0);

            lr *= dif / 2;
            ou *= dif / 2;

            lu.assign(X0);
            lu -= lr;
            lu -= ou;

            lo.assign(X0);
            lo -= lr;
            lo += ou;

            ro.assign(X0);
            ro += lr;
            ro += ou;

            ru.assign(X0);
            ru += lr;
            ru -= ou;

            m_lPointsFunctionTangent.Add(new Square(lu, lo, ro, ru));
        }
Example #8
0
        /// <summary>
        /// eine von aussen auf die Hauptsonne zufliegende Sonne mit Planeten wird erstellt
        /// </summary>
        private void AddComingSun()
        {
            if (suncount < _Light.Length - 1)
            {
                float Massfak = (float)rnd.Next(1, 3) * 5 * PlanetAdvanced2.initSunMass;
                float Mass = (float)rnd.NextDouble() * Massfak;

                Point3 Pos = RndPosToSun(Sun, true,true);
                Pos = (Pos - Sun.Position) * (float)(rnd.Next(10, 20)); // Position weiter von der Sonne entfernen.

                Point3 Dir = new Point3();
                Dir.assign(Sun.Position - Pos); // Bewegung auf die Sonne zu.

                Dir.x += (float)rnd.NextDouble(); // ein wenig Varianz in der Bewegung.
                Dir.y += (float)rnd.NextDouble(); // ein wenig Varianz in der Bewegung.
                Dir.z += (float)rnd.NextDouble(); // ein wenig Varianz in der Bewegung.

                Dir.Normalize(); // BewegungsRichtung normalisieren.

                Dir *= (float)((rnd.NextDouble() * 3) + 2f) * 10f; // Speed zurechnen;

                float[] Color = { (float)rnd.NextDouble(), (float)rnd.NextDouble(), (float)rnd.NextDouble() };
                suncount++;
                o2Sun __Sun = new o2Sun(Pos, Dir, Mass, Color, _Light[suncount]);
                Objects.Add(__Sun);
                AddPlanet(__Sun, rnd.Next(1, 9)); // 1 bis 8 Planeten auf die Umlaufbahn der neuen Sonne bringen.
            }
        }