|
1 | | -using System; |
| 1 | +using System; |
2 | 2 | using MathNet.Spatial.Euclidean; |
3 | 3 | using NUnit.Framework; |
4 | 4 |
|
@@ -69,9 +69,23 @@ public void CircleIntersectWithLine2D(string sc, double radius, string sps, stri |
69 | 69 | var actual = circle.IntersectWith(line); |
70 | 70 | Assert.That(actual.Length, Is.EqualTo(2)); |
71 | 71 |
|
72 | | - var expected = new [] { Point2D.Parse(esp0), Point2D.Parse(esp1) }; |
| 72 | + var expected = new[] { Point2D.Parse(esp0), Point2D.Parse(esp1) }; |
73 | 73 | AssertGeometry.AreEqual(actual[0], expected[0]); |
74 | 74 | AssertGeometry.AreEqual(actual[1], expected[1]); |
75 | 75 | } |
| 76 | + |
| 77 | + [TestCase("0,0", 1.41421356 /*=sqrt(2)*/, "0,0", "+1,+1", "+1,+1")] |
| 78 | + [TestCase("0,0", 1, "0,0", "+1,0", "+1,0")] |
| 79 | + [TestCase("0,0", 1, "0,0", "0,+1", "0,+1")] |
| 80 | + public void CircleIntersectWithLineSegment2D(string sCenter, double radius, string sStart, string sEnd, string sExpected) |
| 81 | + { |
| 82 | + var circle = new Circle2D(Point2D.Parse(sCenter), radius); |
| 83 | + var segment = new LineSegment2D(Point2D.Parse(sStart), Point2D.Parse(sEnd)); |
| 84 | + var actual = circle.IntersectWith(segment); |
| 85 | + Assert.That(actual.Length, Is.EqualTo(1)); |
| 86 | + |
| 87 | + var expected = Point2D.Parse(sExpected); |
| 88 | + AssertGeometry.AreEqual(actual[0], expected); |
| 89 | + } |
76 | 90 | } |
77 | 91 | } |
0 commit comments