cours_progra/q2/tp1/Droites.java
Debucquoy 5456020f7c
tp2
2023-03-09 11:38:23 +01:00

21 lines
537 B
Java

public class Droites {
public static void main(String[] args) {
droite(1, 1, 2, 2);
if(appartient(-1,1, 0, 2, 2)){
System.out.println("yay");
}
}
public static void droite(double x1, double y1, double x2, double y2){
double dir_x = x2 - x1, dir_y = y2 - y1;
double a = -dir_y, b = dir_x;
double c = a*x1 + b*y1;
System.out.println("equation de la droite: " + a + "x + " + b + "y = " + c);
}
public static boolean appartient(double a, double b, double c, double x, double y){
return a * x + b * y == c ;
}
}