예제 #1
0
        public void SphereIntersectionsNoIntersection()
        {
            Ellipsoid unitSphere = Ellipsoid.UnitSphere;

            double[] intersections;

            intersections = unitSphere.Intersections(new Vector3D(2.0, 0.0, 0.0), new Vector3D(0.0, 0.0, 1.0));
            Assert.AreEqual(0, intersections.Length);

            intersections = unitSphere.Intersections(new Vector3D(2.0, 0.0, 0.0), new Vector3D(0.0, 0.0, -1.0));
            Assert.AreEqual(0, intersections.Length);

            intersections = unitSphere.Intersections(new Vector3D(2.0, 0.0, 0.0), new Vector3D(0.0, 1.0, 0.0));
            Assert.AreEqual(0, intersections.Length);

            intersections = unitSphere.Intersections(new Vector3D(2.0, 0.0, 0.0), new Vector3D(0.0, -1.0, 0.0));
            Assert.AreEqual(0, intersections.Length);
        }
예제 #2
0
        public void SphereIntersectionsTwoFromInside()
        {
            Ellipsoid unitSphere = Ellipsoid.UnitSphere;

            double[] intersections;

            intersections = unitSphere.Intersections(new Vector3D(0.0, 0.0, 0.0), new Vector3D(0.0, 0.0, 1.0));
            Assert.AreEqual(2, intersections.Length);
            Assert.AreEqual(-1.0, intersections[0], 1e-14);
            Assert.AreEqual(1.0, intersections[1], 1e-14);

            intersections = unitSphere.Intersections(new Vector3D(0.0, 0.5, 0.0), new Vector3D(0.0, 1.0, 0.0));
            Assert.AreEqual(2, intersections.Length);
            Assert.AreEqual(-1.5, intersections[0], 1e-14);
            Assert.AreEqual(0.5, intersections[1], 1e-14);

            intersections = unitSphere.Intersections(new Vector3D(0.0, 0.5, 0.0), new Vector3D(0.0, -1.0, 0.0));
            Assert.AreEqual(2, intersections.Length);
            Assert.AreEqual(-0.5, intersections[0], 1e-14);
            Assert.AreEqual(1.5, intersections[1], 1e-14);
        }