private Scene2D CreateShapes() { var scene = new Scene2D(); scene.Shapes.Add(new Circle(new Vector2D(3, 5), 8)); scene.Shapes.Add(RectangleFactory.CreateByDimensions(7, -2, 12, 8)); var points = new List <Vector2D>() { new Vector2D(2, 2), new Vector2D(6, 7), new Vector2D(4, -3), new Vector2D(-2, 1) }; scene.Shapes.Add(PolygonFactory.CreateByPoints(points)); return(scene); }
public void RectangleAndPolygon_DoOverlap_ShouldReturn() { var operation = new GeneralShapeOperation(); var rectangle = RectangleFactory.CreateByDimensions(0, 0, 3, 3); var polygon = PolygonFactory.CreateByPoints(new List <Vector2D>() { new Vector2D(1, 1), new Vector2D(1, 2), new Vector2D(2, 1) }); var result = operation.DoOverlap(rectangle, polygon); result.Should().BeTrue(); }
public void Setup() { List <Vector2D> points = new List <Vector2D>(); Console.WriteLine($"PolygonSize: {PolygonSides}"); for (int p = 0; p < PolygonSides; p++) { var x = random.NextDouble() * 60000 + 20000; var y = random.NextDouble() * 60000 + 20000; points.Add(new Vector2D(x, y)); } this.RandomPolygon = PolygonFactory.CreateByPoints(points); this.RandomPolygon.MarginWidth = 2000; points = new List <Vector2D>(); for (int p = 0; p < PolygonSides; p++) { var x = Math.Cos(Math.PI / PolygonSides * p) * OverlapProbability * 100000 + 50000; var y = Math.Cos(Math.PI / PolygonSides * p) * OverlapProbability * 100000 + 50000; points.Add(new Vector2D(x, y)); } this.RegularPolygon = PolygonFactory.CreateByPoints(points); this.RegularPolygon.MarginWidth = 2000; points = new List <Vector2D>(); for (int p = 0; p < PolygonSides; p++) { var radius = random.NextDouble() * OverlapProbability * 50000; var x = Math.Cos(Math.PI / PolygonSides * p) * radius + 50000; var y = Math.Cos(Math.PI / PolygonSides * p) * radius + 50000; points.Add(new Vector2D(x, y)); } this.RadialPolygon = PolygonFactory.CreateByPoints(points); this.RadialPolygon.MarginWidth = 2000; for (int i = 0; i < Count; i++) { var x = random.NextDouble() * 90000; var y = random.NextDouble() * 90000; var width = random.NextDouble() * 20000; var height = random.NextDouble() * 20000; var rectangle = RectangleFactory.CreateByDimensions(x, y, width, height); rectangle.MarginWidth = random.NextDouble() * 3000; Rectangles.Add(rectangle); } }
private static Polygon CreateTestPolygon1() { var points = new List <Vector2D>() { new Vector2D(-10, 5), new Vector2D(-5, 5), new Vector2D(-2, 2), new Vector2D(2, 2), new Vector2D(5, 5), new Vector2D(10, 5), new Vector2D(5, 0), new Vector2D(8, -5), new Vector2D(-8, -5) }; var polygon = PolygonFactory.CreateByPoints(points); return(polygon); }
public void Setup() { List <Vector2D> points = new List <Vector2D>(); Console.WriteLine($"PolygonSize: {PolygonSize}"); for (int p = 0; p < PolygonSize; p++) { var x = random.NextDouble() * 100000; var y = random.NextDouble() * 100000; points.Add(new Vector2D(x, y)); } this.RandomPolygon = PolygonFactory.CreateByPoints(points); for (int i = 0; i < Count; i++) { var x = random.NextDouble() * 100000; var y = random.NextDouble() * 100000; Points.Add(new Vector2D(x, y)); } }