예제 #1
0
 /// <summary>
 /// Returns a rectangle enclosing the corner points of the current instance, rotated
 /// by the specified amount.
 /// </summary>
 public RectangleD Rotate(Angle angle)
 {
     if (angle.IsEmpty)
     {
         return(this);
     }
     // Rotate each corner point
     PointD[] Points = new PointD[] { UpperLeft.RotateAt(angle, Center),
                                      UpperRight.RotateAt(angle, Center),
                                      LowerRight.RotateAt(angle, Center),
                                      LowerLeft.RotateAt(angle, Center) };
     // Now return the smallest rectangle which encloses these points
     return(RectangleD.FromArray(Points));
 }
예제 #2
0
        /// <summary>
        /// Returns a rectangle enclosing the corner points of the current instance, rotated
        /// by the specified amount around a specific point.
        /// </summary>
        /// <returns>A new <strong>RectangleD</strong> containing the rotated rectangle.</returns>
        /// <remarks><para>When a rectangle is rotated, the total width and height it occupies may be larger
        /// than the rectangle's own width and height.  This method calculates the smallest rectangle
        /// which encloses the rotated rectangle.</para>
        ///     <para>[TODO: Include before and after picture; this is confusing.]</para>
        /// </remarks>
        public RectangleD RotateAt(Angle _angle, PointD _center)
        {
            if (_angle.IsEmpty)
            {
                return(this);
            }
            // Rotate each corner point
            PointD[] points =
            {
                UpperLeft.RotateAt(_angle,  _center),
                UpperRight.RotateAt(_angle, _center),
                LowerRight.RotateAt(_angle, _center),
                LowerLeft.RotateAt(_angle,  _center)
            };

            // Now return the smallest rectangle which encloses these points
            return(FromArray(points));
        }