/// <summary> /// Creates a new <see cref="OrientedRect"/> /// </summary> /// <param name="location">The pivot location.</param> /// <param name="offset"> /// The offset of the pivot relative the a unit box /// - (0,0) means <paramref name="location"/> represents the TopLeft corner of the rectangle. /// - (0.5,0.5) means <paramref name="location"/> represents the center of the rectangle. /// - (1,1) means <paramref name="location"/> represents the BottomRight corner of the rectangle. /// </param> /// <param name="size">The width and height of the rectangle.</param> /// <param name="radians">the rotation around <see cref="Location"/>.</param> /// <returns>A new <see cref="OrientedRect"/>.</returns> public static OrientedRect FromLocation(XY location, XY offset, XY size, float radians = 0) { var xform = MATRIX.CreateScale(size) * MATRIX.CreateRotation(radians); xform.Translation = location - XY.TransformNormal(offset, xform); return(new OrientedRect(xform)); }
public static OrientedRect FromCenter(XY center, XY size, float radians = 0) { var xform = MATRIX.CreateScale(size) * MATRIX.CreateRotation(radians); xform.Translation = center - XY.TransformNormal(XY.One * 0.5f, xform); return(new OrientedRect(xform)); }