Beispiel #1
0
        public void ComputeCollision()
        {
            MinkowskiPortalRefinement algo = new MinkowskiPortalRefinement(new CollisionDetection());

            CollisionObject a = new CollisionObject(new GeometricObject
            {
                Shape = new TriangleShape(new Vector3F(0, 0, 0), new Vector3F(0, 1, 0), new Vector3F(0, 0, 1))
            });

            CollisionObject b = new CollisionObject(new GeometricObject
            {
                Shape = new SphereShape(1)
            });

            ContactSet set;

            set = algo.GetContacts(a, b);
            Assert.AreEqual(true, algo.HaveContact(a, b));
            Assert.IsTrue(Numeric.AreEqual(1, set[0].PenetrationDepth));

            ((GeometricObject)b.GeometricObject).Pose = new Pose(new Vector3F(2, 0.1f, 0.2f));
            algo.UpdateContacts(set, 0);
            Assert.AreEqual(false, algo.HaveContact(a, b));
            Assert.AreEqual(0, set.Count);

            ((GeometricObject)b.GeometricObject).Pose = new Pose(new Vector3F(0.9f, 0.1f, 0.2f));
            algo.UpdateContacts(set, 0);
            Assert.AreEqual(true, algo.HaveContact(a, b));
            Assert.AreEqual(1, set.Count);
            Assert.IsTrue(Vector3F.AreNumericallyEqual(new Vector3F(0, 0.1f, 0.2f), set[0].PositionAWorld, 0.02f));
        }
Beispiel #2
0
        public void ComputeCollision()
        {
            MinkowskiPortalRefinement algo = new MinkowskiPortalRefinement(new CollisionDetection());

              CollisionObject a = new CollisionObject(new GeometricObject
              {
            Shape = new TriangleShape(new Vector3F(0, 0, 0), new Vector3F(0, 1, 0), new Vector3F(0, 0, 1))
              });

              CollisionObject b = new CollisionObject(new GeometricObject
              {
            Shape = new SphereShape(1)
              });

              ContactSet set;

              set = algo.GetContacts(a, b);
              Assert.AreEqual(true, algo.HaveContact(a, b));
              Assert.IsTrue(Numeric.AreEqual(1, set[0].PenetrationDepth));

              ((GeometricObject)b.GeometricObject).Pose = new Pose(new Vector3F(2, 0.1f, 0.2f));
              algo.UpdateContacts(set, 0);
              Assert.AreEqual(false, algo.HaveContact(a, b));
              Assert.AreEqual(0, set.Count);

              ((GeometricObject)b.GeometricObject).Pose = new Pose(new Vector3F(0.9f, 0.1f, 0.2f));
              algo.UpdateContacts(set, 0);
              Assert.AreEqual(true, algo.HaveContact(a, b));
              Assert.AreEqual(1, set.Count);
              Assert.IsTrue(Vector3F.AreNumericallyEqual(new Vector3F(0, 0.1f, 0.2f), set[0].PositionAWorld, 0.02f));
        }
Beispiel #3
0
        public void Containment()
        {
            MinkowskiPortalRefinement algo = new MinkowskiPortalRefinement(new CollisionDetection());

            CollisionObject a = new CollisionObject(new GeometricObject
            {
                Shape = new SphereShape(2),
                Pose  = new Pose(new Vector3F(1, 2, 3)),
            });

            CollisionObject b = new CollisionObject(new GeometricObject
            {
                Shape = new SphereShape(1),
                Pose  = new Pose(new Vector3F(1, 2, 3)),
            });

            ContactSet set;

            set = algo.GetContacts(a, b);
            Assert.AreEqual(true, algo.HaveContact(a, b));
            Assert.AreEqual(3, set[0].PenetrationDepth);

            ((GeometricObject)b.GeometricObject).Pose = new Pose(new Vector3F(2, 2, 3));
            algo.UpdateContacts(set, 0);
            Assert.AreEqual(true, algo.HaveContact(a, b));
            Assert.AreEqual(2, set[0].PenetrationDepth);
        }
Beispiel #4
0
        public void TestNormals()
        {
            MinkowskiPortalRefinement algo = new MinkowskiPortalRefinement(new CollisionDetection());

            CollisionObject box = new CollisionObject(new GeometricObject
            {
                Pose  = new Pose(new Vector3F(1.99999f, 0, 0)),
                Shape = new BoxShape(2, 2, 2),
            });

            CollisionObject sphere = new CollisionObject(new GeometricObject
            {
                Shape = new SphereShape(1)
            });

            ContactSet set;

            set = algo.GetContacts(box, sphere);
            Assert.AreEqual(1, set.Count);
            Assert.IsTrue(Numeric.AreEqual(0, set[0].PenetrationDepth));
            Assert.IsTrue(Vector3F.AreNumericallyEqual(new Vector3F(-1, 0, 0), set[0].Normal, 0.001f));

            ((GeometricObject)sphere.GeometricObject).Pose = new Pose(new Vector3F(0.2f, 0, 0));
            algo.UpdateContacts(set, 0);
            Assert.AreEqual(1, set.Count);
            Assert.IsTrue(Numeric.AreEqual(0.2f, set[0].PenetrationDepth));
            Assert.IsTrue(Vector3F.AreNumericallyEqual(new Vector3F(-1, 0, 0), set[0].Normal, 0.001f));
        }
Beispiel #5
0
        public void Containment()
        {
            MinkowskiPortalRefinement algo = new MinkowskiPortalRefinement(new CollisionDetection());

              CollisionObject a = new CollisionObject(new GeometricObject
              {
            Shape = new SphereShape(2),
            Pose = new Pose(new Vector3F(1, 2, 3)),
              });

              CollisionObject b = new CollisionObject(new GeometricObject
              {
            Shape = new SphereShape(1),
            Pose = new Pose(new Vector3F(1, 2, 3)),
              });

              ContactSet set;

              set = algo.GetContacts(a, b);
              Assert.AreEqual(true, algo.HaveContact(a, b));
              Assert.AreEqual(3, set[0].PenetrationDepth);

              ((GeometricObject)b.GeometricObject).Pose = new Pose(new Vector3F(2, 2, 3));
              algo.UpdateContacts(set, 0);
              Assert.AreEqual(true, algo.HaveContact(a, b));
              Assert.AreEqual(2, set[0].PenetrationDepth);
        }
Beispiel #6
0
        public void TestNormals()
        {
            MinkowskiPortalRefinement algo = new MinkowskiPortalRefinement(new CollisionDetection());

              CollisionObject box = new CollisionObject(new GeometricObject
              {
            Pose = new Pose(new Vector3F(1.99999f, 0, 0)),
            Shape = new BoxShape(2, 2, 2),
              });

              CollisionObject sphere = new CollisionObject(new GeometricObject
              {
            Shape = new SphereShape(1)
              });

              ContactSet set;

              set = algo.GetContacts(box, sphere);
              Assert.AreEqual(1, set.Count);
              Assert.IsTrue(Numeric.AreEqual(0, set[0].PenetrationDepth));
              Assert.IsTrue(Vector3F.AreNumericallyEqual(new Vector3F(-1, 0, 0), set[0].Normal, 0.001f));

              ((GeometricObject)sphere.GeometricObject).Pose = new Pose(new Vector3F(0.2f, 0, 0));
              algo.UpdateContacts(set, 0);
              Assert.AreEqual(1, set.Count);
              Assert.IsTrue(Numeric.AreEqual(0.2f, set[0].PenetrationDepth));
              Assert.IsTrue(Vector3F.AreNumericallyEqual(new Vector3F(-1, 0, 0), set[0].Normal, 0.001f));
        }