Author Topic: Fun With Math Graphics 4  (Read 3616 times)

0 Members and 1 Guest are viewing this topic.

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Fun With Math Graphics 4
« on: January 14, 2021, 09:55:06 pm »
There's 3 different sequences on this one, but each one takes around a minute or less to watch draw. Feel free to add, change, or do whatever to it, just like the others I've posted in the past.
Enjoy.

Code: QB64: [Select]
  1. DIM seconds AS SINGLE
  2. DIM seconds2 AS SINGLE
  3. DIM angle AS SINGLE
  4. DIM angle2 AS SINGLE
  5.  
  6. SCREEN _NEWIMAGE(800, 600, 32)
  7. _TITLE "Fun Math Graphics 4 by SierraKen"
  8. angle = 15
  9. angle2 = 15
  10. seconds2 = 60
  11.     DO
  12.         _LIMIT 400
  13.         seconds = seconds + .1
  14.         s = (60 - seconds) * 6 + 180
  15.         x = INT(SIN(s / angle * 3.141592) * 90) + 400
  16.         y = INT(COS(s / 180 * 3.141592) * 180) + 300
  17.         seconds2 = seconds2 - .1
  18.         s2 = (60 - seconds2) * 6 + 180
  19.         x2 = INT(SIN(s2 / angle2 * 3.141592) * 90) + 400
  20.         y2 = INT(COS(s2 / 180 * 3.141592) * 180) + 300
  21.         PSET (x, y), _RGB32(255, 0, 0)
  22.         PSET (x2, y2), _RGB32(0, 255, 0)
  23.         IF seconds > 60 THEN
  24.             seconds = 0
  25.             seconds2 = 60
  26.             angle = angle + 15
  27.             angle2 = angle2 + 15
  28.             GOTO two:
  29.         END IF
  30.     LOOP
  31.     two:
  32.     t = t + 1
  33.     IF t = 33 THEN GOTO more:
  34. more:
  35. t = 0
  36. angle = 15
  37. angle2 = 15
  38.     DO
  39.         _LIMIT 400
  40.         seconds = seconds + .1
  41.         s = (60 - seconds) * 6 + 180
  42.         x = INT(SIN(s / 180 * 3.141592) * 90) + 400
  43.         y = INT(COS(s / angle * 3.141592) * 180) + 300
  44.         seconds2 = seconds2 - .1
  45.         s2 = (60 - seconds2) * 6 + 180
  46.         x2 = INT(SIN(s2 / 180 * 3.141592) * 90) + 400
  47.         y2 = INT(COS(s2 / angle2 * 3.141592) * 180) + 300
  48.         PSET (x, y), _RGB32(255, 0, 0)
  49.         PSET (x2, y2), _RGB32(0, 255, 0)
  50.         IF seconds > 60 THEN
  51.             seconds = 0
  52.             seconds2 = 60
  53.             angle = angle + 15
  54.             angle2 = angle2 + 15
  55.             GOTO two2:
  56.         END IF
  57.     LOOP
  58.     two2:
  59.     t = t + 1
  60.     IF t = 33 THEN GOTO more2:
  61. more2:
  62. three:
  63. t = 0
  64. angle = 15
  65. angle2 = 15
  66.     DO
  67.         _LIMIT 400
  68.         seconds = seconds + .1
  69.         s = (60 - seconds) * 6 + 180
  70.         x = INT(SIN(s / 90 * 3.141592) * 90) + 400
  71.         y = INT(COS(s / angle * 3.141592) * 180) + 300
  72.         seconds2 = seconds2 - .1
  73.         s2 = (60 - seconds2) * 6 + 180
  74.         x2 = INT(SIN(s2 / 90 * 3.141592) * 90) + 400
  75.         y2 = INT(COS(s2 / angle2 * 3.141592) * 180) + 300
  76.         PSET (x, y), _RGB32(255, 0, 0)
  77.         PSET (x2, y2), _RGB32(0, 255, 0)
  78.         IF seconds > 60 THEN
  79.             seconds = 0
  80.             seconds2 = 60
  81.             angle = angle + 150
  82.             angle2 = angle2 + 150
  83.             GOTO two3:
  84.         END IF
  85.     LOOP
  86.     two3:
  87.     t = t + 1
  88.     IF t = 33 THEN t = 0: GOTO more3:
  89. more3:
  90. 'Add anything you wish.
  91.  
« Last Edit: January 14, 2021, 09:58:50 pm by SierraKen »

