Пример #1
0
 private void TestCompoundBodyContainsPoint(CompoundBody compoundBody, double radius)
 {
     foreach (var part in compoundBody.Parts)
     {
         Assert.IsTrue(compoundBody.ContainsPoint(part.Position));
         Assert.IsFalse(compoundBody.ContainsPoint(part.Position.CreatePoint(dx: radius)));
         Assert.IsFalse(compoundBody.ContainsPoint(part.Position.CreatePoint(dy: radius)));
         Assert.IsFalse(compoundBody.ContainsPoint(part.Position.CreatePoint(dz: radius)));
     }
 }
Пример #2
0
        private static void AssertCompoundBodyWithSinglePart_Contains_IsEquivalentToItsPartContains(Body part)
        {
            var random   = new Random(123123);
            var compound = new CompoundBody(new List <Body> {
                part
            });
            var compound2 = new CompoundBody(new List <Body> {
                compound
            });

            for (int i = 0; i < 1000; i++)
            {
                var p = new Vector3(
                    random.NextDouble() * 20 - 10,
                    random.NextDouble() * 20 - 10,
                    random.NextDouble() * 20 - 10);
                Assert.AreEqual(part.ContainsPoint(p), compound.ContainsPoint(p));
                Assert.AreEqual(part.ContainsPoint(p), compound2.ContainsPoint(p));
            }
        }