' Spring 0.1
' Copyright (c) 2012 Nonki Takahashi. All rights reserved.
'
' History:
' 2012/10/13 Created.
'
' Timer Event Mod
' JDR564-0
GraphicsWindow.Title = "Spring 0.1"
scale = 3139 ' [dot/m]
l = .05 ' spring length [m]
k = 20 ' spring constant [N/m]
m = .01 ' mass of weight [kg]
d = .01 ' diameter of weight [m]
g = 9.8 ' acceleration of gravity [m/(s^2)]
xs = .1 ' stationary point from left [m]
ys = 0 ' stationary point from top [m]
x0 = xs - d / 2
y0 = ys + l
y = y0 + .05
v0 = 0
v = v0
fps = 25
time = Math.Round(1000/fps)
dt = .05
InitWeight()
Timer.Tick = Animation
Timer.Interval = time
GraphicsWindow.TextInput = PauseOrExit
Sub Animation
ShowWeight()
dv = (m*g - (y - y0) * k) * dt
v = v + dv
dy = (2*v + dv) * dt/2
y = y + dy
EndSub
Sub InitWeight
GraphicsWindow.PenColor = "DimGray"
spring = Shapes.AddLine(0,0 0,l*scale)
Shapes.Move(spring xs*scale,ys*scale)