Opposite direction restricting to one dimension, and usage of signed numbers.
If both trains SPEEDS are each r,
WhichWay
DIRECTION r
OPPOSITE -r
These will have their own sizes on a number line, find the difference in RATE (not speed, but rate; now you are dealing with the meaning of direction, not just size alone).