Author Topic: Garland of pearls  (Read 13436 times)

0 Members and 1 Guest are viewing this topic.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Garland of pearls
« Reply #15 on: March 23, 2022, 08:30:34 pm »
There is much more to it than interesting!
I asked the question on a Hungarian physics forum on facebook. If there is a meaningful answer, I will inform you! It needs to be addressed!

Hello !
It will be a little longer now. I want an answer to a question I haven't been able to sleep in days :)
Anyone who follows the group may know that I am involved in programming. It used to be machine control, more recently the math behind games. (Interestingly, behind the game programming are the most outdated applications of mathematics)
My recent creations:


I have only considered it important to note this now because I have been dealing with them feverishly lately. The basic development environment, in which I program, can only draw 1 triangle on the screen. That's why I wrote the graphic "engine", the camera movement, the physical background of the movements myself. This developer is so unpopular that I don't think QB64 is known in Hungary. I like to be active in a foreign forum because there are about a handful of people (a handful on a global scale) who struggle with this outdated developer and appreciate it.
Here a forum member wrote a simulation of a pendulum motion. This should be imagined as a fixed point + rigid connector + some weight + rigid connector + some weight .... What happens if we push? He returned the thing quite realistically on the screen. It’s some crazy math, a lot of computation, and limited because it works with 2 “weights,” and with 3, but 4 or more has so much computation that it crumbles all over and can’t be shown in real time.
I had an idea then. What if we created points in space / plane without giving it fixed coordinates. All you need to know about that point is that it is located relative to another point. There should be nothing else for that point other than to strive to maintain its relation to the other point specified.
Do this: "current situation" = "current situation" + ("where you should be" - "current situation") x "all"
This is important here. If "all" is 0, no change is made. If 1, an immediate change occurs. If all are between 0 and 1, it gives a proportionality to the dynamics / flexibility / speed of change.
Now I want to express the point somehow. Imagine a "space." It contains objects. Objects are defined by point clouds. In point clouds, we make connections between points. To an adjacent, or object center, or just a smooth random point, we connect the 1 given point within the point cloud that we just want to define, "smart." We determine for him how far away he should be from that other point ... We will try to make as many such "connections" as possible at all points in that point and that object so that he is as smart as possible and will know "where he is. ".
If this is the case, start the "simulation"! Suppose thousands of points are defined as above. Each point begins to move at such a speed / direction that the connections assigned to it can be fulfilled. All right, we're waiting ... after a while, all movement will stop. "system balanced". The shapes are nicely outlined in front of us.
Now move only 1 out of position !!! that is, ONE point !!!!!!!! This will affect the points you are connected to ... and also the points you are connected to ... and those .... so everyone is running that 1 pulse. A mechanism is starting. Impulses give and take ...
The video shows how I programmed this principle differently. Chain, an image, and a cobweb. In each case, I gave relationships to the points as above. The thing works. And here comes the point. Smart people have already written the mathematical model for every event in Newtonian physics. Rigid-body, wave curves, collision of bodies, pendulum motion, centrifugal force .... what else to say ???????????????
This idea, which I did, completely bypasses the knowledge and use of these. The screen is fully functional. You don't need any physical knowledge or complications. We need a point and the strengths of its connections and connections (or how long we tie it to another point) (perhaps a metaphor for mass?)
Using the principle, we can in principle simulate all Newtonian physics by completely circumventing their use. Example..something .... if we create a brick wall based on the above principle, we can shoot a brick out of it so that the wall collapses in reality..etc ... that's just 1 of the many options.
Here's my question. Unfortunately, I did not study mathematics or physics at higher levels. I'm sure this thing isn't some kind of invention. This can only be new to me. This may be a known, existing theory that is also taught in good places. I would like to ask those who were so lucky to learn things like what it is? what is it used for where can i find writing about this
Thank you!

(just a small philosophical remark: if we hit the wall! the above principle would show the tiny vibration of every part of the wall. what if the above principle simulates the connection between molecules? since reality "renders" so fast that we can't even measure it with instruments, we're just amazed at the end result, because it happens so fast that we can't see, so we don't understand)
To download programs running under video (running under windows) with source code:
https://drive.google.com/file/d/1hkIqbFx_JGzhYpGdQjZ1h0lZYFtiw3Ce/view?usp=sharing



