Esempio n. 1
0
        // create four children that fully divide this quad into four quads of equal area
        private void subdivide()
        {
            int x             = this.boundary.southWest.x;
            int y             = this.boundary.southWest.y;
            int halfDimension = this.boundary.dimension / 2;

            BoundarySouthWest northWestNodeField = new BoundarySouthWest(x, y + halfDimension);
            Bounding          northWestBounding  = new Bounding(northWestNodeField, halfDimension);

            this.northWest = new NodeQuadTree(northWestBounding);

            BoundarySouthWest northEastNodeField = new BoundarySouthWest(x + halfDimension, y + halfDimension);
            Bounding          northEastBounding  = new Bounding(northEastNodeField, halfDimension);

            this.northEast = new NodeQuadTree(northEastBounding);

            BoundarySouthWest southWestNodeField = new BoundarySouthWest(x, y);
            Bounding          southWestBounding  = new Bounding(southWestNodeField, halfDimension);

            this.southWest = new NodeQuadTree(southWestBounding);

            BoundarySouthWest southEastNodeField = new BoundarySouthWest(x + halfDimension, y);
            Bounding          southEastBounding  = new Bounding(southEastNodeField, halfDimension);

            this.southEast = new NodeQuadTree(southEastBounding);
        }
Esempio n. 2
0
        public List <Star> nearbyNearStars(Star star, int tpye = 0)
        {
            List <Star> nearby = new List <Star>();


            //fetch nearby nodes
            BoundarySouthWest boundarySouthWest    = new BoundarySouthWest(star.X - 1, star.Y - 1);
            Bounding          NodeQuadTreeBounding = new Bounding(boundarySouthWest, 3);

            nearby = queryRange(NodeQuadTreeBounding);

            if (nearby.Count == 1)
            {
                nearby.Clear();
            }
            else
            {
                for (int i = nearby.Count - 1; i >= 0; i--)
                {
                    if (nearby[i].Id == star.Id)
                    {
                        nearby.RemoveAt(i);
                        continue;
                    }

                    if (tpye != 0)
                    {
                        if (nearby[i].StarNebulaType != tpye)
                        {
                            nearby.RemoveAt(i);
                        }
                    }
                }
            }

            return(nearby);
        }
Esempio n. 3
0
 public Bounding(BoundarySouthWest southWest, int dimension)
 {
     this.southWest = southWest;
     this.dimension = dimension;
 }