Author Topic: Fun Math Graphics 2  (Read 4194 times)

0 Members and 1 Guest are viewing this topic.

This topic contains a post which is marked as Best Answer. Press here if you would like to see it.

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Fun Math Graphics 2
« on: December 30, 2019, 07:07:33 pm »
Today I was checking out my recent Kaleidoscope I made I wondered to myself, "What if I slowed everything down and see what animation it could make?" So I tried it and I hit a gold mine.
I changed the name of it which is now Fun Math Graphics 2. I used medium sized circles to move around using LINE (0, 0)-(800, 600), _RGBA(0, 0, 0, 30), BF to add some effects to it.
Don't ask me to explain the math, because I am just as amazed as what random equations can do. It makes a few random variables which determine the path the circles go. Most of them go in a pattern like a giant lid going in circles on a table starting from the edge and rotating around and around until it hits the table, but they are all random in the dynamics. Many other ones do some strange and bizarre paths. There are 1000's of possible outcomes or more. So try it out and tell me what you think. Watch it for a few minutes so you can see the potential of this program. I added some of the variables to the Title Bar in case anyone wants to try and duplicate the same pattern with their own by pressing the Space Bar to pause first.

Space Bar pauses, Esc quits.

Code: QB64: [Select]
  1. start:
  2. SCREEN _NEWIMAGE(600, 600, 32)
  3. PRINT "                          Fun Math Graphics 2"
  4. PRINT "                               by Ken G."
  5. PRINT "                 Watch the computer calculate different"
  6. PRINT "                 pathways for a circle to move around on."
  7. PRINT "                          Space Bar to Pause."
  8. PRINT "                             Esc to Quit"
  9. INPUT "                        Press Enter To Begin.", bg$
  10.  
  11.     _LIMIT 500
  12.     c1 = INT(RND * 100) + 155
  13.     c2 = INT(RND * 100) + 155
  14.     c3 = INT(RND * 100) + 155
  15.         mouseX = _MOUSEX
  16.         mouseY = _MOUSEY
  17.         mouseLeftButton = _MOUSEBUTTON(1)
  18.         mouseRightButton = _MOUSEBUTTON(2)
  19.         mouseMiddleButton = _MOUSEBUTTON(3)
  20.     LOOP
  21.     k = INT(RND * 900) + 100
  22.     s = 0
  23.     FOR m = 1 TO 3
  24.         RANDOMIZE TIMER
  25.         mx = (RND * 4) - 2
  26.         my = (RND * 4) - 2
  27.         FOR d = 320 TO 0 STEP -.125
  28.             _LIMIT 1000
  29.             s = s + k
  30.             x = COS(s * 3.141592 / 180) * d
  31.             x = x + mx
  32.             y = SIN(s * 3.151492 / 180) * d
  33.             y = y + my
  34.             xx = x + 300: yy = y + 300
  35.             CIRCLE (xx, yy), 30, _RGB32(c1, c2, c3)
  36.             _DISPLAY
  37.             LINE (0, 0)-(800, 600), _RGBA(0, 0, 0, 30), BF
  38.             mx$ = STR$(mx): my$ = STR$(my): s$ = STR$(s): xx$ = STR$(xx): yy$ = STR$(yy): k$ = STR$(k)
  39.             _TITLE "Fun Math Graphics 2 - K=" + k$ + " mx=" + mx$ + " my=" + my$ + " s=" + s$
  40.             a$ = INKEY$
  41.             IF a$ = CHR$(27) THEN END
  42.             IF a$ = " " AND sl = 0 THEN sl = 1: a$ = "": SLEEP
  43.             IF a$ = " " AND sl = 1 THEN sl = 0
  44.         NEXT d
  45.     NEXT m
  46.  

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Fun Math Graphics 2
« Reply #1 on: December 30, 2019, 08:55:10 pm »
I just added the ability to input your own variable amounts. When you press I, it goes to the input screen and you can set 4 different variables that you saved from liking something you saw earlier.
It only shows them for a few seconds or so before it randomly chooses another one, but I think it's cool.

