I am trying to convert the equation below into programming code. The goal is to find the intersecting point of the two lines. And to pront
(y1 - y2) x - (x1 - x2) y = (y1 - y2) x1 - (x1 - x2) y1
(y3 - y4) x - (x3 - x4) y = (y3 - y4) x3 - (x3 - x4) y3
I was told to use the cramers rule, but the cramers rule has 6 diff variables. I will start from 4 different points in the form of 8 variables (x1, y1, x2, y2, x3, y3, x4, y4)
I am using Java. Any help would be greatly appreciated. All the questions asked on this site are for different types of linear equations with a long complex code, I did not find anything that would matter to me.
This is what I have, not so much, but the transition from the above equation to something programmable really brings me down.
import java.util.Scanner; public class E325 { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter x1 y1, x2 y2, x3 y3, x4 y4: "); double x1 = input.nextDouble(); double y1 = input.nextDouble(); double x2 = input.nextDouble(); double y2 = input.nextDouble(); double x3 = input.nextDouble(); double y3 = input.nextDouble(); double x4 = input.nextDouble(); double y4 = input.nextDouble(); } }
source share