Ejemplo n.º 1
0
        public Extent2D CircumCircleExtent()
        {
            if (m_circumCircleExtent == null)
            {
                m_circumCircleExtent = DelaunayGeometry.Circumcircle(m_v[0], m_v[1], m_v[2], centroidX, centroidY);
            }

            return(m_circumCircleExtent);
        }
Ejemplo n.º 2
0
 private void ForceClockwise()
 {
     if (DelaunayGeometry.CrossProduct(m_v[0], m_v[1], m_v[2]) >= 0)
     {
         // a positive value indicates counter clockwise
         // Swapping the first 2 points should be enough
         DelaunayPoint tmp = m_v[0];
         m_v[0] = m_v[1];
         m_v[1] = tmp;
     }
 }
Ejemplo n.º 3
0
        public bool Contains(DelaunayPoint p)
        {
            // Only bother to check if the point is within the initial extents of the Triangle_t
            if (m_extent.Contains(p.X, p.Y, true))
            {
                return(
                    (DelaunayGeometry.CrossProduct(m_v[0], p, m_v[1]) >= 0.0) &&
                    (DelaunayGeometry.CrossProduct(m_v[1], p, m_v[2]) >= 0.0) &&
                    (DelaunayGeometry.CrossProduct(m_v[2], p, m_v[0]) >= 0.0));
            }

            return(false);
        }
Ejemplo n.º 4
0
        bool Overlaps(Extent2D extent)
        {
            // Check simplist case - triangle inside extent.
            if (extent.Contains(m_extent))
            {
                return(true);
            }

            // Use right-hand rule for each triangle segment against all points of extent rectangle.
            DelaunayPoint p1 = new DelaunayPoint(extent.MinX, extent.MinY, 0.0f, 0);
            DelaunayPoint p2 = new DelaunayPoint(extent.MaxX, extent.MinY, 0.0f, 0);
            DelaunayPoint p3 = new DelaunayPoint(extent.MaxX, extent.MaxY, 0.0f, 0);
            DelaunayPoint p4 = new DelaunayPoint(extent.MinX, extent.MaxY, 0.0f, 0);

            int ar = 0;

            if (DelaunayGeometry.CrossProduct(m_v[0], p1, m_v[1]) >= 0.0f)
            {
                ++ar;
            }
            if (DelaunayGeometry.CrossProduct(m_v[0], p2, m_v[1]) >= 0.0f)
            {
                ++ar;
            }
            if (DelaunayGeometry.CrossProduct(m_v[0], p3, m_v[1]) >= 0.0f)
            {
                ++ar;
            }
            if (DelaunayGeometry.CrossProduct(m_v[0], p4, m_v[1]) >= 0.0f)
            {
                ++ar;
            }

            int br = 0;

            if (DelaunayGeometry.CrossProduct(m_v[1], p1, m_v[2]) >= 0.0f)
            {
                ++br;
            }
            if (DelaunayGeometry.CrossProduct(m_v[1], p2, m_v[2]) >= 0.0f)
            {
                ++br;
            }
            if (DelaunayGeometry.CrossProduct(m_v[1], p3, m_v[2]) >= 0.0f)
            {
                ++br;
            }
            if (DelaunayGeometry.CrossProduct(m_v[1], p4, m_v[2]) >= 0.0f)
            {
                ++br;
            }

            int cr = 0;

            if (DelaunayGeometry.CrossProduct(m_v[2], p1, m_v[0]) >= 0.0f)
            {
                ++cr;
            }
            if (DelaunayGeometry.CrossProduct(m_v[2], p2, m_v[0]) >= 0.0f)
            {
                ++cr;
            }
            if (DelaunayGeometry.CrossProduct(m_v[2], p3, m_v[0]) >= 0.0f)
            {
                ++cr;
            }
            if (DelaunayGeometry.CrossProduct(m_v[2], p4, m_v[0]) >= 0.0f)
            {
                ++cr;
            }

            // There will be some sort intersection of triangle with rectangle if at least one point of
            // the rectangle is on, or to the right (not zero) of every segment of the triangle.
            if (ar != 0 && br != 0 && cr != 0)
            {
                return(true);
            }

            return(false);
        }