Offline OldMoses

  • Seasoned Forum Regular
  • Posts: 469
    • View Profile
Re: Fun With Math Graphics 4
« Reply #1 on: January 15, 2021, 06:18:06 am »
That's a cool looking effect.

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Fun With Math Graphics 4
« Reply #2 on: January 15, 2021, 02:48:58 pm »
Thanks OldMoses, often when I am out of ideas to program, I turn to graphic manipulation. :)

Offline _vince

  • Seasoned Forum Regular
  • Posts: 422
    • View Profile
Re: Fun With Math Graphics 4
« Reply #3 on: January 15, 2021, 07:54:14 pm »
nice, reminds me of

Code: QB64: [Select]
  1. DEFINT A-Z
  2.  
  3. CONST z0 = 2500
  4. CONST y0 = -200
  5. CONST d = 700
  6.  
  7. CONST sw = 640
  8. CONST sh = 480
  9.  
  10. pi = 4 * ATN(1)
  11.  
  12. SCREEN _NEWIMAGE(sw, sh, 32)
  13.  
  14.  
  15. t = 0
  16.     t = t + 0.1
  17.     h = 120 + 100 * SIN(t)
  18.  
  19.     LINE (0, 0)-(sw, sh), _RGB(0, 0, 0), BF
  20.  
  21.     ox = 500 * COS(0)
  22.     oz = 500 * SIN(0)
  23.     oy = -500 + 0 * h / (2 * pi)
  24.     'PSET (sw / 2 + ox * d / (oz + z0), sh / 2 - (oy + y0) * d / (oz + z0))
  25.  
  26.     FOR a = 0.1 TO 15 * 2 * pi STEP 0.01
  27.         x = 500 * COS(a)
  28.         z = 500 * SIN(a)
  29.         y = -500 + a * h / (2 * pi)
  30.  
  31.         DIM dy AS SINGLE
  32.         FOR dy = 6 TO 0 STEP -.5
  33.             LINE (sw / 2 + ox * d / (oz + z0), sh / 2 - (oy + y0) * d / (oz + z0) + dy)-(sw / 2 + x * d / (z + z0) + 6, sh / 2 - (y + y0) * d / (z + z0) + dy), _RGB32(185 - dy * 17), BF
  34.         NEXT
  35.  
  36.         ox = x
  37.         oy = y
  38.         oz = z
  39.     NEXT
  40.  
  41.     _DISPLAY
  42.     _LIMIT 30
  43.  

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Fun With Math Graphics 4
« Reply #4 on: January 15, 2021, 08:10:02 pm »
I found this looking for another thing this reminds me of:
Code: QB64: [Select]
  1. _TITLE "3D Sinusoidal Plot by Hectic"
  2. SCREEN _NEWIMAGE(720, 720, 32)
  3.     _LIMIT 25
  4.     za# = za# + 1
  5.     FOR qq# = 0 TO 4999
  6.         x1# = SIN(_D2R(qq# / 2)) / 4
  7.         y1# = COS(_D2R(qq# / 1.5)) / 8
  8.         x2# = SIN(_D2R(qq# * x1# + za#)) * (qq# + x1#) / 15
  9.         y2# = COS(_D2R(qq# * y1#)) * (qq# + y1#) / 15
  10.         LINE (x2# + 360, y2# + 360)-(x2# + 363, y2# + 363), _RGB(ABS(SIN(_D2R(qq# / 20))) * 255, 0, ABS(COS(_D2R(qq# / 20))) * 255), BF
  11.     NEXT
  12.     _DISPLAY
  13.     CLS
  14. 'SYSTEM
  15.  
  16.  

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Fun With Math Graphics 4
« Reply #5 on: January 15, 2021, 11:09:23 pm »
B+, I took yours and removed the central scribble part of it and turned it into green stars or dots, with trails, that circle around in 3D. Thanks! This does look a little familiar though, you might have made this last year, or someone else posted it. But I can't believe I figured it out. :)
Vince, yep, I still have that spring from last time you posted it awhile back. :) Awesome stuff.

Here is my mod from B+'s post.   

