University stuff.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

Oblig4.java 1006B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. abstract class Oblig4 {
  2. // Required for TegnUt
  3. int x[];
  4. int y[];
  5. int n;
  6. int MAX_Y;
  7. int MAX_X;
  8. int minX;
  9. int maxX;
  10. int minY;
  11. int maxY;
  12. IntList coHull;
  13. NPunkter17 points;
  14. String name = "Oblig4";
  15. Oblig4(NPunkter17 points) {
  16. this.points = points;
  17. n = points.n;
  18. x = new int[n];
  19. y = new int[n];
  20. coHull = new IntList();
  21. points.fyllArrayer(x, y);
  22. }
  23. abstract void solve();
  24. void draw() {
  25. TegnUt t = new TegnUt(this, coHull, name);
  26. t.setVisible(true);
  27. }
  28. int lineA(int p1, int p2) {
  29. return y[p1] - y[p2];
  30. }
  31. int lineB(int p1, int p2) {
  32. return x[p2] - x[p1];
  33. }
  34. int lineC(int p1, int p2) {
  35. return (y[p2] * x[p1]) - (y[p1] * x[p2]);
  36. }
  37. // From p1 to p2.
  38. // == 0: p3 is on the line.
  39. // > 0: p3 is left of the line.
  40. // < 0: p3 is right of the line.
  41. double lineEquation(int a, int b, int c, int p3) {
  42. return (a * x[p3]) + (b * y[p3]) + c;
  43. }
  44. // Distance between the line and p3
  45. double dist(double l, int a, int b) {
  46. return l / Math.sqrt((a * a) + (b * b));
  47. }
  48. }