myphysicslab – roller coaster with flight
this simulation shows a ball on a roller coaster where the ball can jump off the track. when the ball is on the track, it is colored blue; when in free flight it is colored red.
the spring is activated when the spring stiffness is nonzero, which you can change by clicking show controls. clicking the spring on or spring off buttons also changes the spring stiffness. you can change parameters such as gravity or damping. drag the ball with your mouse to change the starting position. if you don't see the simulation try instructions for enabling java. scroll down to see the math!
when should the ball jump the track?
uniform circular motion
this simulation is based on the
roller coaster with spring and uses all of the physics described there. the main difference is that we check for when the ball should jump off the track into
free flight. the key to when this happens lies in the formula for acceleration with uniform circular motion, which is
this is the acceleration,
a, needed to keep a projectile moving in a circle of radius
r with velocity
v. the direction of the acceleration is towards the center of the circle. so, moving faster in a given circle means you need more acceleration to stay on the same circle. conversely, moving in a larger circle means you need less acceleration.
suppose the ball is moving with velocity
v over a hill shaped like a circle with radius
r. the minimum acceleration (towards the center of the circle) needed to keep the ball on the hill is
v^{2}/r. if at any moment the acceleration (towards the center) is less than this, then the ball will fly off the hill.
angle of tangent
to apply this to a general curve other than a circle, we need the notion of
radius of curvature at a point
p on the curve. let
φ = the angle of the tangent to the curve at
p. we can express
φ as
φ = arctan(^{dy}⁄_{dx})
where
^{dy}⁄_{dx} is the slope of the curve at
p. we define the curvature
κ as the rate of change of the tangent angle
φ as we move along the curve.
where
s = arc length along the curve. the radius of curvature
r is the reciprocal of the curvature:
r = ^{1}⁄_{κ}
we can estimate this using the
table representing the curve. here's how: for a given point
p we estimate the slope a short distance
δ on either side of
p. equation (2) is then approximated by
κ =

arctan(slope at p+δ) − arctan(slope at p−δ)

2 δ

the radius of curvature
r is then the reciprocal of this. and this radius of curvature is what we need to apply equation (1). we know that the ball will stay on the curve as long as the acceleration
normal to the curve is greater than
v^{2}/r.
in the
simple roller coaster we developed an expression for the gravity force on the ball. in the
roller coaster with spring we developed an expression for the spring force on the ball. in those cases, we used the component of the force that was
parallel to the track. here, we want to know the component of the force that is
perpendicular (normal) to the track. to determine the acceleration normal (perpendicular) to the curve we use the same calculations except that now we use
sin θ instead of
cos θ.
f_{gravity} = m g sin θ
f_{spring} = c sin θ (√(s_{x}^{2} + s_{y}^{2}) − r)
(please see those pages for the definition of these symbols.) since we already know
cos θ from the
roller coaster with spring we can easily find
sin θ from
sin θ = √(1 − cos^{2}θ)
now we can find the acceleration normal to the curve from
f_{gravity} + f_{spring} = m a
we then compare the acceleration to that given by equation (1) to determine whether the ball should leave the track. to stay on the track going over a hill, we must have
a > v^{2}/r. on the other hand, to stay on the track when going through a valley we need
a < v^{2}/r. (i am glossing over some details of how to determine the correct sign of the acceleration).
switching to free flight
when the ball is on the track, the simulation is controlled by the differential equations given in the
roller coaster with spring. in this case there are two variables:
 p = position on the track (measured by path length along the track)
 v = velocity
when we detect that the ball should leave the track, we switch the controlling differential equations to those of "free flight". there are then four variables:
 u_{x} = horizontal position
 u_{y} = vertical position
 v_{x} = horizontal velocity
 v_{y} = vertical velocity
the differential equations for free flight are the same as those given for the
2dimensional spring
adjusting velocity during collision
while the ball is in free flight we need to handle collisions with the track. after a collision is detected (because the ball is below the track) we back up and use a binary search algorithm to get the simulation very close to the time of collision. the
colliding blocks simulation has some more about collision handling in general.
reflected velocity vector
once the simulation has been run to very close to the time of collision, we need to adjust the velocity of the ball so that it bounces off the track. define the following vectors (vectors are indicated by bold type):
 a = (vx, vy) is the velocity vector of the ball
 b = (1, k) is the vector tangent to the curve where slope = k
 c = the component of a in the b direction
 n = the component of a normal to b
 r = the reflected velocity vector
some elementary vector algebra gives us
n = a − c
the
elasticity parameter determines how bouncy the ball is. let
e = elasticity. a perfectly elastic ball will have elasticity
e = 1.0 and will bounce forever. an elasticity of
e = 0.2 would indicate a rather "dead" ball that doesn't bounce very much. to model this behavior we multiply
n in equation (4) by the elasticity to get
r = c − e n
this represents the new velocity that we assign to the ball at the time of collision.
eventually, the ball will make smaller and smaller bounces. in real life, there comes a time when the ball is back in continuous contact with the ground. to determine whether the ball should "jump back onto the track" and be controlled by the "on the track" set of differential equations, we compare the magnitude of the normal vector
e n to the magnitude of the total velocity vector. the test involves the
stickiness parameter and looks like this:
if (

e n

< stickiness) then jump back onto track

r

if the normal velocity
e n is small enough we decide the ball should be back on the track. the stickiness is a parameter on the order of
0.1 that can be changed in the simulation controls.
multiple collisions
multiple collisions over one time step
the collision occurred as we were trying to advance the simulation a small time step (perhaps ^{1}⁄_{10} of a second) from a certain time t_{0} to the new current time t_{1}. now that the collision has been handled, we attempt to run the simulation up to the current time t_{1}. if there are no new collisions detected, then this simulation step is done. however if a new collision is detected, we begin the entire collision handling process over again. we will eventually reach time t_{1} even if we have to handle multiple collisions along the way.
the figure at left shows a typical situation where multiple collisions occur over one simulation time period because the ball goes into a tight corner at high speed.
limitations of this simulation
unlike the other roller coaster simulations, this one does not have the option to use various tracks. the reason is that having a track that doesn't loop simplified the code considerably. for example, to determine whether there is a collision, we only test whether the ball is below the track. with a looped track there would be more complicated criteria for deciding if the ball has collided with the track, such as checking if it is inside or outside the track. so if you are looking for a programming project, grab the source code and go to work!