static void Main(string[] args) { int[] array = new int[3]; int[] array1 = new int[3]; Console.WriteLine("Введiть 3 точки через пробiл для 1 рiвняння"); array = Array.ConvertAll(Console.ReadLine().Trim().Split(), int.Parse); Console.WriteLine("Введiть 3 точки через пробiл для 2 рiвняння"); array1 = Array.ConvertAll(Console.ReadLine().Trim().Split(), int.Parse); EquationOfTheLine equ1 = new EquationOfTheLine(array); EquationOfTheLine equ2 = new EquationOfTheLine(array1); Console.WriteLine($"Equation1 = {equ1}"); Console.WriteLine($"Equation2 = {equ2}"); Console.WriteLine($"Точка перетину {equ1.CrossingPoint(equ2)}"); Console.WriteLine("Введiть 2 числа через пробiл для перевiрки, чи належить точка з такими координатами прямiй"); double[] point_array = new double[2]; point_array = Array.ConvertAll(Console.ReadLine().Trim().Split(), double.Parse); Point point = new Point(point_array[0], point_array[1]); //Random rand = new Random(); //Point point = new Point(rand.Next(-10, 10), rand.Next(-10, 10)); Console.WriteLine($"Point {point}"); Console.WriteLine(equ1.IsPointBelongLine(point) ? $"Точка належить прямiй {equ1}" : $"Точка не належить прямiй {equ1}"); Console.ReadKey(); }
public Point CrossingPoint(EquationOfTheLine equationOfTheLine) { double pCrossX = 0; double pCrossY = 0; double det = this.ABC[0] * equationOfTheLine[1] - this.ABC[1] * equationOfTheLine[0]; pCrossX = (this.ABC[1] * equationOfTheLine[2] - equationOfTheLine[1] * this.ABC[2]) / det; //x:=(b1*c2-b2*c1)/(a1*b2-b1*a2); pCrossY = (equationOfTheLine[0] * this.ABC[2] - this.ABC[0] * equationOfTheLine[2]) / det; // y:=(a2*c1-a1*c2)/(a1*b2-b1*a2); return(new Point(pCrossX, pCrossY)); }