示例#1
0
        public void test_triangle3d_whichside_tri()
        {
            Triangle3d t = new Triangle3d(new xyz(0, 0, 0), new xyz(5, 0, 0), new xyz(5, 5, 0));

            Assert.AreEqual(WhichSideOfPlane.Coplanar, t.Classify(t));

            Assert.AreEqual(WhichSideOfPlane.Inside, t.Classify(new Triangle3d(new xyz(0, 0, 0), new xyz(5, 0, 0), new xyz(5, 0, -2))));

            Assert.AreEqual(WhichSideOfPlane.Outside, t.Classify(new Triangle3d(new xyz(0, 0, 0), new xyz(5, 0, 0), new xyz(5, 0, 2))));

            Assert.AreEqual(WhichSideOfPlane.Split, t.Classify(new Triangle3d(new xyz(0, 0, -1), new xyz(5, 0, -1), new xyz(5, 0, 2))));
        }
示例#2
0
            public PointInPoly PointInPolyhedron(xyz p)
            {
                WhichSideOfPlane sid = tri.Classify(p);

                Debug.Assert(
                    (sid == WhichSideOfPlane.Inside) ||
                    (sid == WhichSideOfPlane.Outside) ||
                    (sid == WhichSideOfPlane.Coplanar)
                    );
                if (sid == WhichSideOfPlane.Inside)
                {
                    if (inside != null)
                    {
                        return(inside.PointInPolyhedron(p));
                    }
                    else
                    {
                        return(PointInPoly.Inside);
                    }
                }
                else if (sid == WhichSideOfPlane.Outside)
                {
                    if (outside != null)
                    {
                        return(outside.PointInPolyhedron(p));
                    }
                    else
                    {
                        return(PointInPoly.Outside);
                    }
                }
                else
                {
                    // coplanar
                    if (tri.PointInside(p))
                    {
                        return(PointInPoly.Coincident);
                    }

                    if (coincident != null)
                    {
                        foreach (Triangle3d tc in coincident)
                        {
                            if (tc.PointInside(p))
                            {
                                return(PointInPoly.Coincident);
                            }
                        }
                    }

                    if (inside != null)
                    {
                        return(inside.PointInPolyhedron(p));
                    }
                    else // if (outside != null)
                    {
                        Debug.Assert(outside != null);
                        return(outside.PointInPolyhedron(p));
                    }
示例#3
0
        public void test_triangle3d_whichside()
        {
            Triangle3d t = new Triangle3d(new xyz(0, 0, 0), new xyz(5, 0, 0), new xyz(5, 5, 0));

            Assert.AreEqual(WhichSideOfPlane.Coplanar, t.Classify(new xyz(0, 0, 0)));
            Assert.AreEqual(WhichSideOfPlane.Coplanar, t.Classify(new xyz(5, 0, 0)));
            Assert.AreEqual(WhichSideOfPlane.Coplanar, t.Classify(new xyz(5, 5, 0)));

            Assert.AreEqual(WhichSideOfPlane.Coplanar, t.Classify(new xyz(3, 0, 0)));
            Assert.AreEqual(WhichSideOfPlane.Coplanar, t.Classify(new xyz(5, 3, 0)));
            Assert.AreEqual(WhichSideOfPlane.Coplanar, t.Classify(new xyz(3, 3, 0)));

            Assert.AreEqual(WhichSideOfPlane.Coplanar, t.Classify(new xyz(4, 1, 0)));
            Assert.AreEqual(WhichSideOfPlane.Coplanar, t.Classify(new xyz(2, 1, 0)));
            Assert.AreEqual(WhichSideOfPlane.Coplanar, t.Classify(new xyz(3, 2, 0)));

            Assert.AreEqual(WhichSideOfPlane.Coplanar, t.Classify(new xyz(7, 7, 0)));
            Assert.AreEqual(WhichSideOfPlane.Coplanar, t.Classify(new xyz(5, 6, 0)));
            Assert.AreEqual(WhichSideOfPlane.Coplanar, t.Classify(new xyz(0, 9, 0)));
            Assert.AreEqual(WhichSideOfPlane.Coplanar, t.Classify(new xyz(-1, -1, 0)));

            Assert.AreEqual(WhichSideOfPlane.Outside, t.Classify(new xyz(4, 1, 1)));
            Assert.AreEqual(WhichSideOfPlane.Outside, t.Classify(new xyz(0, 0, 1)));
            Assert.AreEqual(WhichSideOfPlane.Outside, t.Classify(new xyz(9, 9, 1)));

            Assert.AreEqual(WhichSideOfPlane.Inside, t.Classify(new xyz(3, 1, -1)));
        }