Пример #1
0
        public void CubeCubeNoOverlap()
        {
            Cube cube1 = new Cube(new Float4(0), new Float4(5), Quaternion.Default);
            Cube cube2 = new Cube(new Float4(10), new Float4(5), Quaternion.Default);
            SeparatingAxisTheorem sat = new SeparatingAxisTheorem();
            var b1 = new SatBodyData();
            var b2 = new SatBodyData();

            b1.CreateFrom(cube1);
            b2.CreateFrom(cube2);
            var data = sat.Test(b1, b2);

            Assert.AreEqual(false, data.Intersecting);
        }
Пример #2
0
        public void AABBAABBNoOverlap()
        {
            AABB aabb1 = new AABB(new Float4(0), new Float4(10));
            AABB aabb2 = new AABB(new Float4(10), new Float4(20));
            SeparatingAxisTheorem sat = new SeparatingAxisTheorem();
            var b1 = new SatBodyData();
            var b2 = new SatBodyData();

            b1.CreateFrom(aabb1);
            b2.CreateFrom(aabb2);
            var data = sat.Test(b1, b2);

            Assert.AreEqual(false, data.Intersecting);
        }
Пример #3
0
        public void CubeCubeOverlap()
        {
            Cube aabb1 = new Cube(new Float4(0, 9, 0, 0), new Float4(5), Quaternion.Default);
            Cube aabb2 = new Cube(new Float4(0), new Float4(5), Quaternion.Default);
            SeparatingAxisTheorem sat = new SeparatingAxisTheorem();
            var b1 = new SatBodyData();
            var b2 = new SatBodyData();

            b1.CreateFrom(aabb1);
            b2.CreateFrom(aabb2);
            var data = sat.Test(b1, b2);

            Assert.AreEqual(true, data.Intersecting);
            Assert.AreEqual(1, data.Depth);
            Assert.AreEqual(new Float3(0, 1, 0), data.Normal);
        }
Пример #4
0
        public void AABBAABBNegYOverlap()
        {
            AABB aabb1 = new AABB(new Float4(0, -9, 0, 0), new Float4(10, 1, 10, 10));
            AABB aabb2 = new AABB(new Float4(0), new Float4(10));
            SeparatingAxisTheorem sat = new SeparatingAxisTheorem();
            var b1 = new SatBodyData();
            var b2 = new SatBodyData();

            b1.CreateFrom(aabb1);
            b2.CreateFrom(aabb2);
            var data = sat.Test(b1, b2);

            Assert.AreEqual(true, data.Intersecting);
            Assert.AreEqual(1, data.Depth);
            Assert.AreEqual(new Float3(0, -1, 0), data.Normal);
        }