Ha! I don't think a spring connects every particle with every other but makes an interesting computer experiment.
Code: QB64: [Select]
  1. _Title "Mouse down, drag ball, release...  Boing" 'B+ 2019-01-08 from
  2. 'boing.bas for SmallBASIC 2015-07-25 MGA/B+
  3. 'coloring mods
  4.  
  5. Const xmax = 1200
  6. Const ymax = 700
  7. Screen _NewImage(xmax, ymax, 32)
  8.  
  9. Dim s(1 To 4, 1 To 2)
  10. s(1, 1) = 0: s(1, 2) = 50
  11. s(2, 1) = 0: s(2, 2) = ymax - 50
  12. s(3, 1) = xmax + 30: s(3, 2) = 50
  13. s(4, 1) = xmax + 30: s(4, 2) = ymax - 50
  14. oldtx = 0: oldtyty = 0: da = .03
  15. boingx = 0: boingy = 0
  16.     mb = _MouseButton(1)
  17.     If mb Then
  18.         tx = _MouseX + 20
  19.         ty = _MouseY
  20.     Else
  21.         tx = xmax / 2
  22.         ty = ymax / 2
  23.         If tx <> oldtx Or ty <> oldty Then
  24.             boingx = 3 * (tx - oldtx) / 4
  25.             boingy = 3 * (ty - oldty) / 4
  26.         Else
  27.             boingx = -3 * boingx / 4
  28.             boingy = -3 * boingy / 4
  29.         End If
  30.         tx = tx + boingx
  31.         ty = ty + boingy
  32.     End If
  33.     a = 0
  34.     oldtx = tx
  35.     oldty = ty
  36.     Cls
  37.     For corner = 1 To 4
  38.         s1x = s(corner, 1)
  39.         s1y = s(corner, 2)
  40.         dx = (tx - s1x) / 2000
  41.         dy = (ty - s1y) / 2000
  42.         x = tx - 20
  43.         y = ty
  44.         For i = 1 To 2000
  45.             sx = 20 * Cos(a) + x
  46.             sy = 20 * Sin(a) + y
  47.             Line (sx, sy + 5)-(sx + 4, sy + 5), _RGB32(118, 118, 118), BF
  48.             Line (sx, sy + 4)-(sx + 4, sy + 4), _RGB32(148, 148, 148), BF
  49.             Line (sx, sy + 3)-(sx + 4, sy + 3), _RGB32(238, 238, 238), BF
  50.             Line (sx, sy + 2)-(sx + 4, sy + 3), _RGB32(208, 208, 208), BF
  51.             Line (sx, sy + 1)-(sx + 4, sy + 1), _RGB32(168, 168, 168), BF
  52.             Line (sx, sy)-(sx + 4, sy), _RGB32(108, 108, 108), BF
  53.             Line (sx, sy - 1)-(sx + 4, sy - 1), _RGB32(68, 68, 68), BF
  54.             x = x - dx: y = y - dy
  55.             a = a + da
  56.         Next
  57.     Next
  58.     For r = 50 To 1 Step -1
  59.         g = (50 - r) * 5 + 5
  60.         Color _RGB32(g, g, g)
  61.         fcirc tx - 20, ty, r
  62.     Next
  63.     _Display
  64.     _Limit 15
  65.  
  66. 'Steve McNeil's  copied from his forum   note: Radius is too common a name
  67. Sub fcirc (CX As Long, CY As Long, R As Long)
  68.     Dim subRadius As Long, RadiusError As Long
  69.     Dim X As Long, Y As Long
  70.  
  71.     subRadius = Abs(R)
  72.     RadiusError = -subRadius
  73.     X = subRadius
  74.     Y = 0
  75.  
  76.     If subRadius = 0 Then PSet (CX, CY): Exit Sub
  77.  
  78.     ' Draw the middle span here so we don't draw it twice in the main loop,
  79.     ' which would be a problem with blending turned on.
  80.     Line (CX - X, CY)-(CX + X, CY), , BF
  81.  
  82.     While X > Y
  83.         RadiusError = RadiusError + Y * 2 + 1
  84.         If RadiusError >= 0 Then
  85.             If X <> Y + 1 Then
  86.                 Line (CX - Y, CY - X)-(CX + Y, CY - X), , BF
  87.                 Line (CX - Y, CY + X)-(CX + Y, CY + X), , BF
  88.             End If
  89.             X = X - 1
  90.             RadiusError = RadiusError - X * 2
  91.         End If
  92.         Y = Y + 1
  93.         Line (CX - X, CY - Y)-(CX + X, CY - Y), , BF
  94.         Line (CX - X, CY + Y)-(CX + X, CY + Y), , BF
  95.     Wend
  96.  
  97.  

