private static bool IsRayIntersectWithBeaconAccuracy(PointF ray, Beacon beacon)
        {
            if (beacon == null)
                return false;

            var x = beacon.X;
            var y = beacon.Y;
            var r = beacon.Accuracy;
            return r > Math.Sqrt((ray.X - x) * (ray.X - x) + (ray.Y - y) * (ray.Y - y));
        }
        private static IEnumerable<PointF> GetCircleCircleIntersections(Beacon b1, Beacon b2)
        {
            var p1 = new PointF(b1.X, b1.Y);
            var p2 = new PointF(b2.X, b2.Y);
            var d = GetDistanceBetween(p1, p2);
            var r1 = b1.Accuracy;
            var r2 = b2.Accuracy;

            // if to far away, or self contained - can't be done
            if ((d >= (r1 + r2)) || (d <= Math.Abs(r1 - r2))) {
                return new List<PointF>();
            }

            var a = (r1*r1 - r2*r2 + d*d)/(2*d);
            var h = Math.Sqrt(r1*r1 - a*a);
            var x0 = p1.X + a*(p2.X - p1.X)/d;
            var y0 = p1.Y + a*(p2.Y - p1.Y)/d;
            var rx = -(p2.Y - p1.Y)*(h/d);
            var ry = -(p2.X - p1.X)*(h/d);

            return new List<PointF>
            {
                new PointF((float) (x0 + rx), (float) (y0 - ry)),
                new PointF((float) (x0 - rx), (float) (y0 + ry))
            };
        }
Пример #3
0
 private static bool IsOverBeaconAccuracyRadius(Beacon beacon, float x, float y)
 {
     var dx = MetersToPixels * beacon.X + ShiftX - x;
     var dy = MetersToPixels * beacon.Y + ShiftY - y;
     var dist = Math.Sqrt(dx*dx + dy*dy);
     var acc = MetersToPixels*beacon.Accuracy;
     return Math.Abs(dist - acc) < 12;
 }