public static void Translate_Returns_Translated_Copy_of_Extents() { PointExtents extents = new PointExtents( new List <CartesianCoordinate>() { new CartesianCoordinate(1, 2), new CartesianCoordinate(3, 5), new CartesianCoordinate(2, 6), new CartesianCoordinate(0, 4), new CartesianCoordinate(1.5, -2), new CartesianCoordinate(5, 4), new CartesianCoordinate(1, 7), new CartesianCoordinate(3.5, -1) }); Assert.AreEqual(0, extents.MinX); Assert.AreEqual(5, extents.MaxX); Assert.AreEqual(-2, extents.MinY); Assert.AreEqual(7, extents.MaxY); Assert.AreEqual(5, extents.Width); Assert.AreEqual(9, extents.Height); PointExtents translatedExtents = extents.Translate(3, 4) as PointExtents; Assert.AreEqual(3, translatedExtents.MinX); Assert.AreEqual(8, translatedExtents.MaxX); Assert.AreEqual(2, translatedExtents.MinY); Assert.AreEqual(11, translatedExtents.MaxY); Assert.AreEqual(5, translatedExtents.Width); Assert.AreEqual(9, translatedExtents.Height); }
/// <summary> /// Calculates the extents aligned at centroid. /// </summary> /// <param name="extents">The extents.</param> /// <param name="centroid">The centroid.</param> /// <returns>PointExtents.</returns> public static PointExtents CalculateExtentsAlignedAtCentroid(PointExtents extents, CartesianCoordinate centroid) { PointExtents extentsAlignedAtCentroid = extents.Translate(-centroid.X, -centroid.Y) as PointExtents; return(extentsAlignedAtCentroid); }