Ejemplo n.º 1
0
        /// <summary>
        /// If the points are stored counter-clockwise and form a convex polygon, this will test if a circle with the origin (0;0) lies inside it.
        /// </summary>
        /// <param name="radius">The rectangle to test for intersection.</param>
        /// <returns><c>true</c> if the circle lies within the quadrangle.</returns>
        public bool IntersectCircle(float radius)
        {
            // Check if a part of the circle lies within the quadrangle
            if (P1.Length() < radius || P2.Length() < radius || P3.Length() < radius || P4.Length() < radius)
            {
                return(true);
            }

            // Check if the quadrangle has the size 0
            if (P1 == P2 && P2 == P3 && P3 == P4)
            {
                return(false);
            }

            // Check if the circle lies within the quadrangle completley
            if (IntersectWith(new Vector2()))
            {
                return(true);
            }

            // If neither, it must be outside of the quadrangle
            return(false);
        }