Animating a Railroad

I was thinking about this some time ago. It shouldn’t be difficult as long as you find a way to calculate intersection of spline with circle:
afe3fef3f67780d8de8b0a1a64c7a0ffb8eca424.jpeg

Yellow is a cart, dark blue is leading bogie and cyan is trailing bogie. First you calculate position of leading bogie along the spline from it’s speed, intersection of circle with spline will give you position for second bogie.

Edit: didn’t had time to elaborate on finding intersection. The straightforward way is to iteratively approximate spline with the set of line segments and look for intersection on each iteration. Reiterate until you reach some necessary precision. The amount of iterations can be scaled by how much curvature you have at spline.
Another approach is to take two control points and find intersection of circle with line between them. This will be your x for the Bézier curve, from there you can calculate y of the spline as you know tangents from control points. I would do the later but I don’t know which specific formula engine used to draw them.