Omega
Stiffness
Damping
(this is not the damping factor)
The black ball is the input.
The yellow ball is connected to it by a spring.
The yellow ball 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); vy += dt * (stiffness * (excitation-y) - vy*damping); y += dt * vy; Moveball(ball,x,y,0); Moveball(input,0,excitation,0); if(running){setTimeout('StepModel()',10);}