public void line_intersects_test() { var a = new Segment2(new Point2(0, -1), new Point2(0, 1)); var b = new Line2(new Point2(1, 1), new Vector2(1, 1)); var c = new Line2(new Point2(1, 1), new Vector2(0, 1)); var d = new Line2(new Point2(0, 0), new Vector2(0, 1)); var e = new Line2(new Point2(0, -2), new Vector2(1, 1)); Assert.True(a.Intersects(b)); Assert.False(a.Intersects(c)); Assert.True(a.Intersects(d)); Assert.False(a.Intersects(e)); }
public void ray_intersects_test() { var a = new Segment2(new Point2(0, -1), new Point2(0, 1)); var b = new Ray2(new Point2(1, 1), new Vector2(1, 1)); var c = new Ray2(new Point2(1, 1), new Vector2(-1, -1)); var d = new Ray2(new Point2(0, 1), new Vector2(0, 1)); var e = new Ray2(new Point2(0, -1), new Vector2(0, -1)); var f = new Ray2(new Point2(0, 0), new Vector2(0, 3)); Assert.False(a.Intersects(b)); Assert.True(a.Intersects(c)); Assert.False(a.Intersects(new Ray2(new Point2(0, 2), new Vector2(0, 1)))); Assert.False(a.Intersects(new Ray2(new Point2(0, -2), new Vector2(0, -1)))); Assert.True(a.Intersects(d)); Assert.True(a.Intersects(d.GetReverse())); Assert.True(a.Intersects(e)); Assert.True(a.Intersects(e.GetReverse())); Assert.True(a.Intersects(f)); Assert.True(a.Intersects(f.GetReverse())); }
public void intersect_point_test() { var s = new Segment2(new Point2(), new Point2(4, 2)); Assert.False(s.Intersects(new Point2(-3, 0))); Assert.False(s.Intersects(new Point2(7, 5))); Assert.False(s.Intersects(new Point2(1, 3))); Assert.True(s.Intersects(new Point2())); Assert.True(s.Intersects(new Point2(4, 2))); Assert.True(s.Intersects(new Point2(2, 1))); }