Code: QB64: [Select]
  1. start:
  2. SCREEN _NEWIMAGE(600, 600, 32)
  3. PRINT "                          Fun Math Graphics 2"
  4. PRINT "                               by Ken G."
  5. PRINT "                 Watch the computer calculate different"
  6. PRINT "                 pathways for a circle to move around on."
  7. PRINT "                          Space Bar to Pause."
  8. PRINT "                      I to set your own variables"
  9. PRINT "                             Esc to Quit"
  10. INPUT "                        Press Enter To Begin.", bg$
  11.  
  12.     _LIMIT 500
  13.     c1 = INT(RND * 100) + 155
  14.     c2 = INT(RND * 100) + 155
  15.     c3 = INT(RND * 100) + 155
  16.         mouseX = _MOUSEX
  17.         mouseY = _MOUSEY
  18.         mouseLeftButton = _MOUSEBUTTON(1)
  19.         mouseRightButton = _MOUSEBUTTON(2)
  20.         mouseMiddleButton = _MOUSEBUTTON(3)
  21.     LOOP
  22.     k = INT(RND * 900) + 100
  23.     s = 0
  24.     FOR m = 1 TO 3
  25.         RANDOMIZE TIMER
  26.         mx = (RND * 4) - 2
  27.         my = (RND * 4) - 2
  28.         FOR d = 320 TO 0 STEP -.125
  29.             _LIMIT 1000
  30.             s = s + k
  31.             x = COS(s * 3.141592 / 180) * d
  32.             x = x + mx
  33.             y = SIN(s * 3.151492 / 180) * d
  34.             y = y + my
  35.             xx = x + 300: yy = y + 300
  36.             CIRCLE (xx, yy), 30, _RGB32(c1, c2, c3)
  37.             _DISPLAY
  38.             LINE (0, 0)-(800, 600), _RGBA(0, 0, 0, 30), BF
  39.             mx$ = STR$(mx): my$ = STR$(my): s$ = STR$(s): xx$ = STR$(xx): yy$ = STR$(yy): k$ = STR$(k)
  40.             _TITLE "Fun Math Graphics 2 - K=" + k$ + " mx=" + mx$ + " my=" + my$ + " s=" + s$
  41.             a$ = INKEY$
  42.             IF a$ = CHR$(27) THEN END
  43.             IF a$ = " " AND sl = 0 THEN sl = 1: a$ = "": SLEEP
  44.             IF a$ = " " AND sl = 1 THEN sl = 0
  45.             IF a$ = "I" OR a$ = "i" THEN GOSUB info:
  46.         NEXT d
  47.     NEXT m
  48. info:
  49. INPUT "k: ", k
  50. INPUT "mx: ", mx
  51. INPUT "my: ", my
  52. INPUT "s: ", s
  53.  

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Fun Math Graphics 2
« Reply #2 on: December 31, 2019, 12:53:53 pm »
If you don't want to wait for random choices it makes, you can press I and enter any of these examples I wrote down:

