Advertisement
Guest User

Untitled

a guest
Aug 24th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. public static int nizovi(double[]a , double[]b , double alfa)
  2. {
  3. int BrStr = 0;
  4. for (int i = 0; i < b.length; i++)
  5. {
  6. double P12,P13, P23;
  7. P12 = duzina(a[i+1], b[i+1], a[i], b[i]);
  8. P13 = duzina(a[i+1], b[i+1], a[i+2], b[i+2]); // pisemo prvo i+1 jer je to vertex tacka, ona koja je u centru ugla, zato nije od i
  9. P23 = duzina(a[i], b[i], a[i+2], b[i+2]);
  10.  
  11. double x = ugao(P12, P13, P23);
  12. if(x > alfa)
  13. {
  14. System.out.print( "Stranica : " + "( " + a[i] + "," + b[i] + " )" + "( " + a[i+1] + "," + b[i+1] + " )" + " & ");
  15. System.out.println("( " + a[i+1] + "," + b[i+1] + " )" + "( " + a[i+2] + "," + b[i+2] + " )");
  16. System.out.println();
  17. BrStr++;
  18. }
  19.  
  20.  
  21. }
  22. return BrStr;
  23.  
  24. }
  25.  
  26.  
  27. public static double ugao (double P12, double P13, double P23)
  28. {
  29. return Math.acos((Math.pow(P12, 2) + Math.pow(P13, 2) - Math.pow(P23, 2))/(2 * P12 * P13));
  30. }
  31.  
  32.  
  33. public static double duzina (double vertexX1, double vertexY1, double x2, double y2)
  34. {
  35. return Math.sqrt(Math.pow((vertexX1-x2),2)+ Math.pow((vertexY1-y2), 2));
  36. }
  37. public static void main(String[] args) {
  38. // TODO Auto-generated method stub
  39.  
  40. double a[] = {12,25,3};
  41. double b[] = {11,20,5};
  42.  
  43. nizovi(a, b, 45);
  44.  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement