Instructions: drag the square or ball, or try changing control values (gravity, damping, etc.)
Click to select a different track:
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
hump | loop | circle | infinity | oval | spiral |
This simulation is a variation of the Simple Roller Coaster, please see that page for more information on the physics and how the simulation is done. The only difference here is that the spring force is added to the differential equation.
Define the following variables:
Let the width and height of the spring be given by:
sx = qx - px
sy = qy - py
The length of the spring is then
F = cos(θ) c (√(sx2 + sy2) - R) (eqn 1)
It is this parallel component of the spring force that will accelerate the ball along the track. Consider a couple of cases to convince yourself of this: If the spring is perpendicular to the track, then
We can find
A · B cos(θ) = ——————— |A| |B| |
where the numerator is the dot product, and the denominator is the product of the magnitudes. Define our two vectors by
This leads to
sx + k sy cos(θ) = ———————————————————— √(1 + k2) √(sx2 + sy2) |
Put this expression into equation (1) and combine with the gravity and friction forces developed for the Simple Roller Coaster to get
-g k c (√(sx2 + sy2) - R) (sx + k sy) a = ————————— - (b/m) v + —————————————————————————————— √(1 + k2) m √(1 + k2) √(sx2 + sy2) |
where
Besides this change to the force equation, the simulation is similar to the Simple Roller Coaster. Please see that page for more information on how the simulation is implemented.