2

複数の iBeacons を使用して、iOS でユーザーの位置を追跡しようとしています。これは、3 つのビーコンと三辺測量を使用して (ある程度) 実行できることはわかっていますが、2 つ (二辺測量) で実行したいと考えています。私はおそらく2つの答えで終わる可能性が高いことを知っています. ビーコンの (x,y) 位置 (部屋に対して) と、各ビーコンからの平均 RSSI を考えると、これを達成する簡単な方法を知っている人はいますか?

私はjavascriptからobjective-cに変更した三辺測量のこのコードを持っています:

- (CGPoint)getTrilaterationWithBeacon1:(BBBeacon *)beacon1 Beacon2:(BBBeacon *)beacon2 Beacon3:(BBBeacon *)beacon3 {
    float xa = beacon1.x;
    float ya = beacon1.y;
    float xb = beacon2.x;
    float yb = beacon2.y;
    float xc = beacon3.x;
    float yc = beacon3.y;
    float ra = beacon1.distance;
    float rb = beacon2.distance;
    float rc = beacon3.distance;

    float S = (pow(xc, 2.) - pow(xb, 2.) + pow(yc, 2.) - pow(yb, 2.) + pow(rb, 2.) - pow(rc, 2.)) / 2.0;
    float T = (pow(xa, 2.) - pow(xb, 2.) + pow(ya, 2.) - pow(yb, 2.) + pow(rb, 2.) - pow(ra, 2.)) / 2.0;
    float y = ((T * (xb - xc)) - (S * (xb - xa))) / (((ya - yb) * (xb - xc)) - ((yc - yb) * (xb - xa)));
    float x = ((y * (ya - yb)) - T) / (xb - xa);

    CGPoint point = CGPointMake(x, y);
    return point;
}
4

1 に答える 1