Example #1
0
        public void GenerateBlackHole(int mass = 5000000)
        {
            var blackHole = new RoundBodyModel((ushort) (Bodies.Any() ? Bodies.Max(x => x.Id) + 1
                                                                      : 1))
            {
                Mass = new Mass(mass),
                CenterX = new Coordinate(MaxX/2),
                CenterY = new Coordinate(MaxY/2),
            };

            blackHole.SetDiameter();

            Bodies.ForEach(x =>
                          {
                              var pair = new BodiesPair(blackHole, x);
                              Pairs.Add(pair.Id, pair);

                          });

            Bodies.Add(blackHole);
        }
Example #2
0
        public void GenerateBodies(int count = BodiesCount)
        {
            var random = new Random();

            for (int i = 0; i < count; i++)
            {
                var temp = new RoundBodyModel((ushort) i)
                {
                    Mass = new Mass(random.Next(MaxMass)),
                    CenterX = new Coordinate(random.Next(MaxX)),
                    CenterY = new Coordinate(random.Next(MaxY)),
                    Speed = new Speed(random.Next(-MaxSpeed, MaxSpeed), random.Next(-MaxSpeed, MaxSpeed))
                };

                temp.SetDiameter();

                Bodies.ForEach(x =>
                              {
                                  var pair = new BodiesPair(x, temp);
                                  Pairs.Add(pair.Id, pair);
                              });

                Bodies.Add(temp);
            }
        }