예제 #1
0
        private static void Exercitiul4()
        {
            //a.x = 1;a.y = 3;
            point dp1 = new point();
            point dp2 = new point();

            dp1.init();
            dp2.init();

            point m = new point();

            m.init();
            while (dp2.isEqual(m))
            {
                m.init();
            }

            Console.WriteLine(dp1.tostring("dp1"));
            Console.WriteLine(dp2.tostring("dp2"));
            Console.WriteLine(m.tostring("m"));

            int a = sumMatrix(dp1.y, 1, dp2.y, 1);
            int b = sumMatrix(dp2.x, 1, dp1.x, 1);
            int c = sumMatrix(dp1.x, dp1.y, dp2.x, dp2.y);

            float dist = (float)(Math.Abs(a * m.x + b * m.y + c) / Math.Sqrt(a * a + c * c));

            Console.WriteLine("dist(M, d)={0}", dist);
        }