I love More or Less on Radio 4. I did squee so much when it came back for a new series. It isn’t easy to make statistics both fun and intelligible.
Also, I got horribly sunburnt yesterday :-(. But only on the top of my arms and face and not where my watch goes so is both daft and painful. Grr.
Also, I have a TrainGame-derived maths problem: let’s say I have a three-dimensional Bezier curve (X(t), Y(t), Z(t)) defined for 0 <= t <= 1. In my case this defines a track segment and works admirably for rendering the track. However it also determines the position of the train on the track at some time t. The problem is, with the train travelling at a constant speed, it appears to speed up or slow down depending where it is on the curve. It turns out that most of the time this doesn’t really matter, but sometimes it does.
What I would like is for the t parameter to be linearly related to the distance travelled along the curve; so if A is the arc length between two points A(0, s) = s * A(0, 1). Unfortunately, Bezier curves don’t possess this property and there’s not even a closed-form solution to A. So I’ve had to write this crude and slow approximation to such a curve given a normal Bezier curve as input:
It works by assuming that (X(s), Y(s), Z(s)) should be sL units along the curve, where L is the length of this track segment. It then approximates the curve by lots of little straight lines and moves t along the curve summing lengths until it reaches sL. Then we evaluate the curve at (X(t), Y(t), Z(t)).
So the question is, mathematicians of the interwebs, is there a better way to do this??