[InlineData(0, 1, 1, 0)] // Touching public void CoincidentalShouldIntersect(int a0, int a1, int b0, int b1) { // Horizontal var a = new OrthoLine(a0, a1, 0, true); var b = new OrthoLine(b0, b1, 0, true); Assert.True(a.Intersects(b, out _)); Assert.True(b.Intersects(a, out _)); a = new OrthoLine(-a0, -a1, 0, false); b = new OrthoLine(-b0, -b1, 0, false); Assert.True(a.Intersects(b, out _)); Assert.True(b.Intersects(a, out _)); // Vertical a = new OrthoLine(a0, a1, 0, false); b = new OrthoLine(b0, b1, 0, false); Assert.True(a.Intersects(b, out _)); Assert.True(b.Intersects(a, out _)); a = new OrthoLine(-a0, -a1, 0, false); b = new OrthoLine(-b0, -b1, 0, false); Assert.True(a.Intersects(b, out _)); Assert.True(b.Intersects(a, out _)); }
public void ParallelShouldNotIntersect() { // Horizontal var a = new OrthoLine(-1, 1, 0, true); var b = new OrthoLine(-1, 1, 1, true); Assert.False(a.Intersects(b, out _)); Assert.False(b.Intersects(a, out _)); a = new OrthoLine(1, -1, 0, true); b = new OrthoLine(1, -1, 1, true); Assert.False(a.Intersects(b, out _)); Assert.False(b.Intersects(a, out _)); // Vertical a = new OrthoLine(-1, 1, 0, false); b = new OrthoLine(-1, 1, 1, false); Assert.False(a.Intersects(b, out _)); Assert.False(b.Intersects(a, out _)); a = new OrthoLine(1, -1, 0, false); b = new OrthoLine(1, -1, 1, false); Assert.False(a.Intersects(b, out _)); Assert.False(b.Intersects(a, out _)); }
public void PerpendicularShouldNotIntersect(int a0, int a1, int ao, int b0, int b1, int bo) { var a = new OrthoLine(a0, a1, ao, false); var b = new OrthoLine(b0, b1, bo, true); Point intersection; Assert.False(a.Intersects(b, out intersection)); Assert.False(b.Intersects(a, out intersection)); }
public void PerpendicularShouldIntersect(int a0, int a1, int ao, int b0, int b1, int bo, int x, int y) { Point intersection; var a = new OrthoLine(a0, a1, ao, false); var b = new OrthoLine(b0, b1, bo, true); Assert.True(a.Intersects(b, out intersection)); Assert.Equal(x, intersection.X); Assert.Equal(y, intersection.Y); Assert.True(b.Intersects(a, out intersection)); Assert.Equal(x, intersection.X); Assert.Equal(y, intersection.Y); a = new OrthoLine(-a0, -a1, -ao, false); b = new OrthoLine(-b0, -b1, -bo, true); Assert.True(a.Intersects(b, out intersection)); Assert.Equal(-x, intersection.X); Assert.Equal(-y, intersection.Y); Assert.True(b.Intersects(a, out intersection)); Assert.Equal(-x, intersection.X); Assert.Equal(-y, intersection.Y); }