Exemple #1
0
        public void AABBTreeRayIntersection_FindIntersection()
        {

            Vector3 projVect = new Vector3(0, 0, -1);
            var mesh = MakeMesh();
            var aabbTree = MakeAABBTree(mesh);
            double tolerance = 1E-10;

            Point3[] inputPoints =
            {
                new Point3(0,1,0.5), //the vertex of the mesh           
                0.5 * new Point3(0, 1, 0.5) + 0.5 * new Point3(0, 0, 1), //point on mesh edge
                new Point3(0.4, 0.4, 0.4),  //point inside mesh 
                new Point3(1, 0, 2.5), //point above the vertex of the mesh  
                //new Point3(1, 0.6, 0.6),  //point outside mesh
            };
            Point3[] expectedPoints = new Point3[]
            {
                new Point3(0, 1, 0.5),
                new Point3(0, 0.5, 0.25),
                new Point3(0.4, 0.4, 0.2),
                new Point3(1, 0, 0),
            };
            Point3[] outputPoints = new Point3[4];



            for (int i = 0; i < inputPoints.Count(); i++)
            {
                Intersection intersection = ShellSecAlgorithms.RayAABBTreeIntersections(inputPoints[i], projVect, aabbTree);
                var pt = intersection.Values.ToList()[0];

                Assert.That(pt.Equals(expectedPoints[i], tolerance));
            }
        }
Exemple #2
0
        public void AABBTreeRayIntersection_FindIntersection_NoValidIntersection()
        {
            Vector3 projVect = new Vector3(0, 0, -1);
            var mesh = MakeMesh();
            var aabbTree = MakeAABBTree(mesh);
            var inputPoints = new Point3(1, 0.6, 0.6);  //point outside mesh

            Intersection intersection = ShellSecAlgorithms.RayAABBTreeIntersections(inputPoints, projVect, aabbTree);

            Assert.That(intersection is null);
        }