Guest User

Untitled

a guest
Apr 22nd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. public static PointRC get_FieldRC2(int x, int y)
  2. {
  3. boolean minus;
  4. int cntrow;
  5. int cntcol;
  6. int steps = 0;
  7. int qx = Math.abs(x);
  8. int qy = (y/16) * 16;
  9. int modx = qx % 32;
  10.  
  11. minus = x < 0 ? true : false;
  12.  
  13. if(modx >= 16)
  14. qx += 32-modx;
  15. else
  16. qx -= modx;
  17.  
  18. qy = 16 + (y / 32) * 32;
  19.  
  20. if(minus)
  21. qx = -qx;
  22.  
  23. if(qx != 0){
  24. if(minus){
  25. steps = qx / -32;
  26. qx += 32 * steps;
  27. qy += 16 * steps;
  28.  
  29. }else{
  30. steps = qx / 32;
  31. qx -= 32 * steps;
  32. qy -= 16 * steps;
  33. }
  34. }
  35. cntrow = qy/32;
  36.  
  37. if(minus)
  38. cntcol = cntrow - steps;
  39. else
  40. cntcol = cntrow + steps;
  41.  
  42. return new PointRC(cntrow,cntcol);
  43. }
Add Comment
Please, Sign In to add comment