Exemplo n.º 1
0
        public void TestRandomPointWithinForZPlane()
        {
            IRandom randomNumberGenerator = new DefaultRandom();

            Plane3 zPlane = new Plane3(Vector3.UnitZ * 2.0f, Vector3.Backward);

            for (int index = 0; index < Specifications.ProbabilisticFunctionSamples; ++index)
            {
                Vector3 randomPoint = zPlane.RandomPointWithin(randomNumberGenerator);

                Assert.IsTrue(float.IsInfinity(randomPoint.X));
                Assert.IsTrue(float.IsInfinity(randomPoint.Y));
                Assert.AreEqual(2.0f, randomPoint.Z);
            }
        }
Exemplo n.º 2
0
        public void TestRandomPointWithin()
        {
            IRandom randomNumberGenerator = new DefaultRandom();

            // A random point has to involve infinity (since the chance that of hitting the
            // meager numeric range of a float, or any other finite number system, is about
            // zero for a infinitely large plane). But given the orientation of the plane,
            // only these combinations of positive and negative infinity can be possible.
            Vector3[] possiblePoints = new Vector3[] {
                new Vector3(float.NegativeInfinity, float.PositiveInfinity, float.PositiveInfinity),
                new Vector3(float.NegativeInfinity, float.NegativeInfinity, float.PositiveInfinity),
                new Vector3(float.PositiveInfinity, float.PositiveInfinity, float.NegativeInfinity),
                new Vector3(float.PositiveInfinity, float.NegativeInfinity, float.NegativeInfinity),
            };

            Plane3 plane = new Plane3(Vector3.Zero, Vector3.Normalize(Vector3.One));

            for (int index = 0; index < Specifications.ProbabilisticFunctionSamples; ++index)
            {
                Vector3 randomPoint = plane.RandomPointWithin(randomNumberGenerator);
                //Assert.That(randomPoint, Is.OneOf(possiblePoints));
                CollectionAssert.Contains(possiblePoints, randomPoint);
            }
        }
Exemplo n.º 3
0
    public void TestRandomPointWithin() {
      IRandom randomNumberGenerator = new DefaultRandom();

      // A random point has to involve infinity (since the chance that of hitting the
      // meager numeric range of a float, or any other finite number system, is about
      // zero for a infinitely large plane). But given the orientation of the plane,
      // only these combinations of positive and negative infinity can be possible.
      Vector3[] possiblePoints = new Vector3[] {
        new Vector3(float.NegativeInfinity, float.PositiveInfinity, float.PositiveInfinity),
        new Vector3(float.NegativeInfinity, float.NegativeInfinity, float.PositiveInfinity),
        new Vector3(float.PositiveInfinity, float.PositiveInfinity, float.NegativeInfinity),
        new Vector3(float.PositiveInfinity, float.NegativeInfinity, float.NegativeInfinity),
      };

      Plane3 plane = new Plane3(Vector3.Zero, Vector3.Normalize(Vector3.One));
      for(int index = 0; index < Specifications.ProbabilisticFunctionSamples; ++index) {
        Vector3 randomPoint = plane.RandomPointWithin(randomNumberGenerator);
        //Assert.That(randomPoint, Is.OneOf(possiblePoints));
        CollectionAssert.Contains(possiblePoints, randomPoint);
      }
    }
Exemplo n.º 4
0
    public void TestRandomPointWithinForZPlane() {
      IRandom randomNumberGenerator = new DefaultRandom();

      Plane3 zPlane = new Plane3(Vector3.UnitZ * 2.0f, Vector3.Backward);
      for(int index = 0; index < Specifications.ProbabilisticFunctionSamples; ++index) {
        Vector3 randomPoint = zPlane.RandomPointWithin(randomNumberGenerator);

        Assert.IsTrue(float.IsInfinity(randomPoint.X));
        Assert.IsTrue(float.IsInfinity(randomPoint.Y));
        Assert.AreEqual(2.0f, randomPoint.Z);
      }
    }