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); } }
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); } }
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); } }
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); } }