@MasterGy try and get some sleep.
« Last Edit: March 23, 2022, 08:37:52 pm by bplus »

Offline jack

  • Seasoned Forum Regular
  • Posts: 408
    • View Profile
Re: Garland of pearls
« Reply #16 on: March 24, 2022, 09:28:11 am »
To download programs running under video (running under windows) with source code:
https://drive.google.com/file/d/1hkIqbFx_JGzhYpGdQjZ1h0lZYFtiw3Ce/view?usp=sharing
I get an error from google not allowing me to download, is there another way you can share your creations?
btw, the programs you presented in this thread are fantastic! :)

Offline MasterGy

  • Seasoned Forum Regular
  • Posts: 327
  • people lie, math never lies
    • View Profile
Re: Garland of pearls
« Reply #17 on: April 03, 2022, 02:57:42 pm »
I'm very interested in this thing. Unfortunately I had little time, the season started. The above programs work in 2d. I started simulating the behavior of points in 3d. The goal would be collisions. I would like to see what I have described above. For now, you can see that it works nicely in 3D as well. Stretched mesh, gravity, WASD + mouse like in games. Use the space bar to move 1 point out of place. All other points will then respond and the system will attempt to return to the idle state.

Code: QB64: [Select]
  1. mouse_sens = .5
  2. tightness = 2
  3. gravity = .005
  4. lass = .94
  5. power = -0.3
  6.  
  7.  
  8.  
  9. CONST pip180 = 3.141592 / 180
  10. DIM SHARED monx, mony: monx = 800: mony = monx / _DESKTOPWIDTH * _DESKTOPHEIGHT: mon = _NEWIMAGE(monx, mony, 32): SCREEN mon: _FULLSCREEN: _MOUSEHIDE
  11.  
  12. DIM SHARED points_c_arr, conn_c_arr
  13. points_c_arr = 2000
  14. conn_c_arr = 2000
  15.  
  16. DIM SHARED points(points_c_arr, 19), conn(conn_c_arr, 9), cam(19), me(19), conn_c, points_c
  17.  
  18.  
  19. make_grid 1, -10, -10, 10, 10, -10, 0, -10, 10, 0, 10, 10, 0, 1.2
  20.  
  21.  
  22.  
  23.  
  24.  
  25. 'make_sphere 2, 0, 10, 0, 5, 8 'ident,X,Y,Z,RAD,POINTS
  26.  
  27.     'control
  28.     mousex = 0: mousey = 0: mw = 0: WHILE _MOUSEINPUT: mousex = mousex + _MOUSEMOVEMENTX: mousey = mousey + _MOUSEMOVEMENTY: mw = mw + _MOUSEWHEEL: WEND
  29.     k_left = _KEYDOWN(19200) OR _KEYDOWN(ASC("a")): k_right = _KEYDOWN(19712) OR _KEYDOWN(ASC("d"))
  30.     k_up = _KEYDOWN(18432) OR _KEYDOWN(ASC("w")): k_down = _KEYDOWN(20480) OR _KEYDOWN(ASC("s"))
  31.     me(2) = me(2) + mw: me(3) = me(3) - mousex * mouse_sens: me(4) = me(4) + mousey * mouse_sens: IF ABS(me(4)) > 80 THEN me(4) = 80 * SGN(me(4))
  32.     go = -.5 * ABS(k_left OR k_right OR k_up OR k_down): go_ang = -90 * (k_left - k_right) + (me(3)) - 90
  33.     ang1 = go_ang * pip180: ang2 = (90 - me(4)) * pip180: IF k_down THEN go = -go
  34.     me(0) = me(0) + SIN(ang2) * COS(ang1) * go: me(1) = me(1) + SIN(ang2) * SIN(ang1) * go: me(2) = me(2) + COS(ang2) * go
  35.     FOR t = 0 TO 9: cam(t) = me(t): NEXT t: cam(13) = cam(3) * pip180: cam(14) = cam(4) * pip180
  36.  
  37.  
  38.  
  39.     'calculate moving
  40.  
  41.     FOR a = 0 TO points_c_arr - 1: FOR t = 0 TO 2: points(a, 11 + t) = points(a, t): NEXT t: IF (points(a, 14) = 0 OR points(a, 6) = 0) THEN _CONTINUE
  42.  
  43.         'connections vector
  44.         vec(0) = 0: vec(1) = 0: vec(2) = 0: vec_c = 0
  45.         FOR t = 0 TO conn_c - 1: IF conn(t, 3) = 0 THEN _CONTINUE
  46.             x = -1: FOR t2 = 0 TO 1: IF conn(t, t2) = a THEN x = conn(t, t2 XOR 1)
  47.             NEXT t2
  48.             IF x <> -1 THEN
  49.                 FOR av = 0 TO 2: disv = points(a, av) - points(x, av): vec(av) = vec(av) + ((ABS(disv) - conn(t, 4 + av))) * SGN(disv) * power
  50.                 NEXT av: vec_c = vec_c + 1
  51.             END IF
  52.         NEXT t
  53.  
  54.         FOR av = 0 TO 2: points(a, 3 + av) = (points(a, 3 + av) + vec(av) / vec_c) * lass: NEXT av: points(a, 4) = points(a, 4) - gravity
  55.         FOR av = 0 TO 2: points(a, 11 + av) = points(a, av) + points(a, 3 + av): NEXT av
  56.     NEXT a
  57.  
  58.     FOR a = 0 TO points_c_arr - 1: FOR t = 0 TO 2: points(a, t) = points(a, 11 + t): NEXT t, a
  59.  
  60.     inkey2$ = INKEY$
  61.     IF inkey2$ = " " THEN
  62.         DO: a = INT(points_c_arr * RND(1)): LOOP UNTIL points(a, 14) AND points(a, 6)
  63.         rand = 30: FOR t = 0 TO 2: points(a, t) = points(a, t) + rand * RND(1) - rand / 2: NEXT t
  64.     END IF
  65.  
  66.     'calculating points
  67.     FOR ap = 0 TO points_c_arr - 1: IF points(ap, 6) = 0 THEN _CONTINUE
  68.         points(ap, 8) = points(ap, 0): points(ap, 9) = points(ap, 1): points(ap, 10) = points(ap, 2)
  69.     rotate_display points(ap, 8), points(ap, 9), points(ap, 10): NEXT ap
  70.  
  71.     'draw connections
  72.     FOR ac = 0 TO conn_c_arr - 1: IF conn(ac, 3) = 0 THEN _CONTINUE
  73.         FOR t1 = 0 TO 1: FOR t2 = 0 TO 2: coo(t1, t2) = points(conn(ac, t1), 8 + t2): NEXT t2, t1
  74.         line_3d coo(0, 0), coo(0, 1), coo(0, 2), coo(1, 0), coo(1, 1), coo(1, 2)
  75.     NEXT ac
  76.  
  77.     'fix points draw signal
  78.     FOR ap = 0 TO points_c_arr - 1: IF points(ap, 6) = 0 OR points(ap, 14) OR points(ap, 10) > -1 THEN _CONTINUE
  79.         FOR t2 = 0 TO 2: coo(0, t2) = points(ap, 8 + t2): NEXT t2
  80.         point3d_to_pset coo(0, 0), coo(0, 1), coo(0, 2): CIRCLE (coo(0, 0), coo(0, 1)), 12000 / coo(0, 2)
  81.     NEXT ap
  82.  
  83.     COLOR _RGB32(200, 200, 200): LOCATE mony / 16 - 2: PRINT "WASD+mouse      SPACE - impulse to a random point ";
  84.     _DISPLAY
  85.     CLS
  86.  
  87.  
  88. SUB line_3d (x0, y0, z0, x1, y1, z1)
  89.     IF z0 < -1 AND z1 < -1 THEN point3d_to_pset x0, y0, z0: point3d_to_pset x1, y1, z1: LINE (x0, y0)-(x1, y1)
  90.  
  91. SUB point3d_to_pset (x, y, z): multi = 400: zlimit = -2: x = monx / 2 + (x + zlimit) / -z * multi: y = mony / 2 + (y + zlimit) / z * multi
  92.     grey = 255 - ABS(z) * .1: IF grey < 10 THEN grey = 10
  93.     COLOR _RGB32(grey, grey, grey)
  94.  
  95. SUB make_grid (acc, x0, y0, z0, x1, y1, z1, x2, y2, z2, x3, y3, z3, res): p_start = points_c
  96.     resA = INT((dis(x0 - x1, y0 - y1, z0 - z1) + dis(x2 - x3, y2 - y3, z2 - z3)) / 2 / res)
  97.     resB = INT((dis(x0 - x2, y0 - y2, z0 - z2) + dis(x1 - x3, y1 - y3, z1 - z3)) / 2 / res)
  98.     FOR a = 0 TO resA - 1: n = 1 / resA * a
  99.         tx1 = scale(x0, x1, n): ty1 = scale(y0, y1, n): tz1 = scale(z0, z1, n): tx2 = scale(x2, x3, n): ty2 = scale(y2, y3, n): tz2 = scale(z2, z3, n)
  100.         FOR b = 0 TO resB - 1: n = 1 / resB * b: l = p_start + b * resA + a
  101.             points(l, 0) = scale(tx1, tx2, n): points(l, 2) = scale(ty1, ty2, n): points(l, 1) = scale(tz1, tz2, n)
  102.             points(l, 6) = 1: points(l, 7) = acc: points(l, 14) = 1: IF (a = 0 OR a = resA - 1) AND (b = 0 OR b = resB - 1) THEN points(l, 14) = 0
  103.     NEXT b, a
  104.     FOR ty = 0 TO resB - 1: FOR tx = 0 TO resA - 2: p1 = tx + ty * resA: conn_add p1, p1 + 1, tightness: NEXT tx, ty
  105.     FOR tx = 0 TO resA - 1: FOR ty = 0 TO resB - 2: p1 = tx + ty * resA: conn_add p1, p1 + resA, tightness: NEXT ty, tx
  106.     points_c = points_c + resA * resB
  107.  
  108. FUNCTION dis (a, b, c): dis = SQR(a * a + b * b + c * c): END FUNCTION
  109. FUNCTION scale (a, b, n): scale = a + (b - a) * n: END FUNCTION
  110. SUB conn_add (p1, p2, tightness): IF p1 = p2 THEN EXIT SUB
  111.     FOR t = 0 TO conn_c_arr - 1: IF (conn(t, 0) = p1 AND conn(t, 1) = p2) OR (conn(t, 0) = p2 AND conn(t, 1) = p1) THEN EXIT SUB
  112.     NEXT t: REDIM disx(2): conn(conn_c, 0) = p1: conn(conn_c, 1) = p2
  113.     FOR t = 0 TO 2: conn(conn_c, 4 + t) = (ABS(points(p1, t) - points(p2, t))) * tightness: NEXT t
  114.     conn(conn_c, 2) = dis(conn(conn_c, 4), conn(conn_c, 5), conn(conn_c, 6)): conn(conn_c, 3) = 1: conn_c = conn_c + 1
  115. SUB rotate_2d (x, y, ang): x1 = x * COS(ang) - y * SIN(ang): y1 = x * SIN(ang) + y * COS(ang): x = x1: y = y1: END SUB
  116. SUB rotate_display (x, y, z)
  117.     x = (x - cam(0)) * 100: y = (y - cam(2)) * 100: z = -(z - cam(1)) * 100: rotate_2d x, z, cam(13): rotate_2d y, z, cam(14)
  118. FUNCTION degree (a, b): degreex = ATN(a / (b + .00001)) / pip180: degreex = degreex - 180 * ABS(0 > b): degreex = degreex - 360 * (degreex < 0): degree = degreex: END FUNCTION
  119.  
  120.  
  121.  
  122.  
  123.  
  124. 'POINTS array
  125. '0,1,2 : X,Y,Z
  126. '3,4,5 : X,Y,Z vector
  127. '6:active 7:identifier
  128. '8,9,10 :X,Y,Z calculated to maptriangle
  129. '11,12,13 :X,Y,Z moving temporary calculating
  130. '14: 0:FIX 1:MOVING
  131.  
  132.  
  133. 'CONN array
  134. '0:point#1
  135. '1:point#2
  136. '2:distance
  137. '3:active
  138. '4:disX
  139. '5:disY
  140. '6:disZ
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  

