/// <summary>
 ///     Computes the <see cref="BoundingRectangle" /> from the specified <see cref="BoundingRectangle" /> transformed by
 ///     the
 ///     specified <see cref="Matrix2" />.
 /// </summary>
 /// <param name="boundingRectangle">The bounding rectangle.</param>
 /// <param name="transformMatrix">The transform matrix.</param>
 /// <param name="result">The resulting bounding rectangle.</param>
 /// <returns>
 ///     The <see cref="BoundingRectangle" /> from the <paramref name="boundingRectangle" /> transformed by the
 ///     <paramref name="transformMatrix" />.
 /// </returns>
 /// <remarks>
 ///     <para>
 ///         If a transformed <see cref="BoundingRectangle" /> is used for <paramref name="boundingRectangle" /> then the
 ///         resulting <see cref="BoundingRectangle" /> will have the compounded transformation, which most likely is
 ///         not desired.
 ///     </para>
 /// </remarks>
 public static void Transform(ref BoundingRectangle boundingRectangle,
                              ref Matrix2 transformMatrix, out BoundingRectangle result)
 {
     PrimitivesHelper.TransformRectangle(ref boundingRectangle.Center, ref boundingRectangle.HalfExtents, ref transformMatrix);
     result.Center      = boundingRectangle.Center;
     result.HalfExtents = boundingRectangle.HalfExtents;
 }
示例#2
0
        /// <summary>
        ///     Computes the <see cref="RectangleF" /> from the specified <see cref="RectangleF" /> transformed by
        ///     the specified <see cref="Matrix2" />.
        /// </summary>
        /// <param name="rectangle">The rectangle to be transformed.</param>
        /// <param name="transformMatrix">The transform matrix.</param>
        /// <param name="result">The resulting transformed rectangle.</param>
        /// <returns>
        ///     The <see cref="BoundingRectangle" /> from the <paramref name="rectangle" /> transformed by the
        ///     <paramref name="transformMatrix" />.
        /// </returns>
        /// <remarks>
        ///     <para>
        ///         If a transformed <see cref="BoundingRectangle" /> is used for <paramref name="rectangle" /> then the
        ///         resulting <see cref="BoundingRectangle" /> will have the compounded transformation, which most likely is
        ///         not desired.
        ///     </para>
        /// </remarks>
        public static void Transform(ref RectangleF rectangle,
                                     ref Matrix2 transformMatrix, out RectangleF result)
        {
            var center      = rectangle.Center;
            var halfExtents = (Vector2)rectangle.Size * 0.5f;

            PrimitivesHelper.TransformRectangle(ref center, ref halfExtents, ref transformMatrix);

            result.X      = center.X - halfExtents.X;
            result.Y      = center.Y - halfExtents.Y;
            result.Width  = halfExtents.X * 2;
            result.Height = halfExtents.Y * 2;
        }