Beispiel #1
0
        /// <summary>
        /// 生成按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, EventArgs e)
        {
            int    AllStar = 200;
            Random rd      = new Random(DateTime.Now.Second);
            Bitmap pic1    = (Bitmap)pictureBox1.Image;

            bmpWidth = pic1.Width;
            bmpHigth = pic1.Height;
            for (int i = 0; i < AllStar; i++)
            {
                //W:1519 H:657
                int roil   = rd.Next(1, 10);
                int localx = rd.Next(pic1.Width - 10);
                int localy = rd.Next(pic1.Height - 10);
                int direct = rd.Next(0, 360);
                roillist.Add(roil);
                localxlist.Add(localx);
                localylist.Add(localy);
                EarthInfo eif = new EarthInfo(roil, localx, localy, i, direct);
                g_listEarth.Add(eif);
            }
            this.pictureBox1.Invalidate();
            //get all earth
            EarthCacl.calcAllEarthDiss(ref g_listEarth);
        }
Beispiel #2
0
 public static void calcAllEarthDiss(ref List <EarthInfo> listData)
 {
     foreach (var eti in listData)
     {
         eti.dictOtherDiss.Clear();
         foreach (var calcEti in listData)
         {
             if (eti == calcEti || eti.dictOtherDiss.ContainsKey(calcEti.name) == true)
             {
                 continue;
             }
             double diss = EarthCacl.getDiss(eti.localx, eti.localy, calcEti.localx, calcEti.localy);
             eti.dictOtherDiss[calcEti.name] = diss;
             calcEti.dictOtherDiss[eti.name] = diss;
         }
     }
 }
Beispiel #3
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            //combine earth
            EarthCacl.combineEarth(ref g_listEarth);
            //repoint
            this.pictureBox1.Invalidate();
            //clac next point local
            EarthCacl.calcEarthExec(ref g_listEarth);
            //get disconect data
            EarthCacl.calcAllEarthDiss(ref g_listEarth);
            //get earth direct
            //F = G*M*m/R2
            //V = V0 + at;
            //direct =

            clacCount++;
            richTextBox1.AppendText(clacCount.ToString() + "\r\n");
        }
Beispiel #4
0
        /// <summary>
        /// 融合两个圆点
        /// </summary>
        /// <param name="listData"></param>
        public static void combineEarth(ref List <EarthInfo> listData)
        {
            EarthInfo[] buffTempEti = new EarthInfo[listData.Count];
            int         index       = 0;

            foreach (var eti in listData)
            {
                try
                {
                    if (buffTempEti.Contains(eti) == true)
                    {
                        continue;
                    }
                    foreach (KeyValuePair <string, double> kvp in eti.dictOtherDiss)
                    {
                        EarthInfo tempEti = EarthCacl.getEarthForName(kvp.Key, listData);
                        // if tempEti will move
                        if (buffTempEti.Contains(tempEti) == true)
                        {
                            continue;
                        }
                        if (tempEti.roil + eti.roil >= (int)kvp.Value)
                        {
                            // 发生融合
                            eti.localx = (int)((eti.localx + tempEti.localx) / 2);
                            eti.localy = (int)((eti.localy + tempEti.localy) / 2);
                            eti.calcEarthNewRoil(tempEti.roil);
                            eti.oldName.Add(tempEti.name);
                            //移除这个位
                            buffTempEti[index++] = tempEti;
                        }
                    } //foreach
                }     //try
                catch (Exception)
                {
                    System.Console.Write("name:" + eti.name + " 不存在");
                }
            }// foreach
            foreach (var tt in buffTempEti)
            {
                listData.Remove(tt);
            }
        }