Exemplo n.º 1
0
        static void Check(Plane P1, TriangleF T, ref int PtCount, xyzf A, xyzf B, ref xyzf Pt1, ref xyzf Pt2)
        {
            double Lam = -1;
            xyz    Pt  = new xyz(0, 0, 0);

            if (P1.Cross(new LineType(A.Toxyz(), (B.Toxyz() - A.Toxyz())), out Lam, out Pt))
            {
                xyz N = A.Toxyz() + (B.Toxyz() - A.Toxyz()) * Lam;

                if ((Lam >= -0.000000001) && (Lam < 1.000000001))
                {
                    if (T.Inside(Pt.toXYZF()))
                    {
                        if (PtCount == 0)
                        {
                            Pt1     = Pt.toXYZF();
                            PtCount = 1;
                        }
                        else
                        if (PtCount == 1)
                        {
                            if (Pt1.dist(Pt.toXYZF()) > 0.0001)
                            {
                                Pt2 = Pt.toXYZF();
                                PtCount++;
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        public bool Cross(List <TriangleF> Triangles, xyzArray Poly, ref double Lam, ref xyz Pt)
        {
            for (int j = 0; j < Triangles.Count; j++)
            {
                Plane P = new Plane(Triangles[j].A.Toxyz(), (Triangles[j].B - Triangles[j].A).Toxyz() & (Triangles[j].C - Triangles[j].A).Toxyz());
                for (int i = 0; i < Poly.Count - 1; i++)
                {
                    Lam = -1;
                    xyz Pkt = new xyz(0, 0, 0);

                    if (P.Cross(new LineType(Poly[i], (Poly[i + 1] - Poly[i])), out Lam, out Pkt))
                    {
                        if ((-0.000001 <= Lam) && (Lam <= 1.00000001))
                        {
                            if (Triangles[j].Inside(Pkt.toXYZF()))
                            {
                                Pt   = Pkt;
                                Lam += i;
                                return(true);
                            }
                        }
                    }
                }
            }
            return(false);
        }
Exemplo n.º 3
0
        bool Inside(LineType L, xyzf A, xyzf B, xyzf C)
        {
            TriangleF T        = new TriangleF(A, B, C);
            Plane     Triangle = new Plane(A, B, C);
            xyzf      N        = Triangle.NormalUnit.toXYZF();
            double    Depth    = -1;
            xyz       pt       = new xyz(0, 0, 0);

            Triangle.Cross(L, out Depth, out pt);
            bool tttt   = T.Inside(pt.toXYZF());
            xyzf _P     = pt.toXYZF();
            bool result = ((((A - _P) & (B - _P)) * N >= -0.00001) &&
                           (((B - _P) & (C - _P)) * N >= -0.00001) &&
                           (((C - _P) & (A - _P)) * N >= -0.00001));

            if (tttt != result)
            {
            }
            return(tttt);
        }
Exemplo n.º 4
0
        public bool Cross(LineType L, ref xyzf Pt, ref double Lam)
        {
            int   PtCount = 0;
            Plane P1      = new Plane(A, B, C);
            xyz   P       = new xyz(0, 0, 0);

            Lam = -1;
            double Mue = -1;

            if (P1.Cross(L, out Lam, out P))
            {
                xyz PP = L.Value(Lam);
                Pt = new Drawing3d.xyzf((float)P.x, (float)P.y, (float)P.z);
                if (Inside(P.toXYZF()))
                {
                    Pt = P.toXYZF();
                    return(true);
                }
            }
            return(false);
        }