Offline MasterGy

  • Seasoned Forum Regular
  • Posts: 327
  • people lie, math never lies
    • View Profile
Re: Garland of pearls
« Reply #18 on: April 05, 2022, 03:32:44 pm »
I added another curiosity. (but I haven't covered the point yet)
I recently had a question with _MAPTRIANGLE that calculates 2d points. I wanted to know so I could move with a mouse in 3d. This has now been achieved with a simple solution.
Stretched mesh in 3d. Walkable with WASD + mouse like in 3D games. If you press the Q key, you can grab the point with the mouse and move it. You can nail it with the SPACE key.



Code: QB64: [Select]
  1. mouse_sens = .5
  2. tightness = 1
  3. gravity = .005
  4. lass = .94
  5. power = -0.3
  6. adj = .8 'moving speed 3d point mouse
  7.  
  8.  
  9. CONST pip180 = 3.141592 / 180
  10. DIM SHARED monx, mony: monx = 800: mony = monx / _DESKTOPWIDTH * _DESKTOPHEIGHT: mon = _NEWIMAGE(monx, mony, 32): SCREEN mon: _FULLSCREEN: _MOUSEHIDE
  11.  
  12. DIM SHARED points_c_arr, conn_c_arr
  13. points_c_arr = 2000
  14. conn_c_arr = 2000
  15.  
  16. DIM SHARED points(points_c_arr, 19), conn(conn_c_arr, 9), cam(19), me(19), conn_c, points_c
  17.  
  18.  
  19. make_grid 1, -10, -10, 10, 10, -10, 0, -10, 10, 0, 10, 10, 0, 1.5
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.     'control
  27.     mousex = 0: mousey = 0: mw = 0: WHILE _MOUSEINPUT: mousex = mousex + _MOUSEMOVEMENTX: mousey = mousey + _MOUSEMOVEMENTY: mw = mw + _MOUSEWHEEL: WEND
  28.     k_left = _KEYDOWN(19200) OR _KEYDOWN(ASC("a")): k_right = _KEYDOWN(19712) OR _KEYDOWN(ASC("d")): inkey2$ = INKEY$: IF inkey2$ = CHR$(27) THEN END
  29.     k_up = _KEYDOWN(18432) OR _KEYDOWN(ASC("w")): k_down = _KEYDOWN(20480) OR _KEYDOWN(ASC("s")): key_take = _KEYDOWN(ASC("q"))
  30.     me(2) = me(2) + mw: IF key_take THEN _MOUSESHOW ELSE _MOUSEHIDE
  31.     IF key_take = 0 THEN me(3) = me(3) - mousex * mouse_sens: me(4) = me(4) + mousey * mouse_sens: IF ABS(me(4)) > 80 THEN me(4) = 80 * SGN(me(4))
  32.     go = -.5 * ABS(k_left OR k_right OR k_up OR k_down): go_ang = -90 * (k_left - k_right) + (me(3)) - 90
  33.     ang1 = go_ang * pip180: ang2 = (90 - me(4)) * pip180: IF k_down THEN go = -go
  34.     me(0) = me(0) + SIN(ang2) * COS(ang1) * go: me(1) = me(1) + SIN(ang2) * SIN(ang1) * go: me(2) = me(2) + COS(ang2) * go
  35.     FOR t = 0 TO 9: cam(t) = me(t): NEXT t: cam(13) = cam(3) * pip180: cam(14) = cam(4) * pip180
  36.  
  37.  
  38.  
  39.     'calculate moving
  40.     FOR a = 0 TO points_c_arr - 1: FOR t = 0 TO 2: points(a, 11 + t) = points(a, t): NEXT t
  41.         IF (points(a, 14) = 0 OR points(a, 6) = 0) OR a = take_moving THEN _CONTINUE
  42.  
  43.         'connections vector
  44.         vec(0) = 0: vec(1) = 0: vec(2) = 0: vec_c = 0
  45.         FOR t = 0 TO conn_c - 1: IF conn(t, 3) = 0 THEN _CONTINUE
  46.             x = -1: FOR t2 = 0 TO 1: IF conn(t, t2) = a THEN x = conn(t, t2 XOR 1)
  47.             NEXT t2
  48.             IF x <> -1 THEN
  49.                 FOR av = 0 TO 2: disv = points(a, av) - points(x, av): vec(av) = vec(av) + ((ABS(disv) - conn(t, 4 + av))) * SGN(disv) * power
  50.                 NEXT av: vec_c = vec_c + 1
  51.             END IF
  52.         NEXT t
  53.  
  54.         FOR av = 0 TO 2: points(a, 3 + av) = (points(a, 3 + av) + vec(av) / vec_c) * lass: NEXT av: points(a, 4) = points(a, 4) - gravity
  55.         FOR av = 0 TO 2: points(a, 11 + av) = points(a, av) + points(a, 3 + av): NEXT av
  56.     NEXT a
  57.  
  58.     FOR a = 0 TO points_c_arr - 1: FOR t = 0 TO 2: points(a, t) = points(a, 11 + t): NEXT t, a
  59.  
  60.  
  61.  
  62.     'calculating points
  63.     FOR ap = 0 TO points_c_arr - 1: IF points(ap, 6) = 0 THEN _CONTINUE
  64.         points(ap, 8) = points(ap, 0): points(ap, 9) = points(ap, 1): points(ap, 10) = points(ap, 2)
  65.         rotate_display points(ap, 8), points(ap, 9), points(ap, 10)
  66.         FOR t = 0 TO 2: points(ap, 15 + t) = points(ap, 8 + t): NEXT t: point3d_to_pset points(ap, 15), points(ap, 16), points(ap, 17)
  67.     NEXT ap
  68.  
  69.     'draw connections
  70.     FOR ac = 0 TO conn_c_arr - 1: IF conn(ac, 3) = 0 THEN _CONTINUE
  71.         FOR t1 = 0 TO 1: FOR t2 = 0 TO 2: coo(t1, t2) = points(conn(ac, t1), 15 + t2): NEXT t2, t1
  72.         IF points(conn(ac, 0), 10) < -1 AND points(conn(ac, 1), 10) < -1 THEN
  73.             LINE (coo(0, 0), coo(0, 1))-(coo(1, 0), coo(1, 1)), _RGB32(coo(0, 2), coo(0, 2), coo(0, 2))
  74.         END IF
  75.     NEXT ac
  76.  
  77.     'fix points draw signal
  78.     FOR ap = 0 TO points_c_arr - 1: IF points(ap, 6) = 0 OR points(ap, 14) OR points(ap, 10) > -1 THEN _CONTINUE
  79.         CIRCLE (points(ap, 15), points(ap, 16)), 12000 / points(ap, 10), _RGB32(points(ap, 17), points(ap, 17), points(ap, 17))
  80.     NEXT ap
  81.  
  82.     'take point with mouse
  83.     IF key_take AND take_moving = -1 THEN
  84.         take_sens = monx * 0.01: mindis = 999999: take = -1
  85.         FOR ap = 0 TO points_c_arr - 1: IF points(ap, 6) = 0 OR points(ap, 10) > -1 THEN _CONTINUE
  86.             disx = ABS(_MOUSEX - points(ap, 15)): IF disx > take_sens THEN _CONTINUE
  87.             disy = ABS(_MOUSEY - points(ap, 16)): IF disy > take_sens THEN _CONTINUE
  88.             disv = dis(disx, disy, 0): IF disv > take_sens OR disv > mindis THEN _CONTINUE
  89.         take = ap: mindis = disv: NEXT ap: IF take <> -1 THEN CIRCLE (points(take, 15), points(take, 16)), 5000 / points(take, 10), _RGB32(255, 0, 0)
  90.     END IF
  91.     IF _MOUSEBUTTON(1) = 0 OR key_take = 0 THEN take_moving = -1
  92.     IF key_take AND _MOUSEBUTTON(1) AND take_moving = -1 AND take <> -1 THEN take_moving = take: dis_take = dis(points(take, 8), points(take, 9), points(take, 10))
  93.     IF take <> -1 AND inkey2$ = " " THEN points(take, 14) = points(take, 14) XOR 1
  94.  
  95.     'move with mouse 3d point
  96.     IF take_moving <> -1 THEN
  97.         IF dis(_MOUSEX - points(take_moving, 15), _MOUSEY - points(take_moving, 16), 0) > 20 THEN
  98.             mindis = 99999: FOR ang1 = 0 TO 360 * pip180 STEP 10 * pip180: FOR ang2 = 0 TO 180 * pip180 STEP 10 * pip180
  99.                     px = points(take_moving, 0) + adj * SIN(ang2) * COS(ang1): py = points(take_moving, 1) + adj * SIN(ang2) * SIN(ang1)
  100.                     pz = points(take_moving, 2) + adj * COS(ang2): vx = px: vy = py: vz = pz
  101.                     rotate_display vx, vy, vz: IF ABS(dis(vx, vy, vz) - dis_take) > 300 THEN _CONTINUE
  102.                     point3d_to_pset vx, vy, vz: disx = dis(_MOUSEX - vx, _MOUSEY - vy, 0)
  103.                     IF disx < mindis THEN mindis = disx: cx = px: cy = py: cz = pz
  104.             NEXT ang2, ang1: points(take_moving, 0) = cx: points(take_moving, 1) = cy: points(take_moving, 2) = cz
  105.         END IF
  106.     END IF
  107.  
  108.     mess$ = "moving WASD+mouse      Q-key fixing and moving point"
  109.     IF key_take THEN mess$ = "SPACE-fix/float point  MOUSEBUTTON - hold point"
  110.     IF take_moving <> -1 THEN mess$ = "moving the point with mouse"
  111.     COLOR _RGB32(200, 200, 200): LOCATE mony / 16 - 2: PRINT mess$;
  112.     _DISPLAY
  113.     CLS
  114.  
  115.  
  116. SUB point3d_to_pset (x, y, z): zlimit = -2: x = monx * .5 + (x + zlimit) / -z * 400: y = mony * .5 + (y + zlimit) / z * 400
  117.     z = 255 - ABS(z) * .1: IF z < 10 THEN grey = 10
  118.  
  119. SUB make_grid (acc, x0, y0, z0, x1, y1, z1, x2, y2, z2, x3, y3, z3, res): p_start = points_c
  120.     resA = INT((dis(x0 - x1, y0 - y1, z0 - z1) + dis(x2 - x3, y2 - y3, z2 - z3)) / 2 / res)
  121.     resB = INT((dis(x0 - x2, y0 - y2, z0 - z2) + dis(x1 - x3, y1 - y3, z1 - z3)) / 2 / res)
  122.     FOR a = 0 TO resA - 1: n = 1 / resA * a
  123.         tx1 = scale(x0, x1, n): ty1 = scale(y0, y1, n): tz1 = scale(z0, z1, n): tx2 = scale(x2, x3, n): ty2 = scale(y2, y3, n): tz2 = scale(z2, z3, n)
  124.         FOR b = 0 TO resB - 1: n = 1 / resB * b: l = p_start + b * resA + a
  125.             points(l, 0) = scale(tx1, tx2, n): points(l, 2) = scale(ty1, ty2, n): points(l, 1) = scale(tz1, tz2, n)
  126.             points(l, 6) = 1: points(l, 7) = acc: points(l, 14) = 1: IF (a = 0 OR a = resA - 1) AND (b = 0 OR b = resB - 1) THEN points(l, 14) = 0
  127.     NEXT b, a
  128.     FOR ty = 0 TO resB - 1: FOR tx = 0 TO resA - 2: p1 = tx + ty * resA: conn_add p1, p1 + 1, tightness: NEXT tx, ty
  129.     FOR tx = 0 TO resA - 1: FOR ty = 0 TO resB - 2: p1 = tx + ty * resA: conn_add p1, p1 + resA, tightness: NEXT ty, tx
  130.     points_c = points_c + resA * resB
  131.  
  132. FUNCTION dis (a, b, c): dis = SQR(a * a + b * b + c * c): END FUNCTION
  133. FUNCTION scale (a, b, n): scale = a + (b - a) * n: END FUNCTION
  134. SUB conn_add (p1, p2, tightness): IF p1 = p2 THEN EXIT SUB
  135.     FOR t = 0 TO conn_c_arr - 1: IF (conn(t, 0) = p1 AND conn(t, 1) = p2) OR (conn(t, 0) = p2 AND conn(t, 1) = p1) THEN EXIT SUB
  136.     NEXT t: REDIM disx(2): conn(conn_c, 0) = p1: conn(conn_c, 1) = p2
  137.     FOR t = 0 TO 2: conn(conn_c, 4 + t) = (ABS(points(p1, t) - points(p2, t))) * tightness: NEXT t
  138.     conn(conn_c, 2) = dis(conn(conn_c, 4), conn(conn_c, 5), conn(conn_c, 6)): conn(conn_c, 3) = 1: conn_c = conn_c + 1
  139. SUB rotate_2d (x, y, ang): x1 = x * COS(ang) - y * SIN(ang): y1 = x * SIN(ang) + y * COS(ang): x = x1: y = y1: END SUB
  140. SUB rotate_display (x, y, z)
  141.     x = (x - cam(0)) * 100: y = (y - cam(2)) * 100: z = -(z - cam(1)) * 100: rotate_2d x, z, cam(13): rotate_2d y, z, cam(14)
  142. FUNCTION degree (a, b): degreex = ATN(a / (b + .00001)) / pip180: degreex = degreex - 180 * ABS(0 > b): degreex = degreex - 360 * (degreex < 0): degree = degreex: END FUNCTION
  143.  
  144.  
  145.  
  146.  
  147.  
  148. 'POINTS array
  149. '0,1,2 : XYZ
  150. '3,4,5 : XYZ vector
  151. '6:active 7:identifier
  152. '8,9,10 :XYZ calculated to maptriangle
  153. '11,12,13 :XYZ moving temporary calculating
  154. '14: 0:FIX 1:MOVING
  155. '15,16,17 2D-X,Y, greyscale
  156.  
  157.  
  158. 'CONN array
  159. '0:point#1
  160. '1:point#2
  161. '2:distance
  162. '3:active
  163. '4:disX
  164. '5:disY
  165. '6:disZ
  166.  
  167.  
  168.  
  169.  
  170.  
  171.