/// <summary>
        /// Find a smallest bounding rectangle.
        /// </summary>
        /// <returns></returns>
        public Vector2[] FindBounds(Polygon2 polygon){

            if (polygon == null) throw new ArgumentNullException("polygon");

            var minified = new Polygon2(polygon.ToVertices().Distinct());
            minified.OrientCounterClockwise();
            var vertices = minified.ToVertices().ToArray();

            if (vertices.Count() == 0)
            {
                return new Vector2[0];
            }

            // This algorithm assumes the polygon is oriented counter-clockwise.

            // Get ready;
            ResetBoundingRect(vertices);

            // Check all possible bounding rectangles.
            for (int i = 0; i < vertices.Count(); i++)
            {
                CheckNextBoundingRectangle(vertices);
            }

            // Return the best result.
            return _bestRectangle;
        }
        /// <summary>
        /// Is the given Polygon fully contained in this one?
        /// </summary>
        /// <param name="polygon"> </param>
        /// <param name="tolerance"> </param>
        /// <returns></returns>
        public bool Contains(Polygon2 polygon, double tolerance = GeometrySettings.DEFAULT_TOLERANCE)
        {
            if (polygon.ToVertices().All(x => Contains(x, tolerance)))
            {
                // When all vertices are contained in a convex polygon
                // we already know that the given vertices are inside
                // this polygon thus we are done
                if (IsConvex()) return true;

                // Otherwise, this is a concave polygon
                // we need to ensure, that the vertices do not intersect any line
                var otherLines = polygon.ToLines();
                return !HasIntersection(otherLines, tolerance);
            }

            return false;
        }
        /// <summary>
        /// Is the given Polygon fully contained in this one?
        /// </summary>
        /// <param name="polygon"> </param>
        /// <param name="tolerance"> </param>
        /// <returns></returns>
        public bool Contains(Polygon2 polygon, double tolerance = GeometrySettings.DEFAULT_TOLERANCE)
        {
            if (polygon.ToVertices().All(x => Contains(x, tolerance)))
            {
                // When all vertices are contained in a convex polygon
                // we already know that the given vertices are inside
                // this polygon thus we are done
                if (IsConvex())
                {
                    return(true);
                }

                // Otherwise, this is a concave polygon
                // we need to ensure, that the vertices do not intersect any line
                var otherLines = polygon.ToLines();
                return(!HasIntersection(otherLines, tolerance));
            }

            return(false);
        }
 /// <summary>
 /// Gets the Vertices (Points) of this Rectangle
 /// </summary>
 /// <returns></returns>
 public Vertices ToVertices()
 {
     return(_rect.ToVertices());
 }