Exemple #1
0
 /// Intersection test for other aabb's
 public bool Intersects(Aabb o)
 {
     return(intervalsOverlap(o.m_xmin, o.m_xmax, m_xmin, m_xmax) &&
            intervalsOverlap(o.m_ymin, o.m_ymax, m_ymin, m_ymax));
 }
Exemple #2
0
        public int ConstructNeighborsTowards(int direction,
                                             out Aabb ll,
                                             out Aabb lr,
                                             out Aabb ul,
                                             out Aabb ur,
                                             out Aabb tot)
        {
            double w = m_xmax - m_xmin;
            double h = m_ymax - m_ymin;

            /*      double dx_min = target.m_xmin - m_xmin;
             * double dx_max = target.m_xmax - m_xmax;
             * double dy_min = target.m_ymin - m_ymin;
             * double dy_max = target.m_ymax - m_ymax;
             */
            switch (direction)
            {
            case 0:
                tot = new Aabb(m_xmin, m_xmax + w,
                               m_ymin, m_ymax + h);
                tot.QuadBreak(out ll, out lr, out ul, out ur);
                ll = this;
                return(0);

            case 1:
                tot = new Aabb(m_xmin - w, m_xmax,
                               m_ymin, m_ymax + h);
                tot.QuadBreak(out ll, out lr, out ul, out ur);
                lr = this;
                return(1);

            case 2:
                tot = new Aabb(m_xmin, m_xmax + w,
                               m_ymin - h, m_ymax);
                tot.QuadBreak(out ll, out lr, out ul, out ur);
                ul = this;
                return(2);

            case 3:
                tot = new Aabb(m_xmin - w, m_xmax,
                               m_ymin - h, m_ymax);
                tot.QuadBreak(out ll, out lr, out ul, out ur);
                ur = this;
                return(3);
            }
            throw new Exception("Bad!");

            /*
             * if (dx_min > dx_max) { // grow towards left
             * if (dy_min > dy_max) { // grow down
             *  tot = new Aabb(m_xmin - w, m_xmax,
             *                 m_ymin - h, m_ymax);
             *  tot.QuadBreak(out ll, out lr, out ul, out ur);
             *  ur = this;
             *  return 3;
             * } else { // grow up
             *  tot = new Aabb(m_xmin - w, m_xmax,
             *                 m_ymin, m_ymax + h);
             *  tot.QuadBreak(out ll, out lr, out ul, out ur);
             *  lr = this;
             *  return 1;
             * }
             * } else { // grow right
             * if (dy_min > dy_max) { // grow down
             *  tot = new Aabb(m_xmin, m_xmax + w,
             *                 m_ymin - h, m_ymax );
             *  tot.QuadBreak(out ll, out lr, out ul, out ur);
             *  ul = this;
             *  return 2;
             * } else { // grow up
             *  tot = new Aabb(m_xmin, m_xmax + w,
             *                 m_ymin, m_ymax + h);
             *  tot.QuadBreak(out ll, out lr, out ul, out ur);
             *  ll = this;
             *  return 0;
             * }
             * }
             */
        }