예제 #1
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 21DEC2008  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * Return a new HyperCube representing the mbb of the Union of this
         * HyperCube and <B>h</B>
         *
         * @param  h The HyperCube that we want to Union with this HyperCube.
         * @return  A HyperCube representing the mbb of their Union.
         */
        public HyperCube GetUnionMbb(HyperCube h)
        {
            if (h == null)
            {
                throw new
                      ArgumentException("HyperCube cannot be null.");
            }

            if (h.GetDimension() != GetDimension())
            {
                throw new
                      ArgumentException
                          ("HyperCubes must be of the same dimension.");
            }

            double[] min = new double[GetDimension()];
            double[] max = new double[GetDimension()];

            for (int i = 0; i < GetDimension(); i++)
            {
                min[i] = Math.Min(_p1.GetFloatCoordinate(i),
                                  h._p1.GetFloatCoordinate(i));
                max[i] = Math.Max(_p2.GetFloatCoordinate(i),
                                  h._p2.GetFloatCoordinate(i));
            }

            return(new HyperCube(new Point(min), new Point(max)));
        }
예제 #2
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 21DEC2008  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * Tests to see whether <B>h</B> is inside this HyperCube.
         * If <B>h</B> is exactly the same shape as this object, it is considered
         * to be inside.
         *
         * @return True if <B>h</B> is inside, false otherwise.
         */
        public bool Enclosure(HyperCube h)
        {
            if (h == null)
            {
                throw new
                      ArgumentException("HyperCube cannot be null.");
            }

            if (h.GetDimension() != GetDimension())
            {
                throw new
                      ArgumentException
                          ("HyperCube dimension is different from current dimension.");
            }

            bool inside = true;

            for (int i = 0; i < GetDimension(); i++)
            {
                if (_p1.GetFloatCoordinate(i) > h._p1.GetFloatCoordinate(i) ||
                    _p2.GetFloatCoordinate(i) < h._p2.GetFloatCoordinate(i))
                {
                    inside = false;
                    break;
                }
            }

            return(inside);
        }
예제 #3
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 21DEC2008  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * Returns a ArrayList with all Hypercubes that completely contain HyperCube
         * <B>h</B>.
         * The HyperCubes are returned in post order traversing, according to the
         * Nodes where they belong.
         *
         * @param h The given HyperCube.
         * @param root The node where the search should begin.
         * @return A ArrayList containing the appropriate HyperCubes in the correct
         * order.
         */
        public ArrayList Enclosure(HyperCube h, AbstractNode root)
        {
            if (h == null || root == null)
            {
                throw new
                      ArgumentException("Arguments cannot be null.");
            }

            if (h.GetDimension() != _file.Dimension)
            {
                throw new
                      ArgumentException("HyperCube dimension " +
                                        "different than RTree dimension.");
            }

            ArrayList v = new ArrayList();

            if (root.GetNodeMbb().Enclosure(h))
            {
                v.Add(root);

                if (!root.IsLeaf())
                {
                    for (int i = 0; i < root.UsedSpace; i++)
                    {
                        if (root.Data[i].Enclosure(h))
                        {
                            ArrayList a = Enclosure(h, ((Index)root).GetChild(i));
                            for (int j = 0; j < a.Count; j++)
                            {
                                v.Add(a[j]);
                            }
                        }
                    }
                }
            }
            return(v);
        }
예제 #4
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 21DEC2008  James Shen                 	          Initial Creation
        ////////////////////////////////////////////////////////////////////////////
        /**
         * Returns a ArrayList with all nodes that Intersect with the given HyperCube.
         * The nodes are returned in post order traversing
         *
         * @param h The given HyperCube that is tested for overlapping.
         * @param root The node where the search should begin.
         * @return A ArrayList containing the appropriate nodes in the correct order.
         */
        public ArrayList Intersection(HyperCube h, AbstractNode root)
        {
            if (h == null || root == null)
            {
                throw new ArgumentException("Arguments cannot be null.");
            }

            if (h.GetDimension() != _file.Dimension)
            {
                throw new ArgumentException
                        ("HyperCube dimension different than RTree dimension.");
            }

            ArrayList v = new ArrayList();

            if (root.GetNodeMbb().Intersection(h))
            {
                v.Add(root);

                if (!root.IsLeaf())
                {
                    for (int i = 0; i < root.UsedSpace; i++)
                    {
                        if (root.Data[i].Intersection(h))
                        {
                            ArrayList a = Intersection(h, ((Index)root).GetChild(i));
                            for (int j = 0; j < a.Count; j++)
                            {
                                v.Add(a[j]);
                            }
                        }
                    }
                }
            }
            return v;
        }
예제 #5
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 21DEC2008  James Shen                 	          Initial Creation
        ////////////////////////////////////////////////////////////////////////////
        /**
         *
         * Tests to see whether <B>h</B> has any common points with this HyperCube.
         * If <B>h</B> is inside this object (or vice versa), it returns true.
         *
         * @return True if <B>h</B> and this HyperCube Intersect, false otherwise.
         */
        public bool Intersection(HyperCube h)
        {
            if (h == null) throw new
                    ArgumentException("HyperCube cannot be null.");

            if (h.GetDimension() != GetDimension()) throw new
                      ArgumentException
                    ("HyperCube dimension is different from current dimension.");

            bool intersect = true;
            for (int i = 0; i < GetDimension(); i++)
            {
                if (_p1.GetFloatCoordinate(i) > h._p2.GetFloatCoordinate(i) ||
                        _p2.GetFloatCoordinate(i) < h._p1.GetFloatCoordinate(i))
                {
                    intersect = false;
                    break;
                }
            }
            return intersect;
        }
예제 #6
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 21DEC2008  James Shen                 	          Initial Creation
        ////////////////////////////////////////////////////////////////////////////
        /**
         * Return a new HyperCube representing the mbb of the Union of this
         * HyperCube and <B>h</B>
         *
         * @param  h The HyperCube that we want to Union with this HyperCube.
         * @return  A HyperCube representing the mbb of their Union.
         */
        public HyperCube GetUnionMbb(HyperCube h)
        {
            if (h == null) throw new
                    ArgumentException("HyperCube cannot be null.");

            if (h.GetDimension() != GetDimension()) throw new
                    ArgumentException
                    ("HyperCubes must be of the same dimension.");

            double[] min = new double[GetDimension()];
            double[] max = new double[GetDimension()];

            for (int i = 0; i < GetDimension(); i++)
            {
                min[i] = Math.Min(_p1.GetFloatCoordinate(i),
                        h._p1.GetFloatCoordinate(i));
                max[i] = Math.Max(_p2.GetFloatCoordinate(i),
                        h._p2.GetFloatCoordinate(i));
            }

            return new HyperCube(new Point(min), new Point(max));
        }