Square Wheels & Catenaries

[Home]   [Puzzles & Projects]    [Delphi Techniques]   [Math topics]   [Library]   [Utilities]

 

 

Search

Search WWW

Search DelphiForFun.org

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 feedback 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.  Thanks

 


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.

Mensa® Daily Puzzlers

For over 15 years Mensa Page-A-Day calendars have provided several puzzles a year for my programming pleasure.  Coding "solvers" is most fun, but many programs also allow user solving, convenient for "fill in the blanks" type.  Below are Amazon  links to the two most recent years.

Mensa® 365 Puzzlers  Calendar 2017

Mensa® 365 Puzzlers Calendar 2018

(Hint: If you can wait, current year calendars are usually on sale in January.)

Contact

Feedback:  Send an e-mail with your comments about this program (or anything else).

Search DelphiForFun.org only

 

 

 

Problem Description

Design a roadbed which will allow "square wheels" to roll smoothly.

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 curves which 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 roadbed. 

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 by definition.   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:

bulletTrial and error: make guesses at A and C values and compare the results with target H and S values until we are "close enough"
 
bulletNewton's Method:  An automated way to accomplish the same goal, by making better and better guesses in a loop until we are "close enough" to 0.  Newton's technique assume that a straight line drawn tangent to the curve from the current point on the curve  would cross the X axis at the same point that the curve does.   If it doesn't, we at least have a new closer point to use as the next guess.  With two equations and two variables things are a little more complicated.  I just made alternate guesses; for C using the height equation and  for A using the arc length equation.   It seems to work, so I avoided re-learning what I might have once known about solving systems of equations with Newton's Method.

There are a couple of conditions before Newton's method will work. 

bullet We must be able to determine the tangent line (the slope of the curve).  Any description of Newton's method will provide the detail.  The slope is defined by the first derivative which I'm sure has a specific expressions for our equations.   I was too lazy to figure them out though and used another way - evaluate the expression at a second point quite close to the current guess and use the resulting point to estimate the slope.  
bulletThe curve must not have any humps and bumps between our current guess and the solution point.   Catenaries are free of such bumps.
 
bulletAnalytical Solution: Finally, the best way, a closed analytical solution that gives us functions A=f1(H,S) and C=f2(H,S).   Hans Klein, a pretty smart math teacher in the Netherlands succeeded in doing just that: Namely:
bullet Let u = (s+h) / (s-h)
bullet then C = 2u*S/(u2-1)
bullet and A = C*ln(u).

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.

Programmer's Notes

Since the math discussion was quite long, I'll keep these notes brief.

bulletOnce 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.     
bulletThe "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.  
bullet"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 

bullet Download source
bullet Download  executable

Suggestions for Further Explorations

bullet Expand the square to other regular polygons.
bullet By  computing two different catenaries and alternating them in the road bed, rectangular wheels could even be allowed.  How cool would that be?
bullet Two wheels connected to form a rolling "cart"?  The wheels would not even have to be synchronized.
bullet Modify the Newton's method solution to use the derived values for the slope of the curve at X.
 
Original Date: March 07, 2007 

Modified: May 15, 2018

 

  [Feedback]   [Newsletters (subscribe/view)] [About me]
Copyright © 2000-2018, Gary Darby    All rights reserved.