Author Topic: Russian Circle Diagram  (Read 4245 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 DANILIN

  • Forum Regular
  • Posts: 128
    • Danilin youtube
Russian Circle Diagram
« on: November 06, 2021, 12:12:44 pm »
Russian Circle Diagram

We build pie charts in 2 ways as Russian Circle Diagram
and it is still possible other way around from edges to center

Code: QB64: [Select]
  1. 'diagram.bas  Russian Circle Diagram
  2. N = 13: s = 0: DIM d(N),r(N+1): SCREEN 12: RANDOMIZE TIMER
  3. FOR i = 1 TO N: d(i) = INT(RND*90+9): s = s+d(i): PRINT d(i): NEXT: PRINT "SUM= "; s
  4. FOR i = 2 TO N: r(i) = r(i-1)+d(i)*2*3.1416/s: NEXT: r(N+1) = r(1)
  5.  
  6. FOR i = 2 TO N+1: FOR j = 1 TO 100: CIRCLE (150,150),j,i,r(i-1),r(i)
  7.         CIRCLE (149,149),j,i,r(i-1),r(i): CIRCLE (151,149),j,i,r(i-1),r(i)
  8.  
  9. FOR j = 1 TO 100: FOR i = 2 TO N+1: CIRCLE (350,150),j,i,r(i-1),r(i)
  10.         CIRCLE (349,149),j,i,r(i-1),r(i): CIRCLE (351,149),j,i,r(i-1),r(i)

Necessary: schkolnaya olympiyskaya zadacha

 
diagram.gif


Plus it is also possible to build a pattern in corners
connecting all points together

 
soedin.gif


Practically: olympic school problem

 
komblife.gif


animations all: less than 300 kb
« Last Edit: November 06, 2021, 01:57:00 pm by DANILIN »
Russia looks world from future. big data is peace data.
https://youtube.com/playlist?list=PLBBTP9oVY7IagpH0g9FNUQ8JqmHwxDDDB
i never recommend anything to anyone and always write only about myself

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: Russian Circle Diagram
« Reply #1 on: November 06, 2021, 01:58:55 pm »
Code: QB64: [Select]
  1. _Title "Pie Chart" ' b+ 2021-11-06 fix up Russian Circle Diagram
  2. 'ref https://www.qb64.org/forum/index.php?topic=4367.msg137864#msg137864
  3.  
  4. N = 13
  5. Dim d(1 To N), sumD(1 To N), ra(1 To N)
  6. For i = 1 To N
  7.     d(i) = Int(Rnd * 90 + 9) ' min 9, max 99.99..
  8.     s = s + d(i)
  9.     sumD(i) = s
  10.  
  11. For i = 1 To N
  12.     ra(i) = sumD(i) * 2 * 3.1416 / s
  13.     Color i: Print d(i); ra(i)
  14. Color 15: Print s; "= SUM "
  15.  
  16. For i = 1 To N
  17.     For radius = 1 To (_Height / 2.5) Step .25
  18.         If i = 1 Then
  19.             Circle (_Width / 2 + 50, _Height / 2), radius, i, 0, ra(1)
  20.         ElseIf i = N Then
  21.             Circle (_Width / 2 + 50, _Height / 2), radius, i, ra(i - 1), _Pi(2)
  22.         Else
  23.             Circle (_Width / 2 + 50, _Height / 2), radius, i, ra(i - 1), ra(i)
  24.         End If
  25.     Next
  26.  
  27. For i = 1 To N
  28.     If i = 1 Then a = ra(1) / 2 Else a = (ra(i) + ra(i - 1)) / 2
  29.     x = _Width / 2 + 50 + _Height / 3 * Cos(a)
  30.     y = _Height / 2 - _Height / 3 * Sin(a) ' <<<<<<<<<< dang backwards circle function!!!
  31.     s$ = _Trim$(Str$(d(i)))
  32.     Color 0: _PrintString (x + 2 - 4 * Len(s$), y + 2 - 8), s$
  33.     Color 15: _PrintString (x - 3.5 * Len(s$), y - 8), _Trim$(Str$(d(i)))
  34.  

 
Pie Chart.PNG

Offline DANILIN

  • Forum Regular
  • Posts: 128
    • Danilin youtube
Re: Russian Circle Diagram
« Reply #2 on: November 06, 2021, 03:08:29 pm »
Code: QB64: [Select]
  1.         END IF
  2.     _DELAY .001: NEXT

_DELAY .001:

better and implements particularity: animation is visible
Russia looks world from future. big data is peace data.
https://youtube.com/playlist?list=PLBBTP9oVY7IagpH0g9FNUQ8JqmHwxDDDB
i never recommend anything to anyone and always write only about myself

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: Russian Circle Diagram
« Reply #3 on: November 06, 2021, 03:22:55 pm »
Better way to do color fill?
Code: QB64: [Select]
  1. _Title "Pie Chart 2" ' b+ 2021-11-06 fix up Russian Circle Diagram
  2. 'ref https://www.qb64.org/forum/index.php?topic=4367.msg137864#msg137864
  3.  
  4. N = 13
  5. Dim d(1 To N), sumD(1 To N), ra(1 To N)
  6. For i = 1 To N
  7.     d(i) = Int(Rnd * 90 + 9) ' min 9, max 99.99..
  8.     s = s + d(i)
  9.     sumD(i) = s
  10.  
  11. For i = 1 To N ' better fill method?
  12.     ra(i) = sumD(i) * 2 * 3.1416 / s
  13.     Color i: Print d(i); ra(i)
  14.  
  15. Color 15: Print s; "= SUM "
  16. radius = _Height / 2.5
  17. Circle (_Width / 2 + 50, _Height / 2), radius, &HFFFFFFFF
  18. For i = 1 To N
  19.     x = _Width / 2 + 50 + radius * Cos(ra(i))
  20.     Y = _Height / 2 + radius * Sin(ra(i))
  21.     Line (_Width / 2 + 50, _Height / 2)-(x, Y), &HFFFFFFFF
  22.     Paint (_Width / 2 + 50 + (radius - 10) * Cos(ra(i) - _Pi(1 / 36)), _Height / 2 + (radius - 10) * Sin(ra(i) - _Pi(1 / 36))), i, &HFFFFFFFF
  23.  
  24. For i = 1 To N
  25.     If i = 1 Then a = ra(1) / 2 Else a = (ra(i) + ra(i - 1)) / 2
  26.     x = _Width / 2 + 50 + _Height / 3 * Cos(a)
  27.     Y = _Height / 2 + _Height / 3 * Sin(a) ' <<<<<<<<<< NOT backwards because not using Circle Function for fill
  28.     s$ = _Trim$(Str$(d(i)))
  29.     Color 0: _PrintString (x + 2 - 4 * Len(s$), Y + 2 - 8), s$
  30.     Color 15: _PrintString (x - 3.5 * Len(s$), Y - 8), _Trim$(Str$(d(i)))
  31.  

 
Pie Chart 2.PNG

Offline DANILIN

  • Forum Regular
  • Posts: 128
    • Danilin youtube
Re: Russian Circle Diagram
« Reply #4 on: November 06, 2021, 03:37:40 pm »
? animation ? ... animation ... ! animation !

Code: QB64: [Select]
  1.     '_DELAY .5: NEXT
  2.  
  3.     '   FOR i = 1 TO N

Code: QB64: [Select]

? animation ? ... animation ... ! animation !

... to be continued ...

 
diagout.gif
« Last Edit: November 07, 2021, 02:08:22 am by DANILIN »
Russia looks world from future. big data is peace data.
https://youtube.com/playlist?list=PLBBTP9oVY7IagpH0g9FNUQ8JqmHwxDDDB
i never recommend anything to anyone and always write only about myself

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: Russian Circle Diagram
« Reply #5 on: November 06, 2021, 04:43:50 pm »
Animation coming right up!
Code: QB64: [Select]
  1. _Title "Pie Chart 2 Animate" ' b+ 2021-11-06 fix up Russian Circle Diagram
  2. 'ref https://www.qb64.org/forum/index.php?topic=4367.msg137864#msg137864
  3. N = 13
  4. Dim d(1 To N), sumD(1 To N), ra(1 To N)
  5. For i = 1 To N
  6.     d(i) = Int(Rnd * 90 + 9) ' min 9, max 99.99..
  7.     s = s + d(i)
  8.     sumD(i) = s
  9. radius = _Height / 2.5
  10.     Cls
  11.     For i = 1 To N ' better fill method?
  12.         ra(i) = sumD(i) * 2 * 3.1416 / s
  13.         Color i: Print d(i); ra(i)
  14.     Next
  15.     Color 15: Print s; "= SUM "
  16.     offset = offset + _Pi(1 / 360)
  17.     Circle (_Width / 2 + 50, _Height / 2), radius, &HFFFFFFFF
  18.     For i = 1 To N
  19.         x = _Width / 2 + 50 + radius * Cos(ra(i) + offset)
  20.         y = _Height / 2 + radius * Sin(ra(i) + offset)
  21.         Line (_Width / 2 + 50, _Height / 2)-(x, y), &HFFFFFFFF
  22.         Paint (_Width / 2 + 50 + (radius - 10) * Cos(ra(i) + offset - _Pi(1 / 36)), _Height / 2 + (radius - 10) * Sin(ra(i) + offset - _Pi(1 / 36))), i, &HFFFFFFFF
  23.     Next
  24.     For i = 1 To N
  25.         If i = 1 Then a = ra(1) / 2 + offset Else a = (ra(i) + ra(i - 1)) / 2 + offset
  26.         x = _Width / 2 + 50 + _Height / 3 * Cos(a)
  27.         y = _Height / 2 + _Height / 3 * Sin(a) ' <<<<<<<<<< NOT backwards circle function!!!
  28.         s$ = _Trim$(Str$(d(i)))
  29.         Color 0: _PrintString (x + 2 - 3.5 * Len(s$), y + 2 - 8), s$  ' <<< EDIT: from 4 * Len()
  30.         Color 15: _PrintString (x - 3.5 * Len(s$), y - 8), _Trim$(Str$(d(i)))
  31.     Next
  32.     _Display
  33.     _Limit 30
  34.  

Edit: fix number noted in code
« Last Edit: November 06, 2021, 05:01:02 pm by bplus »

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
Re: Russian Circle Diagram
« Reply #6 on: November 06, 2021, 07:48:22 pm »
That's pretty cool... But it does remind me of Wheel of Fortune.... lol
Logic is the beginning of wisdom.

Offline DANILIN

  • Forum Regular
  • Posts: 128
    • Danilin youtube
Re: Russian Circle Diagram
« Reply #7 on: November 15, 2021, 04:01:44 am »
animation 120 kB

 
diagout.gif


Code: QB64: [Select]
  1. 'diagout.bas  Russian Circle Diagram
  2. N=12: s=0: DIM d(N),r(N+1): SCREEN 12: RANDOMIZE TIMER
  3. FOR i=1 TO N: d(i)=INT(RND*90+9): s=s+d(i): PRINT d(i): NEXT: PRINT "SUM= "; s
  4. FOR i=2 TO N: r(i)=r(i-1)+d(i)*2*3.1416/s: NEXT: r(N+1)=r(1)
  5.  
  6. FOR i=2 TO N+1 STEP 2: FOR j=1 TO 100: CIRCLE (150,100),j,i,r(i-1),r(i)
  7.         CIRCLE (149,99),j,i,r(i-1),r(i): CIRCLE (151,99),j,i,r(i-1),r(i)
  8.  
  9. FOR i=3 TO N+1 STEP 2: FOR j=100 TO 1 STEP -1: CIRCLE (150,100),j,i,r(i-1),r(i)
  10.         CIRCLE (149,99),j,i,r(i-1),r(i): CIRCLE (151,99),j,i,r(i-1),r(i)
  11.  
  12. FOR j=1 TO 100: FOR i=2 TO N+1
  13.         IF (i MOD 2)=0 THEN CIRCLE (350,100),j,i,r(i-1),r(i): CIRCLE (349,99),j,i,r(i-1),r(i): CIRCLE (351,99),j,i,r(i-1),r(i)
  14.         IF (i MOD 2)=1 THEN CIRCLE (350,100),100-j,i,r(i-1),r(i): CIRCLE (349,99),100-j,i,r(i-1),r(i): CIRCLE (351,99),100-j,i,r(i-1),r(i)
Russia looks world from future. big data is peace data.
https://youtube.com/playlist?list=PLBBTP9oVY7IagpH0g9FNUQ8JqmHwxDDDB
i never recommend anything to anyone and always write only about myself

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
Re: Russian Circle Diagram
« Reply #8 on: November 15, 2021, 05:59:28 am »
Cool effects...
Logic is the beginning of wisdom.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: Russian Circle Diagram
« Reply #9 on: November 15, 2021, 12:54:34 pm »
To avoid the ugly holes step even less than 1 through Circle( ), radii
Step .5 gets most Step .25 gets almost all. The extra stepping would slow the fills which might add to the animation by slowing it a bit?

And since the 2nd way of filling is way more interesting than first, just devote whole screen to filling the 2nd way, it is cool enough to stand on it's own! :)
« Last Edit: November 15, 2021, 01:00:33 pm by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: Russian Circle Diagram
« Reply #10 on: November 15, 2021, 02:01:18 pm »
Code: QB64: [Select]
  1. 'diagout.bas  Russian Circle Diagram
  2. N = 12: s = 0: Dim d(N), r(N + 1): Screen 12: Randomize Timer
  3. For i = 1 To N: d(i) = Int(Rnd * 90 + 9): s = s + d(i): Print d(i): Next: Print "SUM= "; s
  4. For i = 2 To N: r(i) = r(i - 1) + d(i) * 2 * 3.1416 / s: Next: r(N + 1) = r(1)
  5. For j = 0 To 200 Step .25: For i = 1 To N + 1
  6.     If (i Mod 2) = 0 Then Circle (320, 240), j, i, r(i - 1), r(i)
  7.         If (i Mod 2) = 1 Then Circle (320, 240), 200 - j, i, r(i - 1), r(i)
  8.  

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: Russian Circle Diagram
« Reply #11 on: November 15, 2021, 03:08:53 pm »
Finally I get the colors matched up with the original random amounts:
Code: QB64: [Select]
  1. 'diagout.bas  Russian Circle Diagram
  2. N = 12: Dim d(N): Screen 12: Randomize Timer
  3. For i = 1 To N: r = Int(Rnd * 90 + 9): d(i) = d(i - 1) + r: Color i: Print r: Next: Color 15: Print "SUM= "; d(N)
  4. For i = 1 To N: d(i) = d(i) / d(N) * _Pi(2): If d(i) >= _Pi(2) Then d(i) = _Pi(2) - .0001 ' wow circle is really frick'n picky!!!
  5.     Next: For j = 0 To 200 Step .25: For i = 1 To N
  6.         If (i Mod 2) = 0 Then Circle (320, 240), j, i, d(i - 1), d(i)
  7.         If (i Mod 2) = 1 Then Circle (320, 240), 200 - j, i, d(i - 1), d(i)
  8.  

Marked as best answer by DANILIN on November 16, 2021, 08:13:23 am

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: Russian Circle Diagram
« Reply #12 on: November 15, 2021, 09:09:35 pm »
In case the above is too dense and obscure, I removed all the double parking with colons and commented statement by statement:
Code: QB64: [Select]
  1. 'diagout.bas  Russian Circle Diagram   b+ mod overhaul Danilin's 2021-11-15
  2. N = 12 '                    Number of pie slices or data items
  3. Dim d(N) '                  Store our random items, d(i) first stores totals that are converted to RadianAngles for arcs.
  4. Screen 12 '                 Allows graphics like Circle (x, y), radius, color, startRadianForArc, stopRadianForArc
  5. Randomize Timer '           New set each time for 1,000,000 times
  6. For i = 1 To N '            For each data item
  7.     r = Int(Rnd * 90 + 9) ' Pick random  number 9 to 89, +9 guarantees at least 9, INT(rnd*90) = 0 to 89, so 9 to 98 max
  8.     d(i) = d(i - 1) + r '   Add last total to this with new item
  9.     Color i '               Color code by i = index number
  10.     Print r '               Show each item and it's color
  11. Color 15 ' White, not used by any other item
  12. Print "SUM= "; d(N) '       Sum is last total with all data items
  13. For i = 1 To N
  14.     d(i) = d(i) / d(N) * _Pi(2) ' convert d(i) to a fraction of a circle and multiply by 2*Pi to convert to angle in radians
  15.     If d(i) >= _Pi(2) Then d(i) = _Pi(2) - .0001 ' wow circle is really frick'n picky!!!
  16.     ' Circle wont do stop Angle < start angle, that happens with imprecise math and 1 converted to something > 2*Pi
  17.     ' This was big headache until I isolated which number was not working in Circle.
  18. For j = 0 To 200 Step .25 ' .25 to avoid holes between arcs
  19.     For i = 1 To N ' drawing arcs from d(i-1) to d(i) at j radii
  20.         'ref:               Circle (x,y),radius, color, startRadianForArc, stopRadianForArc
  21.         If (i Mod 2) = 0 Then Circle (320, 240), j, i, d(i - 1), d(i) '          inside out
  22.         If (i Mod 2) = 1 Then Circle (320, 240), 200 - j, i, d(i - 1), d(i) ' outside in
  23.     Next
  24.     _Delay .016 '           to show the build either outside in or inside out
  25.  
  26.  

« Last Edit: November 15, 2021, 09:15:09 pm by bplus »

Offline DANILIN

  • Forum Regular
  • Posts: 128
    • Danilin youtube
Re: Russian Circle Diagram
« Reply #13 on: January 22, 2022, 04:31:05 am »
Visualization resembles theory:

60kB 
pirasun55.gif


LAYERS of DECEPTION and WE

Pyramid: visualization is convenient in many areas

Belonging to a minority in pyramid does not make it higher

Narrow layers of pyramid can be higher or lower
wide layers of pyramid and it is always possible
to depict any number of them as a trapezoid inside pyramid

Looking at visually multi colored layered pyramids
being in one pyramid above it is possible to be same people
in a different environment in another pyramid in layer below

New visualization: a ball where pyramids are like spikes
where each turn of ball brings up 1 pyramid
and makes maxima of vertices of other pyramids lower

Almost at top of pyramids capable of deceiving
located higher up in a separate pyramid and deception
requires more information than deceived ones

Other visualization: lever and torque

Product of force on shoulder creates a moment and knowing
moment and lever are calculated as an increase in force
and force field is plotted on inverse function graph

Curves of constant products of different points are obtained
viewpoints that differ vertically and horizontally

To understand vertically it is important to have more
information and be an outstanding person such as
a billionaire or a minister or a champion or a scientist

But horizontally same secret data can really
be thought out by yourself without slightest hints
possibly spending more time

3 kB 
sloi.PNG
Russia looks world from future. big data is peace data.
https://youtube.com/playlist?list=PLBBTP9oVY7IagpH0g9FNUQ8JqmHwxDDDB
i never recommend anything to anyone and always write only about myself