abstract class Oblig4 { // Required for TegnUt int x[]; int y[]; int n; int MAX_Y; int MAX_X; int minX; int maxX; int minY; int maxY; IntList coHull; NPunkter17 points; String name = "Oblig4"; Oblig4(NPunkter17 points) { this.points = points; n = points.n; x = new int[n]; y = new int[n]; coHull = new IntList(); points.fyllArrayer(x, y); } abstract void solve(); void draw() { TegnUt t = new TegnUt(this, coHull, name); t.setVisible(true); } int lineA(int p1, int p2) { return y[p1] - y[p2]; } int lineB(int p1, int p2) { return x[p2] - x[p1]; } int lineC(int p1, int p2) { return (y[p2] * x[p1]) - (y[p1] * x[p2]); } // From p1 to p2. // == 0: p3 is on the line. // > 0: p3 is left of the line. // < 0: p3 is right of the line. double lineEquation(int a, int b, int c, int p3) { return (a * x[p3]) + (b * y[p3]) + c; } // Distance between two points double pointDist(int p1, int p2) { int x1 = x[p1], y1 = y[p1]; int x2 = x[p2], y2 = y[p2]; int dx = x2 - x1; int dy = y2 - y1; return Math.abs(Math.sqrt((dx * dx) + (dy * dy))); } // Distance between the line and p3 double dist(double l, int a, int b) { return l / Math.sqrt((a * a) + (b * b)); } }