Exemplo n.º 1
0
        static public void Run()
        {
            //var tri = new Tri(planes);
            var tri = new FullTri(0, 0, 1, 0, 0, 1);

            Debug.Assert(tri.TestPoint(new Point2(.1, .1)));
            Debug.Assert(!tri.TestPoint(new Point2(-.1, .1)));
            Debug.Assert(!tri.TestPoint(new Point2(.1, -.1)));
            Debug.Assert(!tri.TestPoint(new Point2(1, 1)));

            double a = AreaMeasure.Calc(tri);

            Debug.Assert(Math.Abs(a - .5) < .01);

            tri = new FullTri(0, 0, 10, 0, 0, 20);
            Debug.Assert(tri.TestPoint(new Point2(2, 2)));
            a = AreaMeasure.Calc(tri);
            Debug.Assert(Math.Abs(a - 100) < 1);

            tri = new FullTri(0 - 1, 0 + 2, 1 - 1, 0 + 2, 0 - 1, 1 + 2);
            a   = AreaMeasure.Calc(tri);
            Debug.Assert(Math.Abs(a - .5) < .01);

            tri = new FullTri(-3, -2, 6, -7, -2, 5);
            a   = AreaMeasure.Calc(tri);
            Debug.Assert(Math.Abs(a - 34) < .1);
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Tests.Run();

            var tri = new FullTri(0, 0, 1, 0, 0, 1);

            ThreedianCalc(tri);

            tri = new FullTri(-3, -2, 6, -7, -2, 5);
            ThreedianCalc(tri);
        }
Exemplo n.º 3
0
        static void ThreedianCalc(FullTri tri)
        {
            double a = AreaMeasure.Calc(tri);

            var threed = tri.CreateThreedian();

            var    del = tri.PtMax - tri.PtMin;
            double ta  = AreaMeasure.Calc(threed, del.x, del.y, tri.PtMin.x, tri.PtMin.y);

            var ratio = ta / a;

            Console.WriteLine(string.Format("Full Area: {0} Threed Area: {1} Ratio: {2}", a, ta, ratio));
        }
Exemplo n.º 4
0
        static public double Calc(FullTri tri, double dx = 1, double dy = 1, double xs = 0, double ys = 0)
        {
            var del = tri.PtMax - tri.PtMin;

            return(Calc((Tri)tri, del.x, del.y, tri.PtMin.x, tri.PtMin.y));
        }