public void RectangularCuboid_BoundingBox_IsCorrect(
            double x, double y, double z,
            double sizeX = 4, double sizeY = 7, double sizeZ = 5)
        {
            var cuboid = new RectangularCuboid(new Vector3(x, y, z), sizeX, sizeY, sizeZ);
            var box    = cuboid.GetBoundingBox();

            AssertCuboidsEqual(cuboid, box);
        }
        public void Ball_BoundingBox_IsCorrect(double x, double y, double z, double radius)
        {
            var ball        = new Ball(new Vector3(x, y, z), radius);
            var box         = ball.GetBoundingBox();
            var length      = radius * 2;
            var expectedBox = new RectangularCuboid(new Vector3(x, y, z), length, length, length);

            AssertCuboidsEqual(expectedBox, box);
        }
        public void RectangularCuboid_ContainsPoint_IsCorrect(
            double x, double y, double z,
            double sizeX = 8, double sizeY = 4, double sizeZ = 6)
        {
            var cuboid = new RectangularCuboid(new Vector3(x, y, z), sizeX, sizeY, sizeZ);

            ContainsPoint_ComplexTest(cuboid, true, sizeX / 2, sizeY / 2, sizeZ / 2);
            ContainsPoint_ComplexTest(cuboid, false, sizeX / 2 + 1, sizeY / 2 + 1, sizeZ / 2 + 1);
        }
        private void AssertCuboidsEqual(RectangularCuboid expected, RectangularCuboid actual)
        {
            var message = " is not equal!";

            Assert.That(expected.Position.Equals(actual.Position, Constants.Inaccuracy), $"{expected.Position} != {actual.Position}");
            Assert.AreEqual(expected.SizeX, actual.SizeX, Constants.Inaccuracy, "Length" + message);
            Assert.AreEqual(expected.SizeY, actual.SizeY, Constants.Inaccuracy, "Width" + message);
            Assert.AreEqual(expected.SizeZ, actual.SizeZ, Constants.Inaccuracy, "Height" + message);
        }
        public void CompoundBody_BoundingBox_IsCorrect(double x, double y, double z, double radius)
        {
            const int    figuresCount = 6;
            const double indent       = 2.2;
            var          sizeZ        = radius * 20 + indent * (figuresCount - 1);
            var          expectedBox  = new RectangularCuboid(new Vector3(x, y, sizeZ / 2 + z), radius * 2, radius * 2, sizeZ);

            foreach (var compoundBody in GetCompoundBodies(new Vector3(x, y, z), radius, indent))
            {
                AssertCuboidsEqual(expectedBox, compoundBody.GetBoundingBox());
            }
        }
Beispiel #6
0
        public static Vector3 GetMaxVector(Vector3 a, RectangularCuboid b)
        {
            //find max point in object B
            Vector3 maxPointObjectB = b.Position + new Vector3(b.SizeX / 2, b.SizeY / 2, b.SizeZ / 2);
            //check if the point is above and to the right of point a
            Vector3 vector = maxPointObjectB - a;

            //if yes, set the coordinate of the max point else leave the coordinates a
            return(new Vector3(vector.X > 0 ? maxPointObjectB.X : a.X,
                               vector.Y > 0 ? maxPointObjectB.Y : a.Y,
                               vector.Z > 0 ? maxPointObjectB.Z : a.Z));
        }
Beispiel #7
0
        public static Vector3 GetMinVector(Vector3 a, RectangularCuboid b)
        {
            //find min point in object B
            Vector3 minPointObjectB = b.Position - new Vector3(b.SizeX / 2, b.SizeY / 2, b.SizeZ / 2);
            //check if the point is below and to the left of point a
            Vector3 vector = a - minPointObjectB;

            //if yes, set the coordinate of the minimum point else leave the coordinates a
            return(new Vector3(vector.X > 0 ? minPointObjectB.X : a.X,
                               vector.Y > 0 ? minPointObjectB.Y : a.Y,
                               vector.Z > 0 ? minPointObjectB.Z : a.Z));
        }
        public void Cylinder_BoundingBox_IsCorrect(double x, double y, double z, double radius = 4, double sizeZ = 5)
        {
            var cylinder = new Cylinder(new Vector3(x, y, z), sizeZ, radius);
            var box      = cylinder.GetBoundingBox();
            var cuboid   = new RectangularCuboid
                           (
                cylinder.Position,
                cylinder.Radius * 2,
                cylinder.Radius * 2,
                cylinder.SizeZ
                           );

            AssertCuboidsEqual(cuboid, box);
        }