public void TestAllCoordinatesSame()
        {
            KdNode <IVector> n = new KdNode <IVector>();

            n.Vectors        = new List <IVector>(new IVector[] { Vector.Create(1.0f, 0.0f), Vector.Create(1.0f, 0.0f), Vector.Create(1.0f, 0.0f), Vector.Create(1.0f, 0.0f) });
            n.InternalBounds = new AABB(2);
            n.InternalBounds.Enlarge <IVector>(n.Vectors);
            PeriodicAxisSelector s = new PeriodicAxisSelector();

            s.Select(n);
        }
Beispiel #2
0
 public void TestTrivialSplitsForEndlessRecursion() {
   // Test when split bounds is non-empty, but all contained points are degenerate
   KdNode<IVector> n = new KdNode<IVector>();
   n.Vectors = new List<IVector>(new IVector[] { Vector.Create(-1, -5), Vector.Create(-1, -5) });
   n.InternalBounds = new AABB(Vector.Create(-1.25, -5), Vector.Create(-1, -5));
   n.InternalBounds = new AABB(2);
   n.InternalBounds.Enlarge<IVector>(n.Vectors);
   AxisOfMaximumSpreadSelector aom = new AxisOfMaximumSpreadSelector();
   PeriodicAxisSelector pas = new PeriodicAxisSelector();
   NUnitExtensions.Assert.Throws(typeof(DegenerateDatasetException), delegate { aom.Select(n); });
   NUnitExtensions.Assert.Throws(typeof(DegenerateDatasetException), delegate { pas.Select(n); });
 }
        public void TestRoot()
        {
            KdNode <IVector> n = new KdNode <IVector>();

            n.Vectors        = new List <IVector>(new IVector[] { Vector.Create(1.0f, 0.5), Vector.Create(1.0f, 0.0), Vector.Create(1.0f, 0.0), Vector.Create(1.0f, 0.0) });
            n.InternalBounds = new AABB(2);
            n.InternalBounds.Enlarge <IVector>(n.Vectors);
            PeriodicAxisSelector s = new PeriodicAxisSelector();

            Assert.AreEqual(1, s.Select(n));

            n.Vectors[0][0] = 0.5;
            n.InternalBounds.Reset();
            n.InternalBounds.Enlarge <IVector>(n.Vectors);
            Assert.AreEqual(0, s.Select(n));
        }
        public void TestNonRoot()
        {
            KdNode <IVector> root   = new KdNode <IVector>();
            KdNode <IVector> first  = root.SetLeftChild(new KdNode <IVector>());
            KdNode <IVector> second = first.SetLeftChild(new KdNode <IVector>());
            KdNode <IVector> third  = second.SetLeftChild(new KdNode <IVector>());

            third.Vectors        = new List <IVector>(new IVector[] { Vector.Create(0.0, 0.5), Vector.Create(1.0f, 0.0), Vector.Create(1.0f, 0.0), Vector.Create(1.0f, 0.0) });
            third.InternalBounds = new AABB(2);
            third.InternalBounds.Enlarge <IVector>(third.Vectors);
            third.InternalBounds = new AABB(third.InternalBounds);
            PeriodicAxisSelector s = new PeriodicAxisSelector();

            Assert.AreEqual(1, s.Select(third));

            second.Vectors        = third.Vectors;
            second.InternalBounds = third.InternalBounds;
            second.InternalBounds = new AABB(third.InternalBounds);
            Assert.AreEqual(0, s.Select(second));
        }