When we are on the surface we do use terms like North and South for indicating direction, so on a train, some relative terms would likely be used by the passengers
The passengers, perhaps....
Oddly enough, in the US**, North, South, East, and West don't necessarily mean the same, depending on the railroad concerned, and not only because even quite short railway routes are never dead straight over their entire lengths (for all sorts of reasons).
I can't recall the details, or the book in which I read them, but some railroads define their trains as travelling either east or west (or, alternatively, north or south) on
every part of their (often widespread and complex) systems. So, say, one of those "transcontinental" railroads that run between one or more cities on the Pacific Coast and one or more cities on or near the Mississippi might have trains that are said to be westbound as they head (more or less due) north from LA to the Bay Area.
** - I don't know about other countries, but in the UK, we did (and, perhaps, still sometimes do) use the terms Up train and Down train, with "Up" meaning "heading for London" and "Down" meaning "heading from London".