nextnext page arrow

myphysicslab – roller coaster

if you had first-year physics in college, you probably solved lots of problems with a ball rolling down a flat inclined plane. did you ever wonder how to solve for the motion with a curved surface instead? of course the same principles apply, but the forces are changing as the slope changes. so the math gets a bit more interesting!

you can change the track shape by clicking a button below. you can change parameters such as gravity or damping. you can 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!


click to select a different track:
hump shaped track loop track circle track infinity track oval track spiral track
hump loop circle infinity oval spiral

is it correct? using energy to decide

how can we decide whether this simulation is correct? we know that the ball should not spontaneously gain energy, nor mysteriously lose energy. so we can look for situations that may violate this constraint.

try dragging the ball to a certain height on a curve, and letting go. if damping (friction) is set to 0, the ball should reach the same height on the track again and again. it shouldn't gain or lose height at the moment that it reverses direction. at that moment the velocity is zero, and all the energy is gravitational (potential) energy.

here is a more sensitive test: click on the circle track. with damping set to 0, move the ball to the apex of the circle and let the ball go. when you release the ball it has zero velocity, and only potential (gravitational) energy. the ball will fall to one side and then roll back up the other side to almost where you released it from. it should then reverse direction and fall the other way.

if instead the ball crosses over the top of the circle, you know that it has gained some energy because it will have non-zero velocity at the top of the circle. this shows the simulation is imperfect.

to observe the energy directly, click the "show energy" checkbox. the energy shown is the sum of the kinetic and gravitational energy. kinetic energy = 12 m v2
gravitational energy = m g y
where m = mass, v = velocity, g = gravity constant, and y = vertical position. with damping off, total energy should remain constant. instead, you will see the energy fluctuating quite a bit. this is due to some shortcuts used in the simulation programming. for example, we use a table to represent the curve (see below) and the slope at a given point is approximated somewhat crudely.

perhaps you can appreciate that programming a simulation like this involves tradeoffs between correctness, display speed, and programming effort!

physics of the simple roller coaster

roller coaster variables
a ball moves along a curved track. we assume that the ball cannot leave the track, but is free to move along its length. we have two variables we pick some point on the track to be position p = 0 and pick a direction along the track to be positive. then the position is equal to the length of the track, from the origin to that point. the gravity force on the ball is shown in the diagram as m g pointing downwards. the component of this force that is parallel to the track is what causes the ball to accelerate. the steeper the track, the faster the acceleration.

let k be the slope of the track at this point. let θ be the angle between the gravity vector and the slope vector (the slope vector points in the direction where p increases). then we can write the force equation for gravity as
   f = m a = m g cos θ (1)
where m = mass, a = acceleration, and g = the gravitational constant. if we add a damping (friction) force that is proportional to the velocity we get
   f = m a = m g cos θb v (2)
where b is a constant determining the amount of damping. we can find cos θ by using the formula for the angle between two vectors a, b
cos θ =   a · b
|a| |b|
where the numerator is the dot product, and the denominator is the product of the lengths. (note that we indicate vectors with bold letters here.) define our two vectors by this leads to
cos θ =   k m g   =   k
m g √(1 + k2) √(1 + k2)
now we can write equation (2) as
a =   g k   − bm v
√(1 + k2)
(3)
where we keep in mind that the slope k is really a function of position k(p). that is, given the position, we need to find the slope at that point. this is the equation of motion for the roller coaster.

numerical simulation

the two equations needed for the runge-kutta numerical solver are given by: p' = v
v' =   g k(p)   − bm v
√(1 + k(p)2)
here we indicate that the slope k is a function of position p by the notation k(p).

there is a small additional complication in that the track can loop around. this requires us to determine whether the path is increasing (in the sense of increasing p) to the left or to the right. this affects the direction of the slope vector and can change the sign of cos θ. this enters into the first term of equation (3) as a possible multiplication by −1.

finally, vertical lines need a special treatment, because the slope is infinite there. when we detect that the slope is vertical, equation (3) becomes: a = −gbm v

measuring the length of a curve

to program this simulation on the computer we need to find the relationships between: for the correctness of the simulation, the most important relationship is pk because this is used in the differential equation, represented by the function k(p). the other relationships can be less exact because they are only used to update the graphics or for user input. for example, the relation p → (x, y) is used to update the graphics. and the relation (x, y) → p is used for dragging the ball.

suppose that the curve can be defined parametrically by two functions x(t), y(t). that is, to sweep out the curve we increase the variable t from 0 to some value. and for each value of t we can find the position of the curve from the functions x(t), y(t). for example, a circle can be defined parametrically by x(t) = cos t
y(t) = sin t
where t varies from 0 to . in two dimensions, the length of a curve can be determined by the path integral p = \int \sqrt{\left( \frac{dx}{dt} \right)^2 + \left( \frac{dy}{dt} \right)^2} dt where the limits of integration are the starting and ending value of t corresponding to the points you want to measure between.

we can try to solve the path integral analytically to get the needed relations. for some curves this is easily done. for the circle, the path integral is especially simple: p = ∫ √ (sin2t + cos2t) dt = ∫ 1 dt = t but for most curves the integral is too difficult to solve. for example, the "hump" curve in the simulation is defined by a simple polynomial x(t) = t
y(t) = 3 − 76 t 2 + 16 t 4
but this leads to the following nasty integral which even mathematica cannot solve. p = \int \frac{1}{3} \sqrt{9 + 49 t^2 - 28 t^4 + 4 t^6} \; dt faced with difficult integrals, we instead take an approximate numeric approach and construct a table to represent the curve, as explained below.

representing the curve with a table

here is how we construct a table to represent the curve. assume we have the functions x(t), y(t) which describe the curve parametrically. suppose we want the curve to be defined from t = −3 to t = 3. then we start forming a table that would look something like this:
t p x y
−3 0 1 2
−2.99 0.014142 0.99 2.01
−2.98 0.028284 0.98 2.02
. . . . . . . . . . . .
each row of the table represents a point on the curve. the table is constructed by starting with t = −3 and setting p = 0. we then find x, y from the equations x(−3), y(−3). to add each row, we increase t by some small increment (here it is 0.01) and find the corresponding x(t), y(t). we can then find p either by numerically evaluating the path integral (see above), or as a cruder and simpler method we can just increase p by the distance to the previous x, y point. i've chosen the simple, crude method for the program here (a refinement would be to fit a polynomial to 3 or 4 neighboring points).

once we have the table, we can implement a routine that maps pk. this can be done quickly by using a binary search algorithm, since the p values are all sorted. suppose that p is closest to the i-th value in the table, so that p[i] < p < p[i+1] where p represents the list of p values in the table. then an approximate value for the slope is given by
k =   y[i+1] − y[i]
x[i+1] − x[i]
where x, y are the tables of x, y values. similar methods can be used for finding the relation p → (x, y). for slightly better accuracy we can use a polynomial interpolation of the 4 points in the table that are nearest to the value of p we are seeking.

the routine that maps (x, y) → p is used less frequently and doesn't need to be as efficient. i use a linear search through the entire table to find the point in the table that minimizes the distance from the given (x, y) to the curve.
cheap oakley sunglassescoach factory outletjordan retro 6lebron 11beats by dre outletcheap oakley sunglassesbeats by dre cheaplegend blue 11slegend blue 11slouis vuitton outletcoach outlet onlineferrari 14smichael kors ukblack infrared 6sbeats by dre cheapjordan 11 legend bluelegend blue 11slebron 11 Biscaynelegend blue 11smichael kors outlet