Ejemplo n.º 1
0
        public bool insideTriangle(Triangle tr)
        {
            // lays on bound?
            if (((dist(point, tr.I) + dist(point, tr.J) - dist(tr.I, tr.J)) < epsLay) ||
                 ((dist(point, tr.I) + dist(point, tr.K) - dist(tr.I, tr.K)) < epsLay) ||
                 ((dist(point, tr.K) + dist(point, tr.J) - dist(tr.K, tr.J)) < epsLay))
                //if (equalPoints(point, tr.I) || equalPoints(point, tr.J) || equalPoints(point, tr.K))
                return false;

            Triangle trij = new Triangle(tr.I, tr.J, point);
            Triangle trik = new Triangle(tr.I, tr.K, point);
            Triangle trkj = new Triangle(tr.K, tr.J, point);

            bool res = ((Math.Abs(tr.Square() - (trij.Square() + trik.Square() + trkj.Square()))) < eps);
            return res;
        }
        private static double FindKoefF(Point inPoint, Point i, Point j, Triangle triangle)
        {
            double deltaX = j.X - i.X;
            double deltaY = j.Y - i.Y;
            double deltaT = j.T - i.T;
            double a = 0, b = 0, c = 0;
            double length = Math.Sqrt( (i.X - j.X) * (i.X - j.X) + (i.Y - j.Y) * (i.Y - j.Y) );

            Point jToFindL, kToFindL;
            if (inPoint.Index == triangle.I.Index)
            {
                jToFindL = triangle.J;
                kToFindL = triangle.K;
            }
            else if (inPoint.Index == triangle.J.Index)
            {
                jToFindL = triangle.K;
                kToFindL = triangle.I;
            }
            else
            {
                jToFindL = triangle.I;
                kToFindL = triangle.J;
            }

            FindABC(jToFindL, kToFindL, ref a, ref b, ref c);

            double Ni = a + b * i.X + c * i.Y;
            double koeftBeforeT = b * deltaX + c * deltaY;

            double res = length / (2.0 * triangle.Square()) *
                ( Ni * i.T + (i.T * koeftBeforeT + Ni * deltaT) / 2.0 + (deltaT * koeftBeforeT / 3.0) );
            return res;
        }