Guest User

Untitled

a guest
Jan 14th, 2020
83
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Random;
  2.  
  3.  
  4. public class Lab1
  5. {
  6. public static void main(String[] args) {
  7. double x = 0;
  8. double y = 0;
  9. double u;
  10. double v;
  11. int xDisp;
  12. int yDisp;
  13. int height = 449;
  14. int width = 519;
  15. int scale = -500;
  16. int xOffset = 439;
  17. int yOffset = 509;
  18. double randomF;
  19. int[][] myArray = new int[width][height];
  20. double[][] mOne = { { 0.5, 0, 0, 0.5, 0, 0, 0.33 }, { 0.5, 0, 0, 0.5, 0, 0.5, 0.33 },
  21. { 0.5, 0, 0, 0.5, 0.43, 0.25, 0.34 } };
  22.  
  23.  
  24. for (int i = 0; i < (width*height); i++) {
  25. randomF= Math.random();
  26. if(randomF < 0.33)
  27. {
  28. u = (mOne[0][0] * x) + (mOne[0][1] * y) + (mOne[0][4]);
  29. v = (mOne[0][2] * x) + (mOne[0][3] * y) + (mOne[0][5]);
  30. x=u;
  31. y=v;
  32. xDisp = (int) ((x * scale) + xOffset);
  33. yDisp = (int) ((y * scale) + yOffset);
  34. myArray[xDisp][yDisp]++;
  35. }
  36. if (randomF > 0.66 && randomF >= 0.33)
  37. {
  38. u = (mOne[1][0] * x) + (mOne[1][1] * y) + (mOne[1][4]);
  39. v = (mOne[1][2] * x) + (mOne[1][3] * y) + (mOne[1][5]);
  40. x=u;
  41. y=v;
  42. xDisp = (int) ((x * scale) + xOffset);
  43. yDisp = (int) ((y * scale) + yOffset);
  44. myArray[xDisp][yDisp]++;
  45. }
  46. if(randomF >= 0.66)
  47. {
  48. u = (mOne[2][0] * x) + (mOne[2][1] * y) + (mOne[2][4]);
  49. v = (mOne[2][2] * x) + (mOne[2][3] * y) + (mOne[2][5]);
  50. x=u;
  51. y=v;
  52. xDisp = (int) ((x * scale) + xOffset);
  53. yDisp = (int) ((y * scale) + yOffset);
  54. myArray[xDisp][yDisp]++;
  55.  
  56. }
  57.  
  58.  
  59.  
  60. }
  61.  
  62. IfsViewer.view(myArray);
  63.  
  64. }
  65.  
  66.  
  67. }
RAW Paste Data