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); }
private static void Exercitiul3() { point a = new point(); point b = new point(); /*a.x = 1;a.y = 3; * b.x = 4;b.y = 5;*/ a.init(); b.init(); Console.WriteLine(a.tostring("a")); Console.WriteLine(b.tostring("b")); int qX = sumMatrix(a.y, 1, b.y, 1); int qY = sumMatrix(b.x, 1, a.x, 1); int qR = sumMatrix(a.x, a.y, b.x, b.y); Console.WriteLine("d: {0}*x+{1}*y+{2}=0", qX, qY, qR); }