public static void line_ray_basic_intersection_result() { var a = new Line2(new Point2(3, 3), new Vector2(1, 1)); var b = new Ray2(new Point2(0, 1), new Vector2(0, 1)); var c = new Ray2(new Point2(2, 2), new Vector2(-1, -1)); var d = new Ray2(new Point2(2, 3), new Vector2(-1, -1)); a.Intersection(b.GetReverse()).Should().Be(Point2.Zero); a.Intersection(c).Should().Be(c); a.Intersection(c.GetReverse()).Should().Be(c.GetReverse()); a.Intersection(b).Should().BeNull(); a.Intersection(d).Should().BeNull(); a.Intersection(d.GetReverse()).Should().BeNull(); }
public static void line_ray_basic_intersection_testing() { var a = new Line2(new Point2(3, 3), new Vector2(1, 1)); var b = new Ray2(new Point2(0, 1), new Vector2(0, 1)); var c = new Ray2(new Point2(2, 2), new Vector2(-1, -1)); var d = new Ray2(new Point2(2, 3), new Vector2(-1, -1)); a.Intersects(b.GetReverse()).Should().BeTrue(); a.Intersects(c).Should().BeTrue(); a.Intersects(c.GetReverse()).Should().BeTrue(); a.Intersects(b).Should().BeFalse(); a.Intersects(d).Should().BeFalse(); a.Intersects(d.GetReverse()).Should().BeFalse(); }
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 raw_intersection_result() { 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.Equal(null, a.Intersection(b)); Assert.Equal(new Point2(0, 0), a.Intersection(c)); Assert.Equal(null, a.Intersection(new Ray2(new Point2(0, 2), new Vector2(0, 1)))); Assert.Equal(null, a.Intersection(new Ray2(new Point2(0, -2), new Vector2(0, -1)))); Assert.Equal(new Point2(0, 1), a.Intersection(d)); Assert.Equal(a, a.Intersection(d.GetReverse())); Assert.Equal(new Point2(0, -1), a.Intersection(e)); Assert.Equal(a, a.Intersection(e.GetReverse())); Assert.Equal(new Segment2(f.P, a.B), a.Intersection(f)); Assert.Equal(new Segment2(a.A, f.P), a.Intersection(f.GetReverse())); }