Advertisement
Guest User

Untitled

a guest
Jun 18th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. program aaa
  2. use dflib
  3. implicit none
  4. integer i, j, k, m, counterBall, counter, mask(1000), balls, check, steps, next, cyrcle, linewidth, speedcolor, color(1000), resultspeed(250), graphsize
  5. real x(1000), y(1000), way(1000), position, lx, ly, lx2, ly2, eee, d, d1, d2, wx1, wx, wy1, wy, tmp, speed(1000), eps, minspeed, angle, maxspeed, Macsvell, tmpspeed(1000), pi, addx, addy
  6. type (xycoord) xy
  7. call setvieworg(400,100,xy)
  8.  
  9. pi = 3.14159
  10. balls = 1000 ! kolichestvo sharov
  11. linewidth = 10 ! tolshina linii
  12. cyrcle = 180 ! scorost' vrasheniya
  13. next = 5 ! scorost' poyavleniya
  14. eps = 0.0001 ! tochnost' integrala
  15. minspeed = 0
  16. maxspeed = 3
  17. angle = pi / 12 ! ugol v radianax
  18. graphsize = 250
  19.  
  20. counterBall = 1
  21.  
  22. 1 continue
  23.  
  24. !call sleepqq(10)
  25.  
  26. if ((int(counter/next) + 1).ge.counterBall .and. counterBall.le.balls) then
  27.     call random_seed()
  28.     call random_number(tmp)
  29.     way(counterBall) = tmp * pi * 32 !32 casuse more random.
  30.     mask(counterBall) = 1
  31.     speed(counterBall) = Macsvell(eps, minspeed, maxspeed)
  32.     color(counterBall) = speedcolor(speed(counterBall), minspeed, maxspeed)
  33.     counterBall = counterBall + 1
  34. endif
  35.  
  36. call clearscreen($gclearscreen)
  37. eee = -counter
  38. eee = eee / cyrcle
  39. wx = int(150*sin(eee+angle))
  40. wy = int(150*cos(eee+angle))
  41. wx1 = int(150*sin(eee-angle))
  42. wy1 = int(150*cos(eee-angle))
  43. d=setcolorrgb(#ff0000)
  44. d2=ellipse ($GFILLINTERIOR, -linewidth,-linewidth,500+linewidth,500+linewidth)
  45. d=setcolor(0)
  46. d2=ellipse ($GFILLINTERIOR, 0,0,500,500)
  47. d1=setcolor(12)
  48. d1=pie ($GFILLINTERIOR, 100-linewidth,100-linewidth,400+linewidth,400+linewidth,250+wy1,250+wx1,250+wy,250+wx)
  49. d1=setcolor (0)
  50. d1=ellipse($GFILLINTERIOR, 100,100,400,400)
  51. d=setcolor(9)
  52. d=ellipse($GFILLINTERIOR, 245,245,255,255)
  53.  
  54. check = 0
  55.  
  56. do i = 1, balls
  57.  
  58.     if (mask(i).eq.1) then
  59.         check = check + 1
  60.         tmpspeed(check) = speed(i)
  61.         eee = counter
  62.         eee = eee / cyrcle
  63.         steps = counter - i * next + next
  64.         x(i) = cos(way(i)) * speed(i) * steps
  65.         y(i) = sin(way(i)) * speed(i) * steps
  66.         lx = x(i) + 250
  67.         ly = y(i) + 250
  68.         k = getpixel(lx, ly)
  69.         !write(*, *) (x(i) ** 2 + y(i) ** 2), (250 ** 2)
  70.         !call sleepqq(100)
  71.         if (k.eq.12 .or. ((x(i) ** 2 + y(i) ** 2).ge.(250 ** 2))) then
  72.             if (lx.lt.(400+linewidth) .and. lx.gt.(100-linewidth) .and. ly.gt.(100-linewidth) .and. ly.lt.(400+linewidth)) then
  73.                 mask(i) = 0
  74.             else
  75.                 mask(i) = 2
  76.                 lx2 = cos(way(i)) * steps * speed(i)
  77.                 ly2 = sin(way(i)) * steps * speed(i)
  78.                 x(i) = lx2*cos(-eee) + ly2*sin(-eee)
  79.                 y(i) = ly2*cos(-eee) - lx2*sin(-eee)
  80.             endif
  81.         else
  82.             d = setcolorrgb(color(i))
  83.             d = ellipse($GFILLINTERIOR, lx-5, ly-5, lx+5, ly+5)
  84.         endif
  85.     endif
  86.  
  87.     if (mask(i).eq.2) then
  88.         eee = counter
  89.         eee = eee / cyrcle
  90.         lx2 = x(i)
  91.         ly2 = y(i)
  92.         lx = lx2*cos(eee) + ly2*sin(eee) + 250
  93.         ly = ly2*cos(eee) - lx2*sin(eee) + 250
  94.         d = setcolor(10)
  95.         d = ellipse($GFILLINTERIOR, lx-5, ly-1, lx+5, ly+1)
  96.     endif
  97. enddo
  98.  
  99. if (check.eq.0 .and. counterBall.ge.balls) then
  100.     goto 2
  101. endif
  102.  
  103. write(*,*) (tmpspeed(i),i=1,check)
  104.  
  105. counter = counter + 1
  106. goto 1
  107.  
  108. 2 continue
  109.  
  110. check = 0
  111.  
  112. do i = 1, balls
  113.     if (mask(i).eq.2) then
  114.         check = check + 1
  115.     endif
  116.     j = int((speed(i) - minspeed) * graphsize / (maxspeed - minspeed))
  117.     resultspeed(j) = resultspeed(j) + 1
  118. enddo
  119.  
  120. m = 0
  121. do i = 1, graphsize
  122.     m = max(m, resultspeed(i))
  123. enddo
  124.  
  125. k = int(graphsize / (maxspeed - minspeed))
  126. k = 16
  127. do i = 1, graphsize
  128.     do j = 0, resultspeed(i) * k
  129.         d = setcolorrgb(Z"ffff" - Z"100" * int(255 * j / (m * k)))
  130.         d = setpixel(-graphsize + i, 500 - j)
  131.         d = setpixel(-graphsize + i + 1, 500 - j)
  132.     enddo
  133. enddo
  134.  
  135. write(*, *) check, balls
  136.  
  137. end
  138.  
  139.  
  140.  
  141. real function F(x)
  142. implicit none
  143. real x
  144.  
  145. F = 4*3.14159*(3.14159)**(1.5)*exp(-x**2)*x**2
  146.  
  147. return
  148. end
  149.  
  150. real function integ(eps, l, r)
  151. implicit none
  152. real l, r, F, eps
  153. integer num, i
  154.  
  155. integ = 0
  156. num = (r-l) / eps
  157. do i = 1, num
  158.     integ = integ + eps * F(l + i * eps)
  159. enddo
  160.  
  161. return
  162. end
  163.  
  164. real function searchinteg(eps, l, r, value)
  165. implicit none
  166. real l, r, F, eps, integ, value
  167. integer num, i
  168.  
  169. integ = 0
  170. num = (r-l) / eps
  171. do i = 1, num
  172.     integ = integ + eps * F(l + i * eps)
  173.     if (integ.ge.value) then
  174.         searchinteg = l + i * eps - eps / 2
  175.         return
  176.     endif
  177. enddo
  178. searchinteg = r
  179. return
  180. end
  181.  
  182. real function Macsvell(eps, mins, maxs)
  183. implicit none
  184. integer m
  185. real rand, eps, max, integ, mid, tmp, mins, maxs, searchinteg
  186.  
  187. call random_seed()
  188. call random_number(rand)
  189. max = integ(eps, mins, maxs)
  190. rand = rand * max
  191. Macsvell = searchinteg(eps, mins, maxs, rand)
  192.  
  193. return
  194. end
  195.  
  196. integer function speedcolor(speed, min, max)
  197. real speed, min, max
  198.  
  199. speedcolor = Z"440000" + Z"10001" * int(speed*160 / (max - min))
  200.  
  201. return
  202. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement