if (MACs.Count == 2)
{
///点1为X值小的点
double X1 = StationList[Indexs[0]].Coordinates_X;
double X2 = StationList[Indexs[1]].Coordinates_X;
double Y1 = StationList[Indexs[0]].Coordinates_Y;
double Y2 = StationList[Indexs[1]].Coordinates_Y;
double DBM1 = -DBMs[0];
double DBM2 = -DBMs[1];
///点1为X值小的点
if (StationList[Indexs[0]].Coordinates_X > StationList[Indexs[1]].Coordinates_X)
{
X1 = StationList[Indexs[1]].Coordinates_X;
X2 = StationList[Indexs[0]].Coordinates_X;
Y1 = StationList[Indexs[1]].Coordinates_Y;
Y2 = StationList[Indexs[0]].Coordinates_Y;
DBM1 = -DBMs[1];
DBM2 = -DBMs[2];
}
///在依赖RSSI的定位系统中 信号强度越大 对应的距离值越准确
if (DBM1 > DBM2)
{
//public static double GetDistance(double P1, double A1, double A2, double P2, double F,double N)
// {
// return Math.Pow(10, ((P1 + A1 + A2 - P2 - 20 * Math.Log10(F) + 27.56) / 20))+N;
//}
double Distance = BLL.ConvertDBMToDistance.GetDistance(20, 3, 2.5, DBM1, 2400, 0);
///用反三角函数求出角度
double JiaoQ = Math.Atan(Math.Abs(Y1 - Y2) / Math.Abs(X1 - X2));
///求出X的增量
double XLenth = Distance * Math.Cos(JiaoQ);
///求出Y的增量
double YLenth = Distance * Math.Sin(JiaoQ);
if (Y1 < Y2)
{
X = X1 + XLenth;
Y = Y1 + YLenth;
}
else if (Y1 > Y2)
{
X = X1 + XLenth;
Y = Y1 - YLenth;
}
else if (Y1 == Y2)
{
X = X1 + XLenth;
Y = Y1;
}
}
else if (DBM1 < DBM2)
{
double Distance = BLL.ConvertDBMToDistance.GetDistance(20, 3, 2.5, DBM2, 2400, 0);
double JiaoQ = Math.Atan(Math.Abs(Y1 - Y2) / Math.Abs(X1 - X2));
double XLenth = Distance * Math.Cos(JiaoQ);
double YLenth = Distance * Math.Sin(JiaoQ);
if (Y1 < Y2)
{
X = X2 - XLenth;
Y = Y1 - YLenth;
}
else if (Y1 > Y2)
{
X = X2 - XLenth;
Y = Y2 + YLenth;
}
else if (Y1 == Y2)
{
X = X2 - XLenth;
Y = Y1;
}
}
}