Code: QB64: [Select]
  1. _TITLE "3D Sinusoidal Plot by Hectic - Mod by SierraKen"
  2. SCREEN _NEWIMAGE(720, 720, 32)
  3.     _LIMIT 25
  4.     za# = za# + 1
  5.     FOR qq# = 3000 TO 3500
  6.         'FOR qq# = 0 TO 4999
  7.         'x1# = SIN(_D2R(qq# / 2)) / 4
  8.         'y1# = COS(_D2R(qq# / 1.5)) / 8
  9.         'x2# = SIN(_D2R(qq# * x1# + za#)) * (qq# + x1#) / 15
  10.         'y2# = COS(_D2R(qq# * y1#)) * (qq# + y1#) / 15
  11.         'LINE (x2# + 360, y2# + 360)-(x2# + 363, y2# + 363), _RGB(ABS(SIN(_D2R(qq# / 20))) * 255, 0, ABS(COS(_D2R(qq# / 20))) * 255), BF
  12.         x1# = SIN(_D2R(qq# / 2))
  13.         y1# = COS(_D2R(qq# / 1.5))
  14.         x2# = SIN(_D2R(qq# * x1# + za#)) * (qq# + x1#) / 15
  15.         y2# = COS(_D2R(qq# * y1#)) * (qq# + y1#) / 15
  16.         CIRCLE (x2# + 360, y2# + 360), 1, _RGB32(0, 255, 0)
  17.     NEXT
  18.     _DISPLAY
  19.     LINE (0, 0)-(_WIDTH, _HEIGHT), _RGB32(0, 0, 0, 30), BF
  20. 'SYSTEM
  21.  

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Fun With Math Graphics 4
« Reply #6 on: January 16, 2021, 01:07:24 am »
Here's an even better mod. Now you can see mathematical curves along the outer sides. :)

Code: QB64: [Select]
  1. _TITLE "3D Sinusoidal Plot by Hectic - Mod by SierraKen"
  2. SCREEN _NEWIMAGE(720, 720, 32)
  3.     _LIMIT 25
  4.     za# = za# + 2
  5.     FOR qq# = 3000 TO 3500 STEP .25
  6.         'FOR qq# = 0 TO 4999
  7.         'x1# = SIN(_D2R(qq# / 2)) / 4
  8.         'y1# = COS(_D2R(qq# / 1.5)) / 8
  9.         'x2# = SIN(_D2R(qq# * x1# + za#)) * (qq# + x1#) / 15
  10.         'y2# = COS(_D2R(qq# * y1#)) * (qq# + y1#) / 15
  11.         'LINE (x2# + 360, y2# + 360)-(x2# + 363, y2# + 363), _RGB(ABS(SIN(_D2R(qq# / 20))) * 255, 0, ABS(COS(_D2R(qq# / 20))) * 255), BF
  12.         x1# = SIN(_D2R(qq# / 2))
  13.         y1# = COS(_D2R(qq# / 1.5))
  14.         x2# = SIN(_D2R(qq# * x1# + za#)) * (qq# + x1#) / 15
  15.         y2# = COS(_D2R(qq# * y1#)) * (qq# + y1#) / 15
  16.         CIRCLE (x2# + 360, y2# + 360), 3, _RGB32(0, 255, 0)
  17.     NEXT
  18.     _DISPLAY
  19.     LINE (0, 0)-(_WIDTH, _HEIGHT), _RGB32(0, 0, 0, 30), BF
  20. 'SYSTEM
  21.  

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Fun With Math Graphics 4
« Reply #7 on: January 16, 2021, 08:03:34 am »
Nice mods Ken!

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Fun With Math Graphics 4
« Reply #8 on: January 16, 2021, 11:31:42 am »
Thanks B+ :).

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Fun With Math Graphics 4
« Reply #9 on: January 16, 2021, 11:45:47 am »
Here's a flying text mod I just made. :) Just add any small word and it makes that word fly around.

Code: QB64: [Select]
  1. _TITLE "3D Sinusoidal Plot by Hectic - Text Mod by SierraKen"
  2. SCREEN _NEWIMAGE(720, 720, 32)
  3. go:
  4. LOCATE 1, 1
  5. INPUT "Type a small word here: ", w$
  6.     _LIMIT 25
  7.     za# = za# + 1
  8.     FOR qq# = 3000 TO 3500
  9.         x1# = SIN(_D2R(qq# / 2))
  10.         y1# = COS(_D2R(qq# / 1.5))
  11.         x2# = SIN(_D2R(qq# * x1# + za#)) * (qq# + x1#) / 15
  12.         y2# = COS(_D2R(qq# * y1#)) * (qq# + y1#) / 15
  13.         _PRINTSTRING (x2# + 360, y2# + 360), w$
  14.     NEXT
  15.     _DISPLAY
  16.     LINE (0, 0)-(_WIDTH, _HEIGHT), _RGB32(0, 0, 0, 30), BF
  17. GOTO go:
  18.