Example #1
0
        public void TestBoundingBoxCalculationForZPlane()
        {
            Plane3 zPlane = new Plane3(Vector3.UnitZ * 2.0f, Vector3.Backward);

            Assert.AreEqual(
                new Volumes.AxisAlignedBox3(
                    new Vector3(float.NegativeInfinity, float.NegativeInfinity, 2.0f),
                    new Vector3(float.PositiveInfinity, float.PositiveInfinity, 2.0f)
                    ),
                zPlane.BoundingBox
                );
        }
Example #2
0
        public void TestBoundingBoxCalculationForYPlane()
        {
            Plane3 yPlane = new Plane3(Vector3.UnitY * 2.0f, Vector3.Up);

            Assert.AreEqual(
                new Volumes.AxisAlignedBox3(
                    new Vector3(float.NegativeInfinity, 2.0f, float.NegativeInfinity),
                    new Vector3(float.PositiveInfinity, 2.0f, float.PositiveInfinity)
                    ),
                yPlane.BoundingBox
                );
        }
Example #3
0
        public void TestBoundingBoxCalculationForXPlane()
        {
            Plane3 xPlane = new Plane3(Vector3.UnitX * 2.0f, Vector3.Right);

            Assert.AreEqual(
                new Volumes.AxisAlignedBox3(
                    new Vector3(2.0f, float.NegativeInfinity, float.NegativeInfinity),
                    new Vector3(2.0f, float.PositiveInfinity, float.PositiveInfinity)
                    ),
                xPlane.BoundingBox
                );
        }
Example #4
0
 public void TestSideDetermination()
 {
     Assert.AreEqual(
         Side.Positive, Plane3.GetSide(Vector3.Zero, Vector3.Up, Vector3.UnitY)
         );
     Assert.AreEqual(
         Side.Negative, Plane3.GetSide(Vector3.Zero, Vector3.Up, -Vector3.UnitY)
         );
     Assert.AreEqual(
         Side.Negative, Plane3.GetSide(Vector3.UnitY * 2.0f, Vector3.Up, Vector3.UnitY)
         );
 }
Example #5
0
        public void TestBoundingBoxCalculation()
        {
            Vector3 diagonal = Vector3.Normalize(Vector3.One);
            Plane3  plane    = new Plane3(Vector3.Zero, diagonal);

            Assert.AreEqual(
                new Volumes.AxisAlignedBox3(
                    new Vector3(float.NegativeInfinity, float.NegativeInfinity, float.NegativeInfinity),
                    new Vector3(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity)
                    ),
                plane.BoundingBox
                );
        }
Example #6
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);
            }
        }
Example #7
0
        public void TestRandomPointOnPerimeterForYPlane()
        {
            IRandom randomNumberGenerator = new DefaultRandom();

            Plane3 yPlane = new Plane3(Vector3.UnitY * 2.0f, Vector3.Up);

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

                Assert.IsTrue(float.IsInfinity(randomPoint.X));
                Assert.AreEqual(2.0f, randomPoint.Y);
                Assert.IsTrue(float.IsInfinity(randomPoint.Z));
            }
        }
Example #8
0
        public void TestCenterOfMass()
        {
            Plane3 zeroPlane = new Plane3(Vector3.Zero, Vector3.Up);

            Assert.AreEqual(Vector3.Zero, zeroPlane.CenterOfMass);

            Plane3 xPlane = new Plane3(Vector3.UnitX, Vector3.Right);

            Assert.AreEqual(Vector3.Right, xPlane.CenterOfMass);

            Plane3 yPlane = new Plane3(Vector3.UnitY, Vector3.Up);

            Assert.AreEqual(Vector3.Up, yPlane.CenterOfMass);

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

            Assert.AreEqual(Vector3.Backward, zPlane.CenterOfMass);
        }
Example #9
0
        public void TestRandomPointOnPerimeter()
        {
            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.RandomPointOnPerimeter(randomNumberGenerator);
                CollectionAssert.Contains(possiblePoints, randomPoint);
            }
        }
Example #10
0
        public void TestClosestPointToPlane()
        {
            Plane3 xPlane = new Plane3(Vector3.UnitX * 2.0f, Vector3.Right);

            Assert.AreEqual(
                new Vector3(2.0f, 20.0f, 30.0f),
                xPlane.ClosestPointTo(new Vector3(10.0f, 20.0f, 30.0f))
                );

            Plane3 yPlane = new Plane3(Vector3.UnitY * 2.0f, Vector3.Up);

            Assert.AreEqual(
                new Vector3(10.0f, 2.0f, 30.0f),
                yPlane.ClosestPointTo(new Vector3(10.0f, 20.0f, 30.0f))
                );

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

            Assert.AreEqual(
                new Vector3(10.0f, 20.0f, 2.0f),
                zPlane.ClosestPointTo(new Vector3(10.0f, 20.0f, 30.0f))
                );
        }
Example #11
0
        public void TestAreaIsInfinite()
        {
            Plane3 plane = new Plane3(Vector3.Zero, Vector3.Up);

            Assert.AreEqual(float.PositiveInfinity, plane.Area);
        }
Example #12
0
        public void TestDistanceConstructor()
        {
            Plane3 plane = new Plane3(123.0f, Vector3.Up);

            Assert.AreEqual(123.0f, plane.Offset.Length());
        }
Example #13
0
        public void TestCircumferenceIsInfinite()
        {
            Plane3 plane = new Plane3(Vector3.Zero, Vector3.Up);

            Assert.AreEqual(float.PositiveInfinity, plane.CircumferenceLength);
        }