Advertisement
Guest User

Untitled

a guest
Jun 15th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.64 KB | None | 0 0
  1. public int n;
  2. private String str;
  3. public float a1[],a2[],b1[],b2[],x11,x22,y11,y22,L[], K[][][],cos[],sin[];
  4. public float u,v;
  5.  
  6. @Override
  7. protected void onCreate(Bundle savedInstanceState) {
  8. super.onCreate(savedInstanceState);
  9. setContentView(R.layout.activity_main);
  10.  
  11. final TextView cikti= (TextView) findViewById(R.id.eno);
  12. final TextView boy= (TextView) findViewById(R.id.L);
  13. final EditText m = (EditText) findViewById(R.id.n);
  14. final EditText x1 = (EditText) findViewById(R.id.x1);
  15. final EditText x2 = (EditText) findViewById(R.id.x2);
  16. final EditText y1 = (EditText) findViewById(R.id.y1);
  17. final EditText y2 = (EditText) findViewById(R.id.y2);
  18. final Button kayit = (Button) findViewById(R.id.kaydet);
  19.  
  20. kayit.setOnClickListener (new View.OnClickListener() {
  21. @Override
  22. public void onClick(View view) {
  23. n=Integer.parseInt(m.getText().toString());
  24. x11= Float.parseFloat(x1.getText().toString());
  25. x22= Float.parseFloat(x2.getText().toString());
  26. y11= Float.parseFloat(y1.getText().toString());
  27. y22= Float.parseFloat(y2.getText().toString());
  28.  
  29. a1 = new float[n];
  30. a2 = new float[n];
  31. b1 = new float[n];
  32. b2 = new float[n];
  33. L = new float[n];
  34. cos = new float[n];
  35. sin = new float[n];
  36. K = new float[n][4][4];
  37. str="";
  38.  
  39.  
  40. //a1[0]=x11;
  41. //cikti.setText(String.valueOf(a1[0]));
  42. for (int i=0; i<n; i++){
  43. // boy.setText(String.valueOf(L[0])+"-"+String.valueOf(cos[0])+"-"+String.valueOf(sin[0]));
  44.  
  45.  
  46. a1[i]=x11;
  47. a2[i]=x22;
  48. b1[i]=y11;
  49. b2[i]=y22;
  50. float xx = a2[i]-a1[i];
  51. float yy = b2[i]-b1[i];
  52. L[i]= Float.parseFloat(String.valueOf(Math.hypot(xx,yy)));
  53. cos[i]= xx/L[i];
  54. sin[i]= yy/L[i];
  55.  
  56.  
  57. K[i][0][0]= cos[i]*cos[i]; K[i][0][1]= cos[i]*sin[i]; K[i][0][2]= -cos[i]*cos[i]; K[i][0][3]= -cos[i]*sin[i];
  58. K[i][1][0]= cos[i]*sin[i]; K[i][1][1]= sin[i]*sin[i]; K[i][1][2]= -cos[i]*sin[i]; K[i][1][3]= -sin[i]*sin[i];
  59. K[i][2][0]= -cos[i]*cos[i]; K[i][2][1]= -cos[i]*sin[i]; K[i][2][2]= cos[i]*cos[i]; K[i][2][3]= cos[i]*sin[i];
  60. K[i][3][0]= -cos[i]*sin[i]; K[i][3][1]= -sin[i]*sin[i]; K[i][3][2]= cos[i]*sin[i]; K[i][3][3]= sin[i]*sin[i];
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67. cikti.setText(String.valueOf(a1[0])+"-"+String.valueOf(a2[0])+"-"+String.valueOf(b1[0])+"-"
  68. +String.valueOf(b2[0])+"-"+String.valueOf(n)+"-");
  69. for(int x=0;x<4;x++){
  70. for(int y=0;y<4;y++){
  71. str+=(String.valueOf(K[i][x][y])+" ");
  72. boy.setText(str);
  73. }
  74. str+="n";
  75.  
  76. }
  77.  
  78. }
  79.  
  80.  
  81. }
  82. });
  83.  
  84.  
  85. }
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95. @Override
  96. public boolean onCreateOptionsMenu(Menu menu) {
  97. // Inflate the menu; this adds items to the action bar if it is present.
  98. getMenuInflater().inflate(R.menu.menu_main, menu);
  99. return true;
  100. }
  101.  
  102. @Override
  103. public boolean onOptionsItemSelected(MenuItem item) {
  104. // Handle action bar item clicks here. The action bar will
  105. // automatically handle clicks on the Home/Up button, so long
  106. // as you specify a parent activity in AndroidManifest.xml.
  107. int id = item.getItemId();
  108.  
  109. //noinspection SimplifiableIfStatement
  110. if (id == R.id.action_settings) {
  111. return true;
  112. }
  113.  
  114. return super.onOptionsItemSelected(item);
  115. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement