Home » Archimedes archive » Acorn User » AU 1998-08.adf » Regulars » StarInfo/Brobecker/SprngStrng

StarInfo/Brobecker/SprngStrng

This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.

Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.

Tape/disk: Home » Archimedes archive » Acorn User » AU 1998-08.adf » Regulars
Filename: StarInfo/Brobecker/SprngStrng
Read OK:
File size: 050B bytes
Load address: 0000
Exec address: 0000
File contents
   10REM>>> String constituted of springs
   20REM    Alain BROBECKER (baah/Arm's Tech) on ??-???-1997
   30MODE9:OFF:ORIGIN640,512
   40n%=15       :REMnb of points-1
   50nl=8        :REMsprings' neutral length
   60k=0.1       :REMsprings' stiffness
   70a=.95       :REMabsorption
   80g=-0.5      :REMgravity
   90w%=512      :REMwall position
  100DIMx(n%),y(n%),vx(n%),vy(n%),ax(n%),ay(n%)
  110vx()=0:vy()=0
  120REMcreate object
  130FORc%=0TOn%:x(c%)=0:y(c%)=-nl*c%:NEXT
  140
  150b%=1        :REMscreenbank
  160REPEAT
  170 WAIT:SYS"OS_Byte",&71,b%:b%=b%EOR3:SYS"OS_Byte",&70,b%:CLS
  180 GCOL1:MOVEx(0),y(0):FORc%=1TOn%:DRAWx(c%),y(c%):NEXT
  190 GCOL7:FORc%=0TOn%:POINTx(c%),y(c%):NEXTc%
  200 MOUSEx(0),y(0),z
  210 ax()=0:ay()=g
  220REMcompute force for each spring
  230 FORc%=0TOn%-1
  240  d%=c%+1
  250  dx=x(c%)-x(d%)
  260  dy=y(c%)-y(d%)
  270  l=SQR(dx^2+dy^2)
  280  IFl<>0THEN
  290   ax=(nl-l)*k*dx/l
  300   ay=(nl-l)*k*dy/l
  310   ax(c%)+=ax:ax(d%)-=ax
  320   ay(c%)+=ay:ay(d%)-=ay
  330  ENDIF
  340 NEXT
  350 ax(0)=0:ay(0)=0        :REMFirst point controlled by mouse.
  360REMcompute movements for each point
  370 FORc%=0TOn%
  380  vx(c%)=vx(c%)*a+ax(c%)
  390  vy(c%)=(vy(c%)-ay(c%))*a+2*ay(c%) :REMno absorption of gravity
  400  x(c%)+=vx(c%)
  410  y(c%)+=vy(c%)
  420  IFx(c%)<-w%THENx(c%)=-w%:vx(c%)=-vx(c%)
  430  IFx(c%)>w%THENx(c%)=w%:vx(c%)=-vx(c%)
  440  IFy(c%)<-w%THENy(c%)=-w%:vy(c%)=-vy(c%)
  450  IFy(c%)>w%THENy(c%)=w%:vy(c%)=-vy(c%)
  460 NEXT
  470UNTILFALSE

&�>>> String constituted of springs
9�    Alain BROBECKER (baah/Arm's Tech) on ??-???-1997
�9:�:ȑ640,512
( n%=15       :�nb of points-1
2)nl=8        :�springs' neutral length
<$k=0.1       :�springs' stiffness
Fa=.95       :�absorption
Pg=-0.5      :�gravity
Zw%=512      :�wall position
d,�x(n%),y(n%),vx(n%),vy(n%),ax(n%),ay(n%)
nvx()=0:vy()=0
x�create object
�#�c%=0�n%:x(c%)=0:y(c%)=-nl*c%:�
�
�b%=1        :�screenbank
��
�7 Ȗ:ș"OS_Byte",&71,b%:b%=b%�3:ș"OS_Byte",&70,b%:�
�* �1:�x(0),y(0):�c%=1�n%:�x(c%),y(c%):�
�" �7:�c%=0�n%:Ȓx(c%),y(c%):�c%
� ȗx(0),y(0),z
� ax()=0:ay()=g
�"�compute force for each spring
� �c%=0�n%-1
�
  d%=c%+1
�  dx=x(c%)-x(d%)
  dy=y(c%)-y(d%)
  l=�(dx^2+dy^2)
  �l<>0�
"   ax=(nl-l)*k*dx/l
,   ay=(nl-l)*k*dy/l
6   ax(c%)+=ax:ax(d%)-=ax
@   ay(c%)+=ay:ay(d%)-=ay
J  �
T �
^> ax(0)=0:ay(0)=0        :�First point controlled by mouse.
h%�compute movements for each point
r
 �c%=0�n%
|  vx(c%)=vx(c%)*a+ax(c%)
�B  vy(c%)=(vy(c%)-ay(c%))*a+2*ay(c%) :�no absorption of gravity
�  x(c%)+=vx(c%)
�  y(c%)+=vy(c%)
�)  �x(c%)<-w%�x(c%)=-w%:vx(c%)=-vx(c%)
�'  �x(c%)>w%�x(c%)=w%:vx(c%)=-vx(c%)
�)  �y(c%)<-w%�y(c%)=-w%:vy(c%)=-vy(c%)
�'  �y(c%)>w%�y(c%)=w%:vy(c%)=-vy(c%)
� �
���
�
00000000  0d 00 0a 26 f4 3e 3e 3e  20 53 74 72 69 6e 67 20  |...&.>>> String |
00000010  63 6f 6e 73 74 69 74 75  74 65 64 20 6f 66 20 73  |constituted of s|
00000020  70 72 69 6e 67 73 0d 00  14 39 f4 20 20 20 20 41  |prings...9.    A|
00000030  6c 61 69 6e 20 42 52 4f  42 45 43 4b 45 52 20 28  |lain BROBECKER (|
00000040  62 61 61 68 2f 41 72 6d  27 73 20 54 65 63 68 29  |baah/Arm's Tech)|
00000050  20 6f 6e 20 3f 3f 2d 3f  3f 3f 2d 31 39 39 37 0d  | on ??-???-1997.|
00000060  00 1e 12 eb 39 3a 87 3a  c8 91 36 34 30 2c 35 31  |....9:.:..640,51|
00000070  32 0d 00 28 20 6e 25 3d  31 35 20 20 20 20 20 20  |2..( n%=15      |
00000080  20 3a f4 6e 62 20 6f 66  20 70 6f 69 6e 74 73 2d  | :.nb of points-|
00000090  31 0d 00 32 29 6e 6c 3d  38 20 20 20 20 20 20 20  |1..2)nl=8       |
000000a0  20 3a f4 73 70 72 69 6e  67 73 27 20 6e 65 75 74  | :.springs' neut|
000000b0  72 61 6c 20 6c 65 6e 67  74 68 0d 00 3c 24 6b 3d  |ral length..<$k=|
000000c0  30 2e 31 20 20 20 20 20  20 20 3a f4 73 70 72 69  |0.1       :.spri|
000000d0  6e 67 73 27 20 73 74 69  66 66 6e 65 73 73 0d 00  |ngs' stiffness..|
000000e0  46 1c 61 3d 2e 39 35 20  20 20 20 20 20 20 3a f4  |F.a=.95       :.|
000000f0  61 62 73 6f 72 70 74 69  6f 6e 0d 00 50 19 67 3d  |absorption..P.g=|
00000100  2d 30 2e 35 20 20 20 20  20 20 3a f4 67 72 61 76  |-0.5      :.grav|
00000110  69 74 79 0d 00 5a 1f 77  25 3d 35 31 32 20 20 20  |ity..Z.w%=512   |
00000120  20 20 20 3a f4 77 61 6c  6c 20 70 6f 73 69 74 69  |   :.wall positi|
00000130  6f 6e 0d 00 64 2c de 78  28 6e 25 29 2c 79 28 6e  |on..d,.x(n%),y(n|
00000140  25 29 2c 76 78 28 6e 25  29 2c 76 79 28 6e 25 29  |%),vx(n%),vy(n%)|
00000150  2c 61 78 28 6e 25 29 2c  61 79 28 6e 25 29 0d 00  |,ax(n%),ay(n%)..|
00000160  6e 11 76 78 28 29 3d 30  3a 76 79 28 29 3d 30 0d  |n.vx()=0:vy()=0.|
00000170  00 78 12 f4 63 72 65 61  74 65 20 6f 62 6a 65 63  |.x..create objec|
00000180  74 0d 00 82 23 e3 63 25  3d 30 b8 6e 25 3a 78 28  |t...#.c%=0.n%:x(|
00000190  63 25 29 3d 30 3a 79 28  63 25 29 3d 2d 6e 6c 2a  |c%)=0:y(c%)=-nl*|
000001a0  63 25 3a ed 0d 00 8c 04  0d 00 96 1c 62 25 3d 31  |c%:.........b%=1|
000001b0  20 20 20 20 20 20 20 20  3a f4 73 63 72 65 65 6e  |        :.screen|
000001c0  62 61 6e 6b 0d 00 a0 05  f5 0d 00 aa 37 20 c8 96  |bank........7 ..|
000001d0  3a c8 99 22 4f 53 5f 42  79 74 65 22 2c 26 37 31  |:.."OS_Byte",&71|
000001e0  2c 62 25 3a 62 25 3d 62  25 82 33 3a c8 99 22 4f  |,b%:b%=b%.3:.."O|
000001f0  53 5f 42 79 74 65 22 2c  26 37 30 2c 62 25 3a db  |S_Byte",&70,b%:.|
00000200  0d 00 b4 2a 20 e6 31 3a  ec 78 28 30 29 2c 79 28  |...* .1:.x(0),y(|
00000210  30 29 3a e3 63 25 3d 31  b8 6e 25 3a df 78 28 63  |0):.c%=1.n%:.x(c|
00000220  25 29 2c 79 28 63 25 29  3a ed 0d 00 be 22 20 e6  |%),y(c%):...." .|
00000230  37 3a e3 63 25 3d 30 b8  6e 25 3a c8 92 78 28 63  |7:.c%=0.n%:..x(c|
00000240  25 29 2c 79 28 63 25 29  3a ed 63 25 0d 00 c8 12  |%),y(c%):.c%....|
00000250  20 c8 97 78 28 30 29 2c  79 28 30 29 2c 7a 0d 00  | ..x(0),y(0),z..|
00000260  d2 12 20 61 78 28 29 3d  30 3a 61 79 28 29 3d 67  |.. ax()=0:ay()=g|
00000270  0d 00 dc 22 f4 63 6f 6d  70 75 74 65 20 66 6f 72  |...".compute for|
00000280  63 65 20 66 6f 72 20 65  61 63 68 20 73 70 72 69  |ce for each spri|
00000290  6e 67 0d 00 e6 0f 20 e3  63 25 3d 30 b8 6e 25 2d  |ng.... .c%=0.n%-|
000002a0  31 0d 00 f0 0d 20 20 64  25 3d 63 25 2b 31 0d 00  |1....  d%=c%+1..|
000002b0  fa 14 20 20 64 78 3d 78  28 63 25 29 2d 78 28 64  |..  dx=x(c%)-x(d|
000002c0  25 29 0d 01 04 14 20 20  64 79 3d 79 28 63 25 29  |%)....  dy=y(c%)|
000002d0  2d 79 28 64 25 29 0d 01  0e 14 20 20 6c 3d b6 28  |-y(d%)....  l=.(|
000002e0  64 78 5e 32 2b 64 79 5e  32 29 0d 01 18 0c 20 20  |dx^2+dy^2)....  |
000002f0  e7 6c 3c 3e 30 8c 0d 01  22 17 20 20 20 61 78 3d  |.l<>0...".   ax=|
00000300  28 6e 6c 2d 6c 29 2a 6b  2a 64 78 2f 6c 0d 01 2c  |(nl-l)*k*dx/l..,|
00000310  17 20 20 20 61 79 3d 28  6e 6c 2d 6c 29 2a 6b 2a  |.   ay=(nl-l)*k*|
00000320  64 79 2f 6c 0d 01 36 1c  20 20 20 61 78 28 63 25  |dy/l..6.   ax(c%|
00000330  29 2b 3d 61 78 3a 61 78  28 64 25 29 2d 3d 61 78  |)+=ax:ax(d%)-=ax|
00000340  0d 01 40 1c 20 20 20 61  79 28 63 25 29 2b 3d 61  |..@.   ay(c%)+=a|
00000350  79 3a 61 79 28 64 25 29  2d 3d 61 79 0d 01 4a 07  |y:ay(d%)-=ay..J.|
00000360  20 20 cd 0d 01 54 06 20  ed 0d 01 5e 3e 20 61 78  |  ...T. ...^> ax|
00000370  28 30 29 3d 30 3a 61 79  28 30 29 3d 30 20 20 20  |(0)=0:ay(0)=0   |
00000380  20 20 20 20 20 3a f4 46  69 72 73 74 20 70 6f 69  |     :.First poi|
00000390  6e 74 20 63 6f 6e 74 72  6f 6c 6c 65 64 20 62 79  |nt controlled by|
000003a0  20 6d 6f 75 73 65 2e 0d  01 68 25 f4 63 6f 6d 70  | mouse...h%.comp|
000003b0  75 74 65 20 6d 6f 76 65  6d 65 6e 74 73 20 66 6f  |ute movements fo|
000003c0  72 20 65 61 63 68 20 70  6f 69 6e 74 0d 01 72 0d  |r each point..r.|
000003d0  20 e3 63 25 3d 30 b8 6e  25 0d 01 7c 1c 20 20 76  | .c%=0.n%..|.  v|
000003e0  78 28 63 25 29 3d 76 78  28 63 25 29 2a 61 2b 61  |x(c%)=vx(c%)*a+a|
000003f0  78 28 63 25 29 0d 01 86  42 20 20 76 79 28 63 25  |x(c%)...B  vy(c%|
00000400  29 3d 28 76 79 28 63 25  29 2d 61 79 28 63 25 29  |)=(vy(c%)-ay(c%)|
00000410  29 2a 61 2b 32 2a 61 79  28 63 25 29 20 3a f4 6e  |)*a+2*ay(c%) :.n|
00000420  6f 20 61 62 73 6f 72 70  74 69 6f 6e 20 6f 66 20  |o absorption of |
00000430  67 72 61 76 69 74 79 0d  01 90 13 20 20 78 28 63  |gravity....  x(c|
00000440  25 29 2b 3d 76 78 28 63  25 29 0d 01 9a 13 20 20  |%)+=vx(c%)....  |
00000450  79 28 63 25 29 2b 3d 76  79 28 63 25 29 0d 01 a4  |y(c%)+=vy(c%)...|
00000460  29 20 20 e7 78 28 63 25  29 3c 2d 77 25 8c 78 28  |)  .x(c%)<-w%.x(|
00000470  63 25 29 3d 2d 77 25 3a  76 78 28 63 25 29 3d 2d  |c%)=-w%:vx(c%)=-|
00000480  76 78 28 63 25 29 0d 01  ae 27 20 20 e7 78 28 63  |vx(c%)...'  .x(c|
00000490  25 29 3e 77 25 8c 78 28  63 25 29 3d 77 25 3a 76  |%)>w%.x(c%)=w%:v|
000004a0  78 28 63 25 29 3d 2d 76  78 28 63 25 29 0d 01 b8  |x(c%)=-vx(c%)...|
000004b0  29 20 20 e7 79 28 63 25  29 3c 2d 77 25 8c 79 28  |)  .y(c%)<-w%.y(|
000004c0  63 25 29 3d 2d 77 25 3a  76 79 28 63 25 29 3d 2d  |c%)=-w%:vy(c%)=-|
000004d0  76 79 28 63 25 29 0d 01  c2 27 20 20 e7 79 28 63  |vy(c%)...'  .y(c|
000004e0  25 29 3e 77 25 8c 79 28  63 25 29 3d 77 25 3a 76  |%)>w%.y(c%)=w%:v|
000004f0  79 28 63 25 29 3d 2d 76  79 28 63 25 29 0d 01 cc  |y(c%)=-vy(c%)...|
00000500  06 20 ed 0d 01 d6 06 fd  a3 0d ff                 |. .........|
0000050b