예제 #1
0
        public void CanGetDistanceToVerticalPlane3D()
        {
            List <Pnt3D> points = GetVerticalTrianglePoints();

            Plane3D plane = Plane3D.FitPlane(points);

            Console.WriteLine(@"A: " + plane.A);
            Console.WriteLine(@"B: " + plane.B);
            Console.WriteLine(@"C: " + plane.C);
            Console.WriteLine(@"D: " + plane.D);

            Assert.AreEqual(0, plane.C, plane.Epsilon);             // vertical
            Assert.AreEqual(1, plane.GetUnitNormal().LengthSquared);

            Assert.AreEqual(0.89606641473951276, plane.GetUnitNormal().X, plane.Epsilon);
            Assert.AreEqual(0.44392001574143475, plane.GetUnitNormal().Y, plane.Epsilon);

            foreach (Pnt3D point in points)
            {
                double distance = plane.GetDistanceAbs(point.X, point.Y, point.Z);
                Console.WriteLine(@"{0}: {1}", point, distance);
                Assert.AreEqual(0, distance, plane.Epsilon);
            }

            Assert.Catch <InvalidOperationException>(() => plane.GetZ(100, 100));
        }
예제 #2
0
        public void CanGetDistanceToNearlyVerticalPlane3D()
        {
            List <Pnt3D> points = GetVerticalTrianglePoints();

            points[0].Y += 0.01;
            Plane3D plane = Plane3D.FitPlane(points);

            foreach (Pnt3D point in points)
            {
                double distance = plane.GetDistanceAbs(point.X, point.Y, point.Z);
                Console.WriteLine(@"{0}: {1}", point, distance);
                Assert.AreEqual(0, distance, plane.Epsilon);
            }

            double definedZ = plane.GetZ(100, 100);

            Assert.AreEqual(0, plane.GetDistanceAbs(100, 100, definedZ), plane.Epsilon);
        }
예제 #3
0
        public void CanFitHorizontalPlane3D()
        {
            var x = new double[] { 0, 0, 0, 1, 1, 1, 2, 2, 2 };
            var y = new double[] { 1, 2, 3, 1, 2, 3, 1, 2, 3 };
            var z = new double[] { 1, 1, 1, 1, 1, 1, 1, 1, 1 };

            Plane3D plane = FitPlane3D(x, y, z);

            Assert.AreEqual(1, plane.GetZ(-1000, -1000));
            Assert.AreEqual(1, plane.GetZ(1000, 1000));
            Assert.AreEqual(1, plane.GetDistanceAbs(1000, 1000, 0));
            Assert.AreEqual(1, plane.GetUnitNormal().LengthSquared);
        }
 private static AoIntersectionPoint GetIntersectionPoint(
     [NotNull] Plane3D plane, [NotNull] IPoint pt) =>
 new AoIntersectionPoint(pt, plane.GetZ(pt.X, pt.Y),
                         plane.GetDistanceAbs(pt.X, pt.Y, pt.Z));