コード例 #1
0
ファイル: SphereIterator.cs プロジェクト: carlhuth/GenXSource
        /**
         * checks one tuple for distance
         * @param t
         * @return boolean
         */
        private bool isWithinRadius(Tuple t)
        {
            float dist2;
            float distT;

            distT = t.getDimensionValue(0) - centerValues[0];
            if (tHemisphere && distT < 0)
            {
                return(false);
            }
            dist2 = distT * distT;
            if (dist2 > radius2)
            {
                return(false);
            }
            int dim = bspt.dimMax - 1;

            do
            {
                distT  = t.getDimensionValue(dim) - centerValues[dim];
                dist2 += distT * distT;
                if (dist2 > radius2)
                {
                    return(false);
                }
            }while (--dim > 0);

            this._foundDistance2 = dist2;
            return(true);
        }
コード例 #2
0
ファイル: Node.cs プロジェクト: xuchuansheng/GenXSource
 public override Element addTuple(int level, Tuple tuple)
 {
     float dimValue = tuple.getDimensionValue(dim);
     ++count;
     bool addLeft;
     if (dimValue < maxLeft)
     {
         addLeft = true;
     }
     else if (dimValue > minRight)
     {
         addLeft = false;
     }
     else if (dimValue == maxLeft)
     {
         if (dimValue == minRight)
         {
             if (eleLeft.count < eleRight.count)
                 addLeft = true;
             else
                 addLeft = false;
         }
         else
             addLeft = true;
     }
     else if (dimValue == minRight)
         addLeft = false;
     else
     {
         if (eleLeft.count < eleRight.count)
             addLeft = true;
         else
             addLeft = false;
     }
     if (addLeft)
     {
         if (dimValue < minLeft)
             minLeft = dimValue;
         else if (dimValue > maxLeft)
             maxLeft = dimValue;
         eleLeft = eleLeft.addTuple(level + 1, tuple);
     }
     else
     {
         if (dimValue < minRight)
             minRight = dimValue;
         else if (dimValue > maxRight)
             maxRight = dimValue;
         eleRight = eleRight.addTuple(level + 1, tuple);
     }
     return this;
 }
コード例 #3
0
 /**
  * initialize to return all points within the sphere defined
  * by center and radius
  *
  * @param center
  * @param radius
  */
 public void initialize(Tuple center, float radius)
 {
     this.center = center;
     this.radius = radius;
     this.radius2 = radius * radius;
     this.tHemisphere = false;
     for (int dim = bspt.dimMax; --dim >= 0; )
         centerValues[dim] = center.getDimensionValue(dim);
     leaf = null;
     stack[0] = bspt.eleRoot;
     sp = 1;
     findLeftLeaf();
 }
コード例 #4
0
ファイル: SphereIterator.cs プロジェクト: carlhuth/GenXSource
 /**
  * initialize to return all points within the sphere defined
  * by center and radius
  *
  * @param center
  * @param radius
  */
 public void initialize(Tuple center, float radius)
 {
     this.center      = center;
     this.radius      = radius;
     this.radius2     = radius * radius;
     this.tHemisphere = false;
     for (int dim = bspt.dimMax; --dim >= 0;)
     {
         centerValues[dim] = center.getDimensionValue(dim);
     }
     leaf     = null;
     stack[0] = bspt.eleRoot;
     sp       = 1;
     findLeftLeaf();
 }
コード例 #5
0
 public void sort(int dim)
 {
     for (int i = count; --i > 0;)
     { // this is > not >=
         Tuple champion      = tuples[i];
         float championValue = champion.getDimensionValue(dim);
         for (int j = i; --j >= 0;)
         {
             Tuple challenger      = tuples[j];
             float challengerValue = challenger.getDimensionValue(dim);
             if (challengerValue > championValue)
             {
                 tuples[i]     = challenger;
                 tuples[j]     = champion;
                 champion      = challenger;
                 championValue = challengerValue;
             }
         }
     }
 }
コード例 #6
0
        /**
         * checks one tuple for distance
         * @param t
         * @return boolean
         */
        private bool isWithinRadius(Tuple t)
        {
            float dist2;
            float distT;
            distT = t.getDimensionValue(0) - centerValues[0];
            if (tHemisphere && distT < 0)
                return false;
            dist2 = distT * distT;
            if (dist2 > radius2)
                return false;
            int dim = bspt.dimMax - 1;
            do
            {
                distT = t.getDimensionValue(dim) - centerValues[dim];
                dist2 += distT * distT;
                if (dist2 > radius2)
                    return false;
            }
            while (--dim > 0);

            this._foundDistance2 = dist2;
            return true;
        }
コード例 #7
0
ファイル: Node.cs プロジェクト: carlhuth/GenXSource
        public override Element addTuple(int level, Tuple tuple)
        {
            float dimValue = tuple.getDimensionValue(dim);

            ++count;
            bool addLeft;

            if (dimValue < maxLeft)
            {
                addLeft = true;
            }
            else if (dimValue > minRight)
            {
                addLeft = false;
            }
            else if (dimValue == maxLeft)
            {
                if (dimValue == minRight)
                {
                    if (eleLeft.count < eleRight.count)
                    {
                        addLeft = true;
                    }
                    else
                    {
                        addLeft = false;
                    }
                }
                else
                {
                    addLeft = true;
                }
            }
            else if (dimValue == minRight)
            {
                addLeft = false;
            }
            else
            {
                if (eleLeft.count < eleRight.count)
                {
                    addLeft = true;
                }
                else
                {
                    addLeft = false;
                }
            }
            if (addLeft)
            {
                if (dimValue < minLeft)
                {
                    minLeft = dimValue;
                }
                else if (dimValue > maxLeft)
                {
                    maxLeft = dimValue;
                }
                eleLeft = eleLeft.addTuple(level + 1, tuple);
            }
            else
            {
                if (dimValue < minRight)
                {
                    minRight = dimValue;
                }
                else if (dimValue > maxRight)
                {
                    maxRight = dimValue;
                }
                eleRight = eleRight.addTuple(level + 1, tuple);
            }
            return(this);
        }