コード例 #1
0
        public void SegmentQueryTest()
        {
            var space = new Space();
            var body  = new Body(1, 1.66);
            var shape = new Box(body, 100, 100, 0);

            body.Position = new Vect(0, 0);
            var end = new Vect(0, 1);

            SegmentQueryInfo[] infos = space.SegmentQuery(body.Position, end, 2.0, ShapeFilter.All).ToArray();

            Assert.AreEqual(0, infos.Length, "#1");

            space.AddBody(body);
            space.AddShape(shape);

            infos = space.SegmentQuery(body.Position, end, 2.0, ShapeFilter.All).ToArray();

            SegmentQueryInfo first = space.SegmentQueryFirst(body.Position, end, 2.0, ShapeFilter.All);


            Assert.AreEqual(1, infos.Length, "#2");
            Assert.AreSame(shape, infos[0].Shape, "#3");

            Assert.AreEqual(infos[0], first, "#4");

            shape.Dispose();
            body.Dispose();
            space.Dispose();
        }
コード例 #2
0
        public void SegmentQueryTest()
        {
            var body  = new Body(1, 1.66);
            var shape = new Box(body, 1, 1, 0);

            var a = new Vect(-3, 0);
            var b = new Vect(3, 0);

            SegmentQueryInfo info = shape.SegmentQuery(a, b, 1.0);

            Assert.AreEqual(0, info.Alpha, "#1");
            Assert.AreEqual(new Vect(-1, 0), info.Normal, "#2");
            Assert.AreSame(shape, info.Shape, "#3");
            Assert.AreEqual(new Vect(3, 0), info.Point, "#4");
        }