예제 #1
0
        public void HashOfHull3d_FromBox_NotEquals_FromDifferentBox()
        {
            var a = Hull3d.Create(new Box3d(new V3d(1, 2, 3), new V3d(2, 3, 4.1)));
            var b = Hull3d.Create(new Box3d(new V3d(1, 2, 3), new V3d(2, 3, 4.2)));

            Assert.IsTrue(a.ComputeMd5Hash() != b.ComputeMd5Hash());
        }
예제 #2
0
        public void HashOfHull3d_FromBox_Equals_FromSameBox()
        {
            var a = Hull3d.Create(new Box3d(new V3d(1, 2, 3), new V3d(2, 3, 4.1)));
            var b = Hull3d.Create(new Box3d(new V3d(1, 2, 3), new V3d(2, 3, 4.1)));

            Assert.IsTrue(a.ComputeMd5Hash() == b.ComputeMd5Hash());
        }
예제 #3
0
        public void ForEachNodeIntersecting_Works()
        {
            var storage    = PointCloud.CreateInMemoryStore();
            var pointcloud = CreateClusteredPointsInUnitCube(1000, 10);
            var ns         = pointcloud.Root.Value.ForEachNodeIntersecting(Hull3d.Create(Box3d.Unit), true).ToArray();

            Assert.IsTrue(ns.Length > 0);
        }
예제 #4
0
        public void TestConvexClipped()
        {
            var points      = new[] { V3d.OOO, V3d.IOO, V3d.OIO };
            var poly        = new Polygon3d(points);
            var box         = Box3d.FromMinAndSize(-V3d.OOI, new V3d(1, 0.5, 2));
            var newHull     = Hull3d.Create(box).Reversed(); // requires non-intuitive reversed (or using obsolte Hull3d constructor that points inside)
            var polyClipped = poly.ConvexClipped(newHull);   // will return positive part of planes (outside of Hull3d)
            var clippedBox  = polyClipped.BoundingBox3d;
            var test        = new Box3d(0, 0, 0, 1, 0.5, 0);

            Test.IsTrue(clippedBox == test);
        }
        public static Box3d IntersectionBounds(this Hull3d hull, Box3d box)
        {
            if (box.IsInvalid)
            {
                return(box);
            }

            var bh = Hull3d.Create(box);
            var pp = new Plane3d[6 + hull.PlaneCount];

            bh.PlaneArray.CopyTo(pp, 0);
            hull.PlaneArray.CopyTo(pp, 6);
            var h = new Hull3d(pp);

            return(new Box3d(h.ComputeCorners()));
        }