Ejemplo n.º 1
0
        IEnumerable <T> GetItemsAt_R(int ord, double off, double maxDist)
        {
            var itosearch = new DiscreteSpaceItem <T>(Vector3D.Axis(ord) * off);

            // bin search return 0,(n-1) if found or negative number so that ~result is the index of
            // the first element greather thant those we search for
            var bsr = sorted[ord].BinarySearch(itosearch, cmp[ord]);

            int idx = 0;

            if (bsr < 0)
            {
                idx = ~bsr;
            }
            else
            {
                idx = bsr;
            }

            DiscreteSpaceItem <T> dsi = null;

            // right search
            for (int i = idx; i < sorted[ord].Count && Abs((dsi = sorted[ord][i]).Mean.GetOrd(ord) - off) <= maxDist; ++i)
            {
                yield return(dsi.Item);
            }

            // left search
            for (int i = idx - 1; i >= 0 && Abs((dsi = sorted[ord][i]).Mean.GetOrd(ord) - off) <= maxDist; --i)
            {
                yield return(dsi.Item);
            }
        }
Ejemplo n.º 2
0
        public void Vector3DTest_0004()
        {
            var tol = 1e-3;

            var xaxis = Vector3D.XAxis;
            var yaxis = Vector3D.YAxis;
            var zaxis = Vector3D.ZAxis;

            Assert.True(xaxis.EqualsTol(tol, Vector3D.Axis(0)));
            Assert.True(yaxis.EqualsTol(tol, Vector3D.Axis(1)));
            Assert.True(zaxis.EqualsTol(tol, Vector3D.Axis(2)));
            Assert.Throws <ArgumentException>(new Action(() => Vector3D.Axis(3)));
        }
Ejemplo n.º 3
0
        public void AxisTest()
        {
            var xaxis = Vector3D.Axis(0);

            Assert.True(xaxis.EqualsTol(1e-6, Vector3D.XAxis));

            var yaxis = Vector3D.Axis(1);

            Assert.True(yaxis.EqualsTol(1e-6, Vector3D.YAxis));

            var zaxis = Vector3D.Axis(2);

            Assert.True(zaxis.EqualsTol(1e-6, Vector3D.ZAxis));
        }
Ejemplo n.º 4
0
        public void AxisTest()
        {
            var xaxis = Vector3D.Axis(0);

            Assert.True(xaxis.EqualsTol(1e-6, Vector3D.XAxis));

            var yaxis = Vector3D.Axis(1);

            Assert.True(yaxis.EqualsTol(1e-6, Vector3D.YAxis));

            var zaxis = Vector3D.Axis(2);

            Assert.True(zaxis.EqualsTol(1e-6, Vector3D.ZAxis));

            Assert.Throws <ArgumentException>(new Action(() => Vector3D.Axis(3)));
        }