Exemple #1
0
        private void buttonCalc_Click(object sender, EventArgs e)
        {
            locations[0].rssi = StringToInt(textBoxRSSI1.Text);
            locations[1].rssi = StringToInt(textBoxRSSI2.Text);
            locations[2].rssi = StringToInt(textBoxRSSI3.Text);
            int i;

            for (i = 0; i < 3; i++)
            {
                borders[i] = new BorderLine(locations[i % 3], locations[(i + 1) % 3]);
            }
            DrawMap();
        }
Exemple #2
0
        private void DrawMap()
        {
            var g = map.CreateGraphics();

            g.Clear(Color.White);
            int i;

            for (i = 0; i < 3; i++)
            {
                // 受信機の位置
                float x = locations[i].x, y = locations[i].y;
                g.FillEllipse(Brushes.Blue, x - 10, y - 10, 20, 20);
            }
            for (i = 0; i < 3; i++)
            {
                BorderLine b = borders[i];
                // 境界
                if (!b.isReady)
                {
                    continue;
                }
                if (b.isLine)
                {
                    // 線
                    if (b.vy == 0)
                    {
                        // x軸に平行
                        g.DrawLine(Pens.Black, 0, b.y, map.Width, b.y);
                    }
                    else
                    {
                        float t      = -b.x / b.vx;
                        float line_b = b.y + t * b.vy;       // y軸切片
                        float line_a = (b.y - line_b) / b.x; // 傾き
                        float left_y = line_a * map.Width + line_b;
                        g.DrawLine(Pens.Black, 0, line_b, map.Width, left_y);
                    }
                }
                else
                {
                    // 円
                    g.DrawEllipse(Pens.Black, b.x - b.r, b.y - b.r, b.r * 2, b.r * 2);
                }
            }
        }