private bool HasCollision(RectangleAA2 other, double tolerance = GeometrySettings.DEFAULT_TOLERANCE) { return((other.X < (X + Width + tolerance)) && (X < (other.X + other.Width + tolerance)) && (other.Y < (Y + Height + tolerance)) && (Y < (other.Y + other.Height + tolerance))); }
public RectangleAA2(RectangleAA2 prototype) { if (prototype == null) { throw new ArgumentNullException("prototype"); } Prototype(prototype); }
public static VisualAARectangle Create(RectangleAA2 rect, Pen pen = null, Brush brush = null) { return new VisualAARectangle(rect) { Pen = pen, FillBrush = brush }; }
public void Constructor(string locationStr, string sizeStr) { var location = Vector2.Parse(locationStr); var size = SizeD.Parse(sizeStr); var rect = new RectangleAA2(location, size); Assert.AreEqual(location, rect.Location); Assert.AreEqual(size.Width, rect.Width); Assert.AreEqual(size.Height, rect.Height); }
public void ToLinesTest() { var rect = new RectangleAA2(new Vector2(10,10), new SizeD(20,20)); var lines = rect.ToLines(); var bottom = new LineSegment2(new Vector2(10, 10), new Vector2(30, 10)); var top = new LineSegment2(new Vector2(30, 30), new Vector2(10, 30)); var right = new LineSegment2(new Vector2(30, 10), new Vector2(30, 30)); var left = new LineSegment2(new Vector2(10, 30), new Vector2(10, 10)); Assert.True((from l in lines where l.Equals(bottom) select l).Any()); Assert.True((from l in lines where l.Equals(top) select l).Any()); Assert.True((from l in lines where l.Equals(right) select l).Any()); Assert.True((from l in lines where l.Equals(left) select l).Any()); }
[TestCase("10, 10", "10, 10", "(0, 15),(5, 15)", false)] // left of it public void CollisionWithLine(string locationStr, string sizeStr, string lineStr, bool expectedCollision) { var location = Vector2.Parse(locationStr); var size = SizeD.Parse(sizeStr); var rect = new RectangleAA2(location, size); var line = LineSegment2.Parse(lineStr); var hasCollision = rect.HasCollision(line); Assert.AreEqual(expectedCollision, hasCollision); }
public RectangleAA2(RectangleAA2 prototype) { if(prototype == null) throw new ArgumentNullException("prototype"); Prototype(prototype); }
private bool HasCollision(RectangleAA2 other, double tolerance = GeometrySettings.DEFAULT_TOLERANCE) { return (other.X < (X + Width + tolerance)) && (X < (other.X + other.Width + tolerance)) && (other.Y < (Y + Height + tolerance)) && (Y < (other.Y + other.Height + tolerance)); }
public VisualImage(Vector2 location, Image image) { _imageRect = new RectangleAA2(location.X, location.Y, 0, 0); Image = image; }
public VisualAARectangle(RectangleAA2 geometry) { _rectangle = geometry; }