CODE MÔ PHỎNG HIỂN THỊ MỤC TIÊU RADAR TRÊN MÀN HÌNH PC Form1 using using using using using using using using using using using using System; System.Collections; System.Collections.Generic; System.Drawing; System.Drawing.Design; System.Drawing.Drawing2D; System.Drawing.Imaging; System.Drawing.Text; System.Windows.Forms; System.Threading; System.ComponentModel; System.Windows; namespace Radar { public partial class MainForm : Form { Radar _radar; Coordinate td1 = new Coordinate(1,400, 400, 4000, 1000, "abc"); Coordinate td2 = new Coordinate(2, 200, 200, 4000, 1000, "abc"); List qd1 = new List(); System.Windows.Forms.Timer t = new System.Windows.Forms.Timer(); int speed = 400; public static List listTarget = new List(); public static List listTenlua = new List(); public MainForm() { InitializeComponent(); // internal item update timer t.Interval = 500; t.Tick += new EventHandler(t_Tick); t.Enabled = true; backgroundWorker1.DoWork+=new System.ComponentModel.DoWorkEventHandler(backgroundWorker1_DoWork); } void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { System.Media.SoundPlayer myPlayer = new System.Media.SoundPlayer(); myPlayer.SoundLocation = @"c:\sound1.wav"; myPlayer.Play(); } //update vi tri cac May bay khoang thoi gian = t.Interval void t_Tick(object sender, EventArgs e) { double max_angle = _radar.maxAngle * 0.0174532925d; if (listTarget.Count == 0) { lvTarget.Items.Clear(); cbTarget.Items.Clear(); cbTarget.Text = ""; } else { //lvTarget.Items.Clear(); cbTarget.Items.Clear(); // select which of the three items to update foreach (FlyingItem item in listTarget) { //khoang cach di duoc cua muc tieu s double s = item._current.velocity * 1000 / (3600000 * 3); //toa tuong doi giua diem di va diem den double x = item._to.X - item._current.X; double y = item._to.Y - item._current.Y; double chenhlech_kc = Math.Sqrt(x * x + y * y); double gocngang = Math.Acos(x / chenhlech_kc); //doi sang gocngang = gocngang / 0.0174532925d; if (y < 0) { gocngang = 360d - gocngang; } //doi sang radian de tinh sin va cos gocngang *= 0.0174532925d; double z = item._to.Z - item._current.Z; double gocdung = Math.Asin(z / Math.Sqrt(z * z + chenhlech_kc * chenhlech_kc)); //toa muc tieu sau 1s double z1 = item._current.Z + (s * Math.Sin(gocdung)); double chenhlech_kc1 = (float)(s * Math.Abs(Math.Cos(gocdung))); double x1 = item._current.X + chenhlech_kc1 * Math.Cos(gocngang); double y1 = item._current.Y + chenhlech_kc1 * Math.Sin(gocngang); Coordinate current = new Coordinate(item._current.stt, x1, y1, z1, item._current.velocity, "abc"); //gan diem diem bat dau item._current = current; if (z >= 0) { item._current = current; if (z1 >= item._to.Z) { for (int k = 0; k < item.airline.Count; k++) { Coordinate td = item.airline[k]; if (td1.stt == item._to.stt) item._to = item.airline[k + 1]; else { } } } else { } } else { item._current = current; if (z1 Radar.getAzimuth(current) && _radar._az - 20 < Radar.getAzimuth(current) && Radar.getRange(current) item._current.Z) { bool Flag = true; for (int j = 0; j < lvTarget.Items.Count; j++) { if (lvTarget.Items[j].Text.Trim() == item.ID.ToString().Trim()) { ListViewItem lvItem = lvTarget.Items[j]; lvItem.Text = item.ID.ToString(); lvItem.SubItems[1].Text = (item._category); lvItem.SubItems[2].Text = (Radar.getAzimuth(item._current).ToString()); int rg = (int)Radar.getRange(item._current); lvItem.SubItems[3].Text = (rg.ToString()); lvItem.SubItems[4].Text = (item._current.Z.ToString()); lvItem.SubItems[5].Text = (item._current.velocity.ToString()); Flag = false; } } if (Flag) { ListViewItem lvItem = new ListViewItem(); lvItem.Text = item.ID.ToString(); lvItem.SubItems.Add(item._category); lvItem.SubItems.Add(Radar.getAzimuth(item._current).ToString()); int rg = (int)Radar.getRange(item._current); } lvItem.SubItems.Add(rg.ToString()); lvItem.SubItems.Add(item._current.Z.ToString()); lvItem.SubItems.Add(item._current.velocity.ToString()); lvItem.BackColor = item._color; lvTarget.Items.Add(lvItem); if (Radar.getRange(current) 180) Y = range * Math.Sin(360 - a); else } Y = range * Math.Sin(a); velocity = speed; alpha = a; beta = b; r = radius; } } KẾT QUẢ MÔ PHỎNG Giao diện : Dạng quét thẳng : Dạng quét tròn: Dạng quét xoắn: ... MessageBox.Show( "Mục tiêu bị tiêu diệt"); } else { item._to = mb._current; _radar. AddItem(item); if ( _radar. _az + 20 > Radar. getAzimuth(current) && _radar. _az - 20 < Radar. getAzimuth(current) && Radar. getRange(current)... } _radar. AddItem(item); _radar. ImageUpdate += new ImageUpdateHandler( _radar_ ImageUpdate); if ( _radar. _az + 20 > Radar. getAzimuth(current) && _radar. _az - 20 < Radar. getAzimuth(current) && Radar. getRange(current)... sender, EventArgs e) { _radar = new Radar( pictureBox1.Width,pQuetThang.Width,pQuetThang.Height,pQuetVong.Width); _radar. numberOfSpirals = 3; pictureBox1.Image = _radar. Image; _radar. ImageUpdate +=