Beispiel #1
0
        public void AddingPointsToAnEmptyBoundingBox()
        {
            var box = new BoundingBox();

            box.Add(new Point(-5, 2, 0));
            box.Add(new Point(7, 0, -3));

            Assert.AreEqual(new Point(-5, 0, -3), box.Min);
            Assert.AreEqual(new Point(7, 2, 0), box.Max);
        }
Beispiel #2
0
        public void AddingPointsToEmptyBoundingBox_ShouldAdjustTheBounds()
        {
            var box = new BoundingBox();
            var p1  = new Point(-5, 2, 0);
            var p2  = new Point(7, 0, -3);

            box.Add(p1);
            box.Add(p2);
            Assert.Equal(new Point(-5, 0, -3), box.Min, PointComparer);
            Assert.Equal(new Point(7, 2, 0), box.Max, PointComparer);
        }
        public void TestBBCreateAddedPoints()
        {
            var box = new BoundingBox();
            var p1  = new Point(-5, 2, 0);
            var p2  = new Point(7, 0, -3);

            box.Add(p1);
            box.Add(p2);

            Assert.AreEqual(box.Min, new Point(-5, 0, -3));
            Assert.AreEqual(box.Max, new Point(7, 2, 0));
        }
Beispiel #4
0
        /// <summary>
        /// the center position of each chain in the symmetry unit cell
        /// </summary>
        /// <param name="crystalChainsHash"></param>
        /// <returns></returns>
        private void GetCenterPosOfCellChains(Dictionary <string, AtomInfo[]> crystalChainsHash, ref Dictionary <string, BoundingBox> chainBbHash)
        {
            chainBbHash = new Dictionary <string, BoundingBox> ();
            double minX = 100;
            double minY = 100;
            double minZ = 100;
            double maxX = -100;
            double maxY = -100;
            double maxZ = -100;

            foreach (string cellChain in crystalChainsHash.Keys)
            {
                minX = 100;
                minY = 100;
                minZ = 100;
                maxX = -100;
                maxY = -100;
                maxZ = -100;
                AtomInfo[] chainAtoms = (AtomInfo[])crystalChainsHash[cellChain];
                foreach (AtomInfo atom in chainAtoms)
                {
                    if (minX > atom.fractCoord.X)
                    {
                        minX = atom.fractCoord.X;
                    }
                    if (maxX < atom.fractCoord.X)
                    {
                        maxX = atom.fractCoord.X;
                    }
                    if (minY > atom.fractCoord.Y)
                    {
                        minY = atom.fractCoord.Y;
                    }
                    if (maxY < atom.fractCoord.Y)
                    {
                        maxY = atom.fractCoord.Y;
                    }
                    if (minZ > atom.fractCoord.Z)
                    {
                        minZ = atom.fractCoord.Z;
                    }
                    if (maxZ < atom.fractCoord.Z)
                    {
                        maxZ = atom.fractCoord.Z;
                    }
                }
                BoundingBox bb = new BoundingBox();
                bb.Add(minX, maxX);
                bb.Add(minY, maxY);
                bb.Add(minZ, maxZ);
                chainBbHash.Add(cellChain, bb);
            }
        }
Beispiel #5
0
        public BoundingBox CalculateBoundingBox()
        {
            BoundingBox result = this.MinimumBoundingBox;

            if (LeftChild != null && !LeftChild.IsNilNode())
            {
                result = result.Add(LeftChild.CalculateBoundingBox());
            }
            if (RightChild != null && !RightChild.IsNilNode())
            {
                result = result.Add(RightChild.CalculateBoundingBox());
            }

            return(result);
        }
Beispiel #6
0
        public void AddingOneBoundingBoxToAnother_ShouldCauseOriginalBoxToExpand()
        {
            var box1 = new BoundingBox(new Point(-5, -2, 0), new Point(7, 4, 4));
            var box2 = new BoundingBox(new Point(8, -7, -2), new Point(14, 2, 8));

            box1.Add(box2);
            Assert.Equal(new Point(-5, -7, -2), box1.Min, PointComparer);
            Assert.Equal(new Point(14, 4, 8), box1.Max, PointComparer);
        }
        public void TestBBNested()
        {
            var box1 = new BoundingBox(new Point(-5, -2, 0), new Point(7, 4, 4));
            var box2 = new BoundingBox(new Point(8, -7, -2), new Point(14, 2, 8));

            box1.Add(box2);

            Assert.AreEqual(box1.Min, new Point(-5, -7, -2));
            Assert.AreEqual(box1.Max, new Point(14, 4, 8));
        }
Beispiel #8
0
        public void AddingOneBoundingBoxToAnother()
        {
            var box1 = new BoundingBox(new Point(-5, -2, 0), new Point(7, 4, 4));
            var box2 = new BoundingBox(new Point(8, -7, -2), new Point(14, 2, 8));

            box1.Add(box2);

            Assert.AreEqual(new Point(-5, -7, -2), box1.Min);
            Assert.AreEqual(new Point(14, 4, 8), box1.Max);
        }