package com.sanjiao;
import java.awt.Point;
public class sanjiao {
public static void main(String[] args) {
Point l1 = new Point(2, 2);
Point l2 = new Point(4, 5);
Point l3 = new Point(0, 0);
LineClass lineclass = new LineClass(l1, l2);
int aa = lineclass.panduan(l3);
System.out.println(aa);
}
}
class Testsanjiao {
LineClass l1 = null;
LineClass l2 = null;
LineClass l3 = null;
}
class LineClass {
double a;
double b;
public LineClass(Point p1, Point p2) {
super();
// TODO Auto-generated constructor stub
a = (p1.y - p2.y) / (p1.x - p2.x);
b = (p2.y * p1.x - p1.y * p2.x) / (p1.x - p2.x);
}
// 直线 上侧返回1 直线上返回0 直线下侧返回-1
public int panduan(Point p) {
int ret = 0;
double y = p.x * a + b;
if (p.y > y) {
ret = 1;
} else if (p.y < y) {
ret = -1;
}
return ret;
}
}