Well, not really...
<tl;dr>
The catenary in a curve should form an open polygonal chain tangent to the curve (the straight line segments must be tangent to the curve). Let me rephrase:
the polygonal chain should not intersect the curve. Let me rephrase again: the zigzag offset works only to the outside of the curve.
Knowing that, we can construct each catenary segment as a base of an isosceles triangle such that its height is equal to the curve radius and its arms’ length is equal to the sum of curve radius and zigzag offset and its tip is at the centre of the curve. We can then divide this triangle into two right triangles, such that each arm turns into the hypotenuse and the height becomes the adjacent side. Having established that, we can now find the ratio of the adjacent side to the hypotenuse which is equal to the cosine of the central angle (based at the centre of the circle). We can reverse this to get the magnitude of the angle given values for parameters r and o:
halfAlfa = acos(r / (r+o));
and hence get the angular distance between poles (points where the catenary is attached):
</tl;dr>
alfa = 2 * acos(r / (r+o));
Now, to get the actual length, we need to decide whether we want the length of the curve segment (length of the curved track segment between the points where catenary is attached) or the length of the actual catenary segment.
For the first, we need to multiply the angle by the
lengthOfCurveSegment = alfa * r;
lengthOfCurveSegment = 2r * acos(r/(r+o));
and for the other we need to find out the length of the base of the isosceles triangle which is equal to double the length of the opposite side of the right angle. Hence
lengthOfCatenarySegment = 2 * sqrt( (r+o)^2 - r^2);
after optimizing the equation:
lengthOfCatenarySegment = 2 * sqrt(o * (2r+o));
Not sure how Marcin arrived at his result. :<
Besides his equation should optimize into:
d = 2sqrt(2*p^3*r)
which makes no sense whatsoever (why the power 3?).