Exemplo n.º 1
0
        }  // end Contains()

        /// <summary>
        /// Get the bounding rectangle for this polygon.
        /// </summary>
        /// <returns></returns>
        public virtual Rect2 GetBoundingRectangle()
        {
            double xmax = Double.MinValue;
            double xmin = Double.MaxValue;
            double ymax = Double.MinValue;
            double ymin = Double.MaxValue;

            foreach (Point2 point in Points)
            {
                xmax = Math.Max(point.X, xmax);
                xmin = Math.Min(point.X, xmin);
                ymax = Math.Max(point.Y, ymax);
                ymin = Math.Min(point.Y, ymin);
            }
            Rect2 bounder = new Rect2();

            bounder.UpperLeft  = new Point2(xmin, ymax);
            bounder.LowerRight = new Point2(xmax, ymin);
            return(bounder);
        }
Exemplo n.º 2
0
        public virtual Point2 GetApproxCenter()
        {
            Rect2 bounder = GetBoundingRectangle();

            return(bounder.Center);
        }