Ejemplo n.º 1
0
        public void DistributionTest()
        {
            var udd0 = new UniformDistributionD {
                MinValue = 1.001, MaxValue = 2.0002
            };
            var udd1 = Serialize(udd0);

            Assert.IsTrue(udd0.MinValue == udd1.MinValue);
            Assert.IsTrue(udd0.MaxValue == udd1.MaxValue);

            var cdd0 = new DirectionDistribution {
                Deviation = 1.001f, Direction = new Vector3F(1, 2, 3)
            };
            var cdd1 = Serialize(cdd0);

            Assert.IsTrue(cdd0.Deviation == cdd1.Deviation);
            Assert.IsTrue(cdd0.Direction == cdd1.Direction);
        }
        public void Test1()
        {
            var random = new Random(123456);
            var d      = new DirectionDistribution
            {
                Direction = Vector3.UnitY,
                Deviation = MathHelper.ToRadians(30),
            };

            // Create 100 random values and check if they are valid.
            for (int i = 0; i < 100; i++)
            {
                Vector3 r = d.Next(random);
                Assert.IsTrue(r.IsNumericallyNormalized);

                float angle = Vector3.GetAngle(Vector3.UnitY, r);
                Assert.IsTrue(angle <= MathHelper.ToRadians(30));
            }

            Assert.AreEqual(MathHelper.ToRadians(30), d.Deviation);
            Assert.AreEqual(new Vector3(0, 1, 0), d.Direction);

            d.Deviation = 0.1f;
            Assert.AreEqual(0.1f, d.Deviation);
            Assert.AreEqual(new Vector3(0, 1, 0), d.Direction);

            d.Direction = new Vector3(1, 2, 3);
            Assert.AreEqual(0.1f, d.Deviation);
            Assert.AreEqual(new Vector3(1, 2, 3), d.Direction);

            // Create 100 random values and check if they are valid.
            for (int i = 0; i < 100; i++)
            {
                Vector3 r = d.Next(random);
                Assert.IsTrue(r.IsNumericallyNormalized);

                float angle = Vector3.GetAngle(d.Direction, r);
                Assert.IsTrue(angle <= 0.1f);
            }
        }
        public void Test1()
        {
            var random = new Random(123456);
              var d = new DirectionDistribution
              {
            Direction = Vector3F.UnitY,
            Deviation = MathHelper.ToRadians(30),
              };

              // Create 100 random values and check if they are valid.
              for (int i=0; i<100; i++)
              {
            Vector3F r = d.Next(random);
            Assert.IsTrue(r.IsNumericallyNormalized);

            float angle = Vector3F.GetAngle(Vector3F.UnitY, r);
            Assert.IsTrue(angle <= MathHelper.ToRadians(30));
              }

              Assert.AreEqual(MathHelper.ToRadians(30), d.Deviation);
              Assert.AreEqual(new Vector3F(0, 1, 0), d.Direction);

              d.Deviation = 0.1f;
              Assert.AreEqual(0.1f, d.Deviation);
              Assert.AreEqual(new Vector3F(0, 1, 0), d.Direction);

              d.Direction = new Vector3F(1, 2, 3);
              Assert.AreEqual(0.1f, d.Deviation);
              Assert.AreEqual(new Vector3F(1, 2, 3), d.Direction);

              // Create 100 random values and check if they are valid.
              for (int i = 0; i < 100; i++)
              {
            Vector3F r = d.Next(random);
            Assert.IsTrue(r.IsNumericallyNormalized);

            float angle = Vector3F.GetAngle(d.Direction, r);
            Assert.IsTrue(angle <= 0.1f);
              }
        }