public void CenterTest() { var quadrilateral = new Quadrilateral { Points = new List <Point> { new Point(0, 0), new Point(10, 0), new Point(0, 4), new Point(10, 4) } }; var center = quadrilateral.Center(); Assert.Equal(5, center.X); Assert.Equal(2, center.Y); }
public static Quadrilateral MoveToPoint(Quadrilateral quadrilateral, Point newCenter) { Point previouseCenter = quadrilateral.Center(); int xShifting = previouseCenter.X - newCenter.X; int yShifting = previouseCenter.Y - newCenter.Y; var points = quadrilateral.ToArray(); for (int i = 0; i < points.Count(); i++) { points[i].X -= xShifting; points[i].Y -= yShifting; } quadrilateral.Points = points.ToList(); return(quadrilateral); }