Exemplo n.º 1
0
 public static bool CircleToRectangle(Circle a, Rectangle b)
 {
     double dmin = 0;
     double[] C = new double[] { a.cX, a.cY };
     double[] Bmin = new double[] { b.X, b.Y };
     double[] Bmax = new double[] { b.X + b.W, b.Y + b.H };
     for (int i = 0; i < C.Length; i++)
     {
         if (C[i] < Bmin[i]) dmin += (C[i] - Bmin[i]) * (C[i] - Bmin[i]);
         else if (C[i] > Bmax[i]) dmin += (C[i] - Bmax[i]) * (C[i] - Bmax[i]);
     }
     return dmin <= a.R * a.R;
 }
Exemplo n.º 2
0
 public static bool RectangleToRectangle(Rectangle a, Rectangle b)
 {
     if (b == null) return false;
     return MathUtil.CheckAxis(a.X, a.X + a.W, b.X, b.X + b.W) &&
            MathUtil.CheckAxis(a.Y, a.Y + a.H, b.Y, b.Y + b.H);
 }