As of October, 2016, Embarcadero is offering a free release
of Delphi (Delphi
10.1 Berlin Starter Edition ). There
are a few restrictions, but it is a welcome step toward making
more programmers aware of the joys of Delphi. They do say
"Offer may be withdrawn at any time", so don't delay if you want
to check it out. Please use the
link to let me know if the link stops working.
Support DFF - Shop
If you shop at Amazon anyway, consider using
this link. We receive a few cents from each purchase.
Support DFF - Donate
If you benefit from the website, in terms of
knowledge, entertainment value, or something otherwise useful,
consider making a donation via PayPal to help defray the
costs. (No PayPal account necessary to donate via credit
card.) Transaction is secure.
e-mail with your comments about this program (or anything else).
Design a roadbed which will allow "square wheels" to
Background & Techniques
While browsing for information about the catenary shape of the Gateway
Arch recently, I ran across a paragraph in the Wikipedia article on Catenary
mentioned that regular polygons rolling over a series of catenary shaped
bumps could keep their centers at a constant height. Not at all
practical of course, but it motivated me to see if I could design such a
Designing the road turned out to be a good mental exercise. It
was clear early on that there were two constraints on each "bump".
First, as the polygon rolled on a level surface, its center would vary in
height from the perpendicular distance to an edge (at its low point) to the distance
to a corner (at its high point). So the height of each bump had
to be the difference of those two heights. Also if the edge is to roll without slipping, the length of
each bump must equal the length of each edge.
Those two parameters, curve height, H, and curve length, S,
should define our catenary. The problem is, the standard definition of
a catenary does not include either of these parameters as independent
variables. Look it up and you'll find and equation for
catenaries like Y=C
cosh(X/C). No H or S in sight as
independent variables! Y,
which could be the curve height if we have the correct origin,
is determined by X, the
horizontal distance, and C, some sort of width controlling parameter.
Cosh(X/C), the hyperbolic cosine is (ex/c + e-x/c)/2
Note that negative X values give the same result a positive values, so the
curve is symmetric about X=0 and we only need to work with 1/2 of the curve. Also, height increases as X increases
and is at its minimum when X=0. For X=0, Y=C ( (e0
+ e-0)/2 =C. In order to have the expression
measure height directly, we need to shift the curve down by C units so that
it crosses the Y axis at 0. If we subtract C from the expression, we can replace Y with H (for height).
The modified equation then is H=C cosh(X/C) - C.
We have an expression for H, how about S, the arc length? There is an
expression for that also. In the interval 0 to X, the arc length S
= C sinh(X/C). Sinh, hyperbolic sine, is defined as (ex
- e-x)/2. Let's denote the specific X value
where height and arc length both match out target values as A.
So given H and S, we'd like to solve the two equations
C cosh(A/C )- C - H = 0 and C sinh(A/C) - S = 0 for A and
C. Note we are solving the upright version of the curve, but
the inverted catenary will have exactly the same C and A values.
Also, we are working with only half of the "bump" so our target arc length
will be half the length of a polygon side.
With the problem finally defined, now we can work on a solution.
The "Find catenary parameters" page has three solution techniques, developed
and listed in the order they were developed:
I display Hans' derivation on the results page in the program so I
won't repeat it here.
How he came up with the derivation is a mystery to me, but it all looks valid, and
the results agree with (are better than) the results from the
preceding methods. .
Non-programmers are welcome to read on, but may
want to skip to the bottom of this page to download
executable version of the program.
Since the math discussion was quite long, I'll keep these notes brief.
|Once the parameters A and C are known, drawing the roadbed is quite
straightforward. I limited the wheel to a 50 pixel x 50 pixel
square. It was probably only dumb luck that the resulting width
value (2A) came out so close to being an integer value (44.07 pixels)
that we could use it directly without worrying about adding or
subtracting an occasional pixel to the width.
|The "RollWheel" button click procedure calls procedure
DrawSquare passing a center point, size and angle in a loops until
the center reaches the edge of the image. In the 44 horizontal
steps to roll over one bump, the square must rotate 90 degrees (Pi/2
radians) so we rotate the square by Pi/88 radians for each step.
The Sleep procedure lets the wheel "rest" for 9 milliseconds
before erasing it and drawing the next position. |
|"Just for fun" I made a set of reward messages at the end of each
trip intending to display one of them randomly. One of the 5
messages is for granddaughter Kaitlin, but I found that it might take 10
or more messages before it shows up, so maybe she would never see it.
(As a probability refresher, the chance of 0 occurrences of a particular
message when choosing 1 of 5 for each of 10 trials is 0.810
= 0.107 or about 10%.) I choose a new
method that displays a random message from among those that haven't yet
been displayed, starting over after all the messages have been
displayed. I like it. |
Running/Exploring the Program
Suggestions for Further Explorations
square to other regular polygons.
computing two different catenaries and alternating them in the road
bed, rectangular wheels could even be allowed. How cool would
connected to form a rolling "cart"? The wheels would not even
have to be synchronized.
Newton's method solution to use the derived values for the slope of
the curve at X.
Original Date: March 07, 2007
February 18, 2016