I am trying to convert the equation below into programming code. The purpose 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've been told to use cramers rule, but cramers rule has 6 diff variables. I'll be starting off with 4 different points as 8 variables (x1, y1, x2, y2, x3, y3, x4, y4)
I'm using Java. Any help would be appreciated. All the asked questions on this site are for different types of linear equations with long complicated code, I didnt find anything that was relevant to me.
This is what I have, not much but the transition from the above equation to something programmable really stumps me.
import java.util.Scanner;
public class E325 {
public static void main(String[] args) {
/*
* The purpose of this program is to find the intersect
* of two lines given by the user by four points
*
* Get the four points. x1,y1 x2,y2 x3,y3 x4,y4
*/
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();
}
}