public void GetPerpendicularIntersect() { //assign Geometry.MarginOfError = 0.001; WLine a = new WLine(new WPoint(0, 15.0 / 6.0), new WPoint(15.0 / 8.0, 0)); WPoint c = new WPoint(3, -4); //act WPoint result = a.GetPerpendicularIntersect(c); //assert Assert.IsTrue(Geometry.WithinMarginOfError(21.0 / 5.0, result.X)); Assert.IsTrue(Geometry.WithinMarginOfError(-31.0 / 10.0, result.Y)); }
public void Overlaps_WPoint_PointIsOutsideLineSegment() { //arrange Geometry.MarginOfError = 0.001; Geometry.CoordinatePlane = Geometry.CoordinatePlanes.Screen; WLine line = new WLine(new WPoint(1, 0), new WPoint(5, 0)); WPoint point = new WPoint(0, 0); //act bool result = line.Overlaps(point); //assert Assert.IsTrue(result); }
public void IsHorizontal_MarginOfError_No() { //arrange (from real example) Geometry.MarginOfError = 0.001; Geometry.CoordinatePlane = Geometry.CoordinatePlanes.Screen; WPoint a = new WPoint(1, 160.06); WPoint b = new WPoint(10, 159.94); WLine line = new WLine(a, b); //act bool result = line.IsHorizontal; //assert Assert.IsFalse(result); }
public void IsVertical_MarginOfError_Yes() { //arrange (from real example) Geometry.MarginOfError = 0.001; Geometry.CoordinatePlane = Geometry.CoordinatePlanes.Screen; WPoint a = new WPoint(160.00000000000006, 1); WPoint b = new WPoint(159.99999999999994, 10); WLine line = new WLine(a, b); //act bool result = line.IsVertical; //assert Assert.IsTrue(result); }
public void Corners_Screen_Flat() { //assign Geometry.MarginOfError = 0.001; Geometry.CoordinatePlane = Geometry.CoordinatePlanes.Screen; WPoint topLeftCorner = new WPoint(10, 5); double width = 12; double height = 4; double rotation = 0; WRectangle rectangle = new WRectangle(width, height, topLeftCorner, rotation); //act WPoint[] result = rectangle.Corners; //assert Assert.AreEqual(4, result.Length); Assert.AreEqual(topLeftCorner, result[0]); Assert.AreEqual(new WPoint(topLeftCorner.X + width, topLeftCorner.Y), result[1]); Assert.AreEqual(new WPoint(topLeftCorner.X + width, topLeftCorner.Y + height), result[2]); Assert.AreEqual(new WPoint(topLeftCorner.X, topLeftCorner.Y + height), result[3]); }