public void OverlapsLineSegment_Overlaid_LargeBothWays() { //assign WLineSegment a = new WLineSegment(new WPoint(1, 0), new WPoint(4, 0)); WLineSegment b = new WLineSegment(new WPoint(0, 0), new WPoint(5, 0)); //act bool result = a.Overlaps(b); //assert Assert.IsTrue(result); }
public void GetIntersection_WLineSegment_Parallel_DifferentDirection_NoOverlap() { //arrange Geometry.MarginOfError = 0.001; Geometry.CoordinatePlane = Geometry.CoordinatePlanes.Screen; WLineSegment a = new WLineSegment(new WPoint(0, 0), new WPoint(3, 0)); WLineSegment b = new WLineSegment(new WPoint(6, 0), new WPoint(4, 0)); //act Intersection resultA = a.GetIntersection(b); Intersection resultB = b.GetIntersection(a); //assert Assert.IsTrue(resultA.IsNone); Assert.IsTrue(resultB.IsNone); }
public void GetIntersection_WLineSegment_Parallel_SameDirection_OneEncompassingOverlap() { //arrange Geometry.MarginOfError = 0.001; Geometry.CoordinatePlane = Geometry.CoordinatePlanes.Screen; WLineSegment a = new WLineSegment(new WPoint(0, 0), new WPoint(6, 0)); WLineSegment b = new WLineSegment(new WPoint(3, 0), new WPoint(4, 0)); //act Intersection resultA = a.GetIntersection(b); Intersection resultB = b.GetIntersection(a); //assert Assert.IsTrue(resultA.IsLineSegment); Assert.IsTrue(resultB.IsLineSegment); Assert.AreEqual(new WLineSegment(new WPoint(3, 0), new WPoint(4, 0)), resultA.LineSegment); Assert.AreEqual(new WLineSegment(new WPoint(3, 0), new WPoint(4, 0)), resultB.LineSegment); }
public void OverlapsWedge_CenterToEdge_True() { //assign Geometry.MarginOfError = 0.000001; Geometry.CoordinatePlane = Geometry.CoordinatePlanes.Screen; WWedge a = new WWedge(new WCircle(new WPoint(3, 3), 3), -45, 45); WLineSegment edgeA = a.LineEdges[1]; WPoint centerB = Geometry.PointOnLine(edgeA.A, edgeA.B, a.Circle.Radius * 0.25); WWedge b = new WWedge(new WCircle(centerB, 3), 90, 120); //account Utilities.SaveDiagram(new IDraw[] { a, b }, nameof(TestWedge)); //act bool result = a.Overlaps(b); //assert Assert.IsTrue(result); }
public void OverlapsWedge_LineEdge_AdjacentExternal_True() { //assign Geometry.MarginOfError = 0.000001; Geometry.CoordinatePlane = Geometry.CoordinatePlanes.Screen; WWedge a = new WWedge(new WCircle(new WPoint(2, 2), 2), 260, 280); WLineSegment aEdge = new WLineSegment(a.Circle.Center, a.EndPoint); WPoint centerB = Geometry.PointOnLine(a.Circle.Center, a.EndPoint, a.Circle.Radius * 0.25); WCircle circleB = new WCircle(centerB, a.Circle.Radius * 1.5); double startDegreesB = circleB.DegreesAtPoint(a.EndPoint); WWedge b = new WWedge(circleB, startDegreesB, startDegreesB + 10); //account Utilities.SaveDiagram(new IDraw[] { a, b }, nameof(TestWedge)); //act bool result = a.Overlaps(b); //assert Assert.IsTrue(result); }
public void GetIntersectionPointsLineSegment_DoubleIntersection() { //assign Geometry.MarginOfError = 0.01; //(x - 2)^2 + (y + 3)^2 = 4 WCircle a = new WCircle(new WPoint(2, -3), 2); //2x + 2y = -1 WLineSegment c = new WLineSegment(new WPoint(5, -11.0 / 2.0), new WPoint(0, -1.0 / 2.0)); //account Utilities.SaveDiagram(new IDraw[] { a, c }, nameof(TestCircle)); //act WPoint[] result = a.GetIntersectionPoints(c); WPoint minResult = (result[0] < result[1]) ? result[0] : result[1]; WPoint maxResult = (minResult == result[0]) ? result[1] : result[0]; //assert Assert.AreEqual(2, result.Length); Assert.IsTrue(new WPoint(0.86, -1.36) == minResult); Assert.IsTrue(new WPoint(3.64, -4.14) == maxResult); }