Example #1
0
        public void SphereAABBTest()
        {
            Point3d  p  = new Point3d(0, 0, 0);
            Sphere   e  = new Sphere(p, 5);
            Rotation r  = new Rotation(new Vector3d(1, 2, 3), PI / 4);
            Coord3d  cs = new Coord3d(new Point3d(1, 2, 4), r.ToRotationMatrix.Transpose());

            Box3d b = e.BoundingBox(cs);

            Plane3d s = new Plane3d(b.P1, b.P2, b.P3);

            Assert.IsTrue(e.IntersectionWith(s).GetType() == typeof(Point3d));

            s = new Plane3d(b.P8, b.P7, b.P6);
            Assert.IsTrue(e.IntersectionWith(s).GetType() == typeof(Point3d));

            s = new Plane3d(b.P1, b.P2, b.P5);
            Assert.IsTrue(e.IntersectionWith(s).GetType() == typeof(Point3d));

            s = new Plane3d(b.P2, b.P3, b.P6);
            Assert.IsTrue(e.IntersectionWith(s).GetType() == typeof(Point3d));

            s = new Plane3d(b.P3, b.P4, b.P7);
            Assert.IsTrue(e.IntersectionWith(s).GetType() == typeof(Point3d));

            s = new Plane3d(b.P1, b.P4, b.P8);
            Assert.IsTrue(e.IntersectionWith(s).GetType() == typeof(Point3d));
        }