Omega
Stiffness
Damping
(this is a parameter, not the damping factor)
The black ball is the input.
The trolley is connected to it by a spring.
The trolley is also connected to ground through a damper.
running=true; //First give the variables some initial values dt = .01; //Make this smaller for better accuracy stiffness=document.inputs.stiff.value; damping=document.inputs.damp.value; omega=eval(document.inputs.omeg.value); x=0; //initial position y=0; vx=0; vy=0; //initial velocity StepModel(); //Start the simulation running
theta+=omega*dt; excitation=Math.sin(theta)*20; vx += dt * (stiffness * (excitation-x) - vx*damping); x += dt * vx; Move(trolley,x); if(running){setTimeout('StepModel()',10);}