# 540_degree_twisted_Moebious_Strip.BAS

Home   »   540_degree_twisted_Moebious_Strip.BAS

``````!540 degree twisted Moebious Strip becomes shape with D_3 symmetry
!2021-05-29 @aoki_taichi
!http://hp.vector.co.jp/authors/VA008683/
!http://www.darwin3d.com/gamedev/articles/col0599.pdf
!todo: Verlet Integlationとやらを使った方が安定する？

OPTION ARITHMETIC NATIVE

LET dt=0.04! time step
LET m=10*3*2 ! x
LET n=5    ! y
LET nn=n*m ! number of particles
LET k=2*1.0e2 !spring constant
LET drag=0.2
DIM x(1 TO nn),y(1 TO nn),z(1 TO nn)
DIM vx(1 TO nn),vy(1 TO nn),vz(1 TO nn)
DEF id(xx,yy)=(xx-1)*n + (yy-1) +1
SET WINDOW -1/3*m +m/6,2/3*m -m/6,-m/2 +m/6,m/2 -m/6
SET POINT STYLE 2

DIM ex(1 TO 3),ey(1 TO 3),ez(1 TO 3)!orthogonal vector
DATA 1,0,0
DATA 0,1,0
DATA 0,0,1

!initialize the particle positions
FOR xx=1 TO m
FOR yy=1 TO n
LET i=id(xx,yy)
LET x(i)=xx
LET y(i)=yy-CEIL(n/2)
LET z(i)=0
NEXT YY
NEXT XX

LET nnn= (n-1)*m + n*(m-1) + (n-1)*(m-1)*2 + (n-2)*m + n*(m-2) ! number of links
DIM link(1 TO nnn,0 TO 1)
LET ii=0
FOR xx=1 TO m-1
FOR yy=1 TO n
LET ii=ii+1
NEXT  YY
NEXT XX
FOR xx=1 TO m
FOR yy=1 TO n-1
LET ii=ii+1
NEXT  YY
NEXT XX

FOR xx=1 TO m-1
FOR yy=1 TO n-1
LET ii=ii+1
LET ii=ii+1
NEXT  YY
NEXT XX

FOR xx=1 TO m-2
FOR yy=1 TO n
LET ii=ii+1
NEXT  YY
NEXT XX
FOR xx=1 TO m
FOR yy=1 TO n-2
LET ii=ii+1
NEXT  YY
NEXT XX

IF ii-nnn <> 0 THEN STOP
DIM d0(1 TO nnn) ! rest length for each link
FOR ii=1 TO nnn
LET d0(ii)=SQR((x(i)-x(j))^2+(y(i)-y(j))^2+(z(i)-z(j))^2)
NEXT ii

DO
LET mx_was=mx
LET my_was=my
mouse poll mx,my,ml,mr
LET t=t+dt

FOR ii= 1 TO nnn
LET d=SQR((x(i)-x(j))^2+(y(i)-y(j))^2+(z(i)-z(j))^2)
LET f=k*(d - d0(ii))!Hooke's law
LET vx(i)=vx(i)-f*(x(i)-x(j))/d*dt
LET vy(i)=vy(i)-f*(y(i)-y(j))/d*dt
LET vz(i)=vz(i)-f*(z(i)-z(j))/d*dt

LET vx(j)=vx(j)+f*(x(i)-x(j))/d*dt
LET vy(j)=vy(j)+f*(y(i)-y(j))/d*dt
LET vz(j)=vz(j)+f*(z(i)-z(j))/d*dt
NEXT  II

FOR i= 1 TO nn
IF t``````
``` Leave a Reply Your email address will not be published. Required fields are marked *Comment Name * Email * Website Save my name, email, and website in this browser for the next time I comment. Δdocument.getElementById( "ak_js" ).setAttribute( "value", ( new Date() ).getTime() ); ```
``` ```
``` ```
``` ```
``` window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'G-EDBFB861MJ'); ```