"Juggle"
k=659
mx=1.070739
my=1.296892
s=655705
------------------
"Coin"
k=321
mx=1.248722
my=.2715797
s=286011
------------------
"Coin 2"
k=321
mx=.4692338
my=.8475013
s=1607247
------------------
"Up and Down"
k=120
mx=1.096297
my=.659328
s=300960
------------------
"Big Coin"
k=106
mx= .1813991
my= -1.679267
s= 235956
------------------
"Dancing"
k=258
mx= -1.142254
my= 1.664867
s= 1489692
-------------------
"Open and Close"
k=166
mx= -1.737304
my= 1.140303
s= 248668
-------------------
"A Dizzy Circle"
k=126
mx= 1.371215
my= 1.281544
s= 699174
-------------------
"Waves"
k= 320
mx=  1.708808
my= -.4963732
s= 1344960
--------------------
"Speed Racer"
k= 214
mx= 1.125437
my= 1.366045
s= 318218
 

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Fun Math Graphics 2
« Reply #3 on: December 31, 2019, 02:20:10 pm »
Yeah well I don't want to enter all those silly numbers to see what you are liking so
Code: QB64: [Select]
  1. start:
  2. SCREEN _NEWIMAGE(600, 600, 32)
  3. PRINT "                          Fun Math Graphics 2"
  4. PRINT "                               by Ken G. mod B+"
  5. PRINT "                 Watch the computer calculate different"
  6. PRINT "                 pathways for a circle to move around on."
  7. PRINT "                          Space Bar to Pause."
  8. PRINT "                      I to set your own variables"
  9. PRINT "                             Esc to Quit"
  10. INPUT "                        Press Enter To Begin.", bg$
  11.  
  12.     _LIMIT 500
  13.     c1 = INT(RND * 100) + 155
  14.     c2 = INT(RND * 100) + 155
  15.     c3 = INT(RND * 100) + 155
  16.         mouseX = _MOUSEX
  17.         mouseY = _MOUSEY
  18.         mouseLeftButton = _MOUSEBUTTON(1)
  19.         mouseRightButton = _MOUSEBUTTON(2)
  20.         mouseMiddleButton = _MOUSEBUTTON(3)
  21.     LOOP
  22.     k = INT(RND * 900) + 100
  23.     s = 0
  24.     name$ = "random"
  25.     FOR m = 1 TO 3
  26.         RANDOMIZE TIMER
  27.         mx = (RND * 4) - 2
  28.         my = (RND * 4) - 2
  29.         FOR d = 320 TO 0 STEP -.125
  30.             _LIMIT 1000
  31.             s = s + k
  32.             x = COS(s * 3.141592 / 180) * d
  33.             x = x + mx
  34.             y = SIN(s * 3.151492 / 180) * d
  35.             y = y + my
  36.             xx = x + 300: yy = y + 300
  37.             CIRCLE (xx, yy), 30, _RGB32(c1, c2, c3)
  38.             _DISPLAY
  39.             LINE (0, 0)-(800, 600), _RGBA(0, 0, 0, 30), BF
  40.             mx$ = STR$(mx): my$ = STR$(my): s$ = STR$(s): xx$ = STR$(xx): yy$ = STR$(yy): k$ = STR$(k)
  41.             _TITLE "Fun K=" + k$ + " mx=" + mx$ + " my=" + my$ + " s=" + s$ + " name= " + name$
  42.             a$ = INKEY$
  43.             IF a$ = CHR$(27) THEN END
  44.             IF a$ = " " AND sl = 0 THEN sl = 1: a$ = "": SLEEP
  45.             IF a$ = " " AND sl = 1 THEN sl = 0
  46.             IF a$ = "I" OR a$ = "i" THEN
  47.                 GOSUB info
  48.                 d = 320
  49.                 m = 1
  50.             END IF
  51.         NEXT d
  52.     NEXT m
  53. info:
  54. mode = (mode + 1) MOD 10
  55.     CASE 1 '
  56.         name$ = "Juggle"
  57.         k = 659
  58.         mx = 1.070739
  59.         my = 1.296892
  60.         s = 655705
  61.     CASE 2
  62.         name$ = "Coin"
  63.         k = 321
  64.         mx = 1.248722
  65.         my = .2715797
  66.         s = 286011
  67.     CASE 3
  68.         name$ = "Coin 2"
  69.         k = 321
  70.         mx = .4692338
  71.         my = .8475013
  72.         s = 1607247
  73.     CASE 4
  74.         name$ = "Up and Down"
  75.         k = 120
  76.         mx = 1.096297
  77.         my = .659328
  78.         s = 300960
  79.     CASE 5
  80.         name$ = "Big Coin"
  81.         k = 106
  82.         mx = .1813991
  83.         my = -1.679267
  84.         s = 235956
  85.     CASE 6
  86.         name$ = "Dancing"
  87.         k = 258
  88.         mx = -1.142254
  89.         my = 1.664867
  90.         s = 1489692
  91.     CASE 7
  92.         name$ = "Open and Close"
  93.         k = 166
  94.         mx = -1.737304
  95.         my = 1.140303
  96.         s = 248668
  97.     CASE 8
  98.         name$ = "A Dizzy Circle"
  99.         k = 126
  100.         mx = 1.371215
  101.         my = 1.281544
  102.         s = 699174
  103.     CASE 9
  104.         name$ = "Waves"
  105.         k = 320
  106.         mx = 1.708808
  107.         my = -.4963732
  108.         s = 1344960
  109.     CASE 0
  110.         name$ = "Speed Racer"
  111.         k = 214
  112.         mx = 1.125437
  113.         my = 1.366045
  114.         s = 318218
  115.  
  116.  
  117.  

;D BTW what is the mouse stuff for?
« Last Edit: December 31, 2019, 02:22:41 pm by bplus »

Marked as best answer by SierraKen on December 31, 2019, 02:49:17 pm

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Fun Math Graphics 2
« Reply #4 on: December 31, 2019, 03:07:27 pm »
LOL Bplus, hey my brain is still on holiday mode. :) The mouse stuff was from the Kaleidoscope that I got the code from, I forgot to remove it, thanks for telling me.
Also thanks for the idea of putting in the examples, I used that idea except to make a list of them and have the user choose from them.
I hope to use this program in the future to make animations of different sorts. Tell me what you think, thanks. Also, try picking random numbers, like 100,200,300,400 or whatever. I don't think it works with all the same numbers though for some reason.
Here is my update:

Code: QB64: [Select]
  1. start:
  2. SCREEN _NEWIMAGE(600, 600, 32)
  3. PRINT "                          Fun Math Graphics 2"
  4. PRINT "                               by Ken G."
  5. PRINT "                 Watch the computer calculate different"
  6. PRINT "                 pathways for a circle to move around on."
  7. PRINT "                          Space Bar to Pause."
  8. PRINT "               I to set your own variables or see examples."
  9. PRINT "                             Esc to Quit"
  10. INPUT "                        Press Enter To Begin.", bg$
  11.  
  12.     _LIMIT 500
  13.     c1 = INT(RND * 100) + 155
  14.     c2 = INT(RND * 100) + 155
  15.     c3 = INT(RND * 100) + 155
  16.     k = INT(RND * 900) + 100
  17.     s = 0
  18.     NAME$ = "random"
  19.     FOR m = 1 TO 3
  20.         RANDOMIZE TIMER
  21.         mx = (RND * 4) - 2
  22.         my = (RND * 4) - 2
  23.         FOR d = 320 TO 0 STEP -.125
  24.             _LIMIT 1000
  25.             s = s + k
  26.             x = COS(s * 3.141592 / 180) * d
  27.             x = x + mx
  28.             y = SIN(s * 3.151492 / 180) * d
  29.             y = y + my
  30.             xx = x + 300: yy = y + 300
  31.             CIRCLE (xx, yy), 30, _RGB32(c1, c2, c3)
  32.             _DISPLAY
  33.             LINE (0, 0)-(800, 600), _RGBA(0, 0, 0, 30), BF
  34.             mx$ = STR$(mx): my$ = STR$(my): s$ = STR$(s): xx$ = STR$(xx): yy$ = STR$(yy): k$ = STR$(k)
  35.             _TITLE "K=" + k$ + " mx=" + mx$ + " my=" + my$ + " s=" + s$ + " name= " + NAME$
  36.             a$ = INKEY$
  37.             IF a$ = CHR$(27) THEN END
  38.             IF a$ = " " AND sl = 0 THEN sl = 1: a$ = "": SLEEP
  39.             IF a$ = " " AND sl = 1 THEN sl = 0
  40.             IF a$ = "I" OR a$ = "i" THEN GOSUB info:
  41.         NEXT d
  42.     NEXT m
  43. info:
  44. PRINT "See Examples or Input Data Page"
  45. PRINT "(1) See Examples"
  46. PRINT "(2) Input Your Own Data"
  47. PRINT "(3) Go Back To Random Displays"
  48. PRINT "(4) Quit"
  49. INPUT "Choose 1-4 Here:", ex
  50. IF ex = 1 THEN GOTO examples:
  51. IF ex = 2 THEN GOTO inputting:
  52. IF ex = 3 THEN RETURN
  53. IF ex = 4 THEN END
  54. GOTO info:
  55.  
  56. examples:
  57. PRINT "Examples"
  58. PRINT "(0) Speed Racer"
  59. PRINT "(1) Juggle"
  60. PRINT "(2) Coin"
  61. PRINT "(3) Coin 2"
  62. PRINT "(4) Up and Down"
  63. PRINT "(5) Big Coin"
  64. PRINT "(6) Dancing"
  65. PRINT "(7) Open and Close"
  66. PRINT "(8) A Dizzy Circle"
  67. PRINT "(9) Waves"
  68. INPUT "Type 0-9 Here:"; exx
  69. IF exx < 0 OR exx > 9 OR exx <> INT(exx) THEN GOTO examples:
  70. IF exx = 1 THEN
  71.     NAME$ = "Juggle"
  72.     k = 659
  73.     mx = 1.070739
  74.     my = 1.296892
  75.     s = 655705
  76. IF exx = 2 THEN
  77.     NAME$ = "Coin"
  78.     k = 321
  79.     mx = 1.248722
  80.     my = .2715797
  81.     s = 286011
  82. IF exx = 3 THEN
  83.     NAME$ = "Coin 2"
  84.     k = 321
  85.     mx = .4692338
  86.     my = .8475013
  87.     s = 1607247
  88. IF exx = 4 THEN
  89.     NAME$ = "Up and Down"
  90.     k = 120
  91.     mx = 1.096297
  92.     my = .659328
  93.     s = 300960
  94. IF exx = 5 THEN
  95.     NAME$ = "Big Coin"
  96.     k = 106
  97.     mx = .1813991
  98.     my = -1.679267
  99.     s = 235956
  100. IF exx = 6 THEN
  101.     NAME$ = "Dancing"
  102.     k = 258
  103.     mx = -1.142254
  104.     my = 1.664867
  105.     s = 1489692
  106. IF exx = 7 THEN
  107.     NAME$ = "Open and Close"
  108.     k = 166
  109.     mx = -1.737304
  110.     my = 1.140303
  111.     s = 248668
  112. IF exx = 8 THEN
  113.     NAME$ = "A Dizzy Circle"
  114.     k = 126
  115.     mx = 1.371215
  116.     my = 1.281544
  117.     s = 699174
  118. IF exx = 9 THEN
  119.     NAME$ = "Waves"
  120.     k = 320
  121.     mx = 1.708808
  122.     my = -.4963732
  123.     s = 1344960
  124. IF exx = 0 THEN
  125.     NAME$ = "Speed Racer"
  126.     k = 214
  127.     mx = 1.125437
  128.     my = 1.366045
  129.     s = 318218
  130.  
  131. inputting:
  132. INPUT "Name: ", NAME$
  133. INPUT "k: ", k
  134. INPUT "mx: ", mx
  135. INPUT "my: ", my
  136. INPUT "s: ", s
  137.  


Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Fun Math Graphics 2
« Reply #5 on: December 31, 2019, 07:49:01 pm »
LOL Thanks [banned user]!