|
1 | | -using System; |
| 1 | +using System; |
| 2 | +using System.Linq; |
2 | 3 | using MathNet.Spatial.Euclidean; |
3 | 4 | using NUnit.Framework; |
4 | 5 |
|
@@ -59,19 +60,19 @@ public void CircleFromThreePointsArgumentException() |
59 | 60 | Assert.Throws<ArgumentException>(() => { Circle2D.FromPoints(p1, p2, p3); }); |
60 | 61 | } |
61 | 62 |
|
62 | | - [TestCase("0,0", 1.41421356 /*=sqrt(2)*/, "-1,-1", "+1,+1", "+1,+1", "-1,-1")] |
63 | | - [TestCase("0,0", 1, "-1,0", "+1,0", "+1,0", "-1,0")] |
64 | | - [TestCase("0,0", 1, "0,-1", "0,+1", "0,+1", "0,-1")] |
65 | | - public void CircleIntersectWithLine2D(string sc, double radius, string sps, string spe, string esp0, string esp1) |
| 63 | + [TestCase("0,0", 1, "-10,+10", "+10,+10", 0)] |
| 64 | + [TestCase("0,0", 1, "-10,+1", "+10,+1", 1)] |
| 65 | + [TestCase("0,0", 1, "-10,0", "+10,0", 2)] |
| 66 | + [TestCase("0,0", 1, "-10,-1", "+10,-1", 1 )] |
| 67 | + [TestCase("0,0", 1, "-10,-10", "+10,-10", 0)] |
| 68 | + public void CircleIntersectWithLine2D_NumberOfIntersections(string sc, double radius, string sps, string spe, int expectedNumberOfIntersections) |
66 | 69 | { |
67 | 70 | var circle = new Circle2D(Point2D.Parse(sc), radius); |
68 | 71 | var line = new Line2D(Point2D.Parse(sps), Point2D.Parse(spe)); |
| 72 | + |
69 | 73 | var actual = circle.IntersectWith(line); |
70 | | - Assert.That(actual.Length, Is.EqualTo(2)); |
71 | 74 |
|
72 | | - var expected = new[] { Point2D.Parse(esp0), Point2D.Parse(esp1) }; |
73 | | - AssertGeometry.AreEqual(actual[0], expected[0]); |
74 | | - AssertGeometry.AreEqual(actual[1], expected[1]); |
| 75 | + Assert.That(actual.Count(), Is.EqualTo(expectedNumberOfIntersections)); |
75 | 76 | } |
76 | 77 |
|
77 | 78 | [TestCase("0,0", 1.41421356 /*=sqrt(2)*/, "0,0", "+1,+1", "+1,+1")] |
|
0 commit comments