Exemplo n.º 1
0
        public float vx, vy;  // 方向ベクトル(isLine==true)

        public BorderLine(LocationStruct p1, LocationStruct p2)
        {
            isLine = true;
            x      = y = r = vx = vy = 0;

            isReady = p1.rssi > 0 && p2.rssi > 0;
            if (!isReady)
            {
                return;
            }
            float m, n;

            // 強度から距離の比を決める
            m      = (float)1.0 / Math.Abs(p1.rssi);
            n      = (float)1.0 / Math.Abs(p2.rssi);
            isLine = (p1.rssi == p2.rssi);
            if (isLine)
            {
                // 結果は直線
                x  = (p1.x * n + p2.x * m) / (m + n);
                y  = (p1.y * n + p2.y * m) / (m + n);
                vx = (p1.y - p2.y);
                vy = (p2.x - p1.x);
            }
            else
            {
                // 結果は円
                float m2 = m * m, n2 = n * n;
                x = (-p1.x * n2 + p2.x * m2) / (m2 - n2);
                y = (-p1.y * n2 + p2.y * m2) / (m2 - n2);
                float dist = (float)Math.Sqrt(Math.Pow(p1.x - p2.x, 2) + Math.Pow(p1.y - p2.y, 2));
                r = Math.Abs(m * n / (m2 - n2)) * dist;
            }
        }
Exemplo n.º 2
0
        private void buttonSave_Click(object sender, EventArgs e)
        {
            locations[0] = new LocationStruct(StringToFloat(textBoxX1.Text), StringToFloat(textBoxY1.Text));
            locations[1] = new LocationStruct(StringToFloat(textBoxX2.Text), StringToFloat(textBoxY2.Text));
            locations[2] = new LocationStruct(StringToFloat(textBoxX3.Text), StringToFloat(textBoxY3.Text));

            this.Close();
        }