Пример #1
0
        public bool Intersects(Hop5DPoly other)
        {
            if (!valid || !other.valid)
            {
                return(false);
            }

            if (minX >= other.maxX || other.minX >= maxX ||
                minY >= other.maxY || other.minY >= maxY ||
                minZ >= other.maxZ || other.minZ >= maxZ)
            {
                return(false);
            }

            if (this.HasSeparatingAxis(other))
            {
                return(false);
            }
            if (other.HasSeparatingAxis(this))
            {
                return(false);
            }

            return(true);
        }
Пример #2
0
 bool HasSeparatingAxis(Hop5DPoly other) {
   for (int i = 0; i < points.Count; ++i) {
     bool clean = true;
     for (int j = 0; j < other.points.Count; ++j) {
       int det = Determinant(points[i],
                             points[(i + 1) % points.Count],
                             other.points[j]);
       if (det < 0)
         clean = false;
     }
     if (clean)
       return true;
   }
   return false;
 }
Пример #3
0
 public bool Intersects(Hop5DPoly other) {
   if (!valid || !other.valid)
     return false;
   
   if (minX >= other.maxX || other.minX >= maxX ||
       minY >= other.maxY || other.minY >= maxY ||
       minZ >= other.maxZ || other.minZ >= maxZ)
     return false;
   
   if (this.HasSeparatingAxis(other))
     return false;
   if (other.HasSeparatingAxis(this))
     return false;
   
   return true;
 }
Пример #4
0
 bool HasSeparatingAxis(Hop5DPoly other)
 {
     for (int i = 0; i < points.Count; ++i)
     {
         bool clean = true;
         for (int j = 0; j < other.points.Count; ++j)
         {
             int det = Determinant(points[i],
                                   points[(i + 1) % points.Count],
                                   other.points[j]);
             if (det < 0)
             {
                 clean = false;
             }
         }
         if (clean)
         {
             return(true);
         }
     }
     return(false);
 }