Route Building Tutorial 5: FInishing the Island Platform and Adding a Junction (Also, Turning On the Rain!)

In this fith tutorial, we will finish the track construction necessary to fit the island platform at the second station and also create a simple diverging junction.
For a little light relief, we will also see how to add rain and vary the intensity.

Time to open the route file and get coding…
So, at the moment, we should have a routefile that looks something like this:

We also have a half built pair of diverging curves at the second station (up to location 2 on the diagram below):

Our incomplete island platform

Our incomplete island platform

To regain parallel tracks, we need to introduce a right hand curve on the running rail between locations 2 and 3. A foolproof means of achieving this is to use the same length of curve with an identical radius as was used between locations 1 and 2.

For our running rail, between locations 2 (at 2500m) and 3 (2575m), we need to add the following code.

We must also not forget to change the rail type to that of a 1000m right hand curve(In the ‘with structure’ section of the code we find Rail(12) matches this criteria), and also to revert back to straight track at the end of the curve, so that our second station now looks like this:

Notice that we have yet to specify where the other track (rail 1) will appear – we need to do a bit more maths first, but before that, check the changes made to the running rail were successful by viewing the route.

To calculate the distance between the running rail and the second track, we need to first work out the offsets given by the tangent of the curve at the point which they change direction (given by start of the red line) and then subtract from this the offsets generated by the curves.

While using trigonometry or indeed calculus to work out the offsets of the tangents would be perfectly valid, an alternative method is to use the equation of a circle which we have already used to generate the first set of diverging curves.

Remembering that the initial diverging curves were 75m long and of 1000m metres radius, if we calculate the offsets at 74.5 and 75m and then extend from these two points in a straight line for a further 75m, we will have a close approximation of the tangent shown red in the diagram.

Using x2 + y2 = r2 , the offset of the curve is as follows:

Offset x (m)y (m)

Extending this as a straight line forwards in 25m increments (50 x 0.0374) gives us the offset of the tangent from location 2 on our track diagram (where 0m = location 2);
Offset x (m)y (m)

From the offset of the tangent, we now need to subtract the offset of our curve, which we calculated in our previous tutorial as being:
offset X (m)y

This now gives us the combined offset due to the contribution of one of the tracks only as;
Offset x (m)y (m)

These offsets must be doubled as we have the effects of two tracks to consider and we need to add the offset which already exists at location 2 (9.13m). The results of this calculation are the distance between the running rail and rail (1) between the locations marked 2 and 3 on the track diagram:
Offset x (m)y (m)

We now need to add this to our route code, not forgetting to change the railtype of rail 1 to a 1000m radius left hand curve at the start and to a straight at the end:

We also need to change the railtype of rail 1 at the start of the divergence to a 1000m right hand curve:

The divergence is now complete, ready for inclusion of our island platform. The only problem we have is that the current stop location will leave trains longer than a single carriage stopped on the diverging (curved) part of the track.

Assuming the platform will be built to hold 8 carriages which are typically 20-25m long, it would be good to move the stop position forward by 200 metres. It is also a sensible idea to increase our backward stopping distance tolerance so that we do not always need to run up so near to the end of the platform (when it’s built!). We can make these changes by amending the code controlling our station stop from:


Before we go for a test drive to check our changes have been successful, lets include some rain. This is done using the ‘beacon 21’ command:

.Beacon 21;0;0;n,
Where n is the intensity of the rain and must be in the range 0 (no rain) – 99 (heavy rain).

This code will make it start raining, gently at first, between the first and second stations:

The background we are currently using suggests the weather is bright, so for more realism, this should be changed to include rain clouds – this can be done by editing the background image if desired.

Save the route file and go for a test drive (on my PC rain only shows in full screen mode).

Don’t worry about the objects on the track where the rain changes in intensity – these can be removed later.

Our next job is to re-converge the two tracks after the station. We could go through all the calculations again or simply re-use the distances between the tracks we have already calculated in reverse order. This option is by far the easiest (but does not provide any more practice calculating track positions!).

Taking the easy option, the code we need to add for converging the tracks and changing the rail types and curves as required is as follows:

Notice how this code is essentially the reverse of what we added for the divergence.

If you managed to understand how to construct the track layout required for the island platform, you will have no trouble on the next part-

Constructing a simple double lead diverging junction

The track layout after the second station is to look like this, with the running rail diverging from the straight:

The layout for our diverging junction

The layout for our diverging junction

Here, we need to add 2 additional tracks after location 1 and ensure these head off in a straight line while the running track initially curves away before straightening up. For this junction we will use a curve with a moderately tight radius of 250m.


Making location 1 on the diagram be at 3050m, we can add the curves to the running line and adjacent track (rail 1) by changing our route to look like this at position 3000m, not forgetting to change the rail types:

Now we need to use the equation of a circle to calculate the distances between the running rail and the mainline tracks.

Using x2 + y2 = r2 , the offset of the curve is as follows (taking location 1 on the diagram as 0m):

Offset x (m)y (m)

These distances are valid for the left hand track of the mainline (which we will identify as rail 2), for the right hand track (which we will identify as rail 3), we need to add 3.5m to the offset (as this is the distance separating the two tracks):
Rail 2 Offset x (m)Rail 3 Offset x (m)y (Actual, m)

Using the railstart and rail commands, we can now add code to our route which covers the curved length of the divergence like this:

The next step is to calculate the divergence over the straight section (after location 2 on the track diagram). As with the construction of the layout for the island platform, we need to extend a tangent forward from location 2. The equation of the tangent could be obtained using trigonometry or calculus but a close approximation can be found by calculating the offsets of two points close to the end of our 50m long curve:

Offset x (m)y (m)

For every 0.5 metres we need to increase the offsets of rails 2 and 3 by 0.1m (=5.08m per 25m):
Rail 2 Offset x (m)Rail 3 Offset x (m)y (Actual, m)

We can now add this code to our route manually, or if these calculations are being performed in a spreadsheet, this can be arranged to include all of the commands and separators before being copied and pasted into the route file. Whichever method is used, the code should look like this:

Our final task for this tutorial is to end the rails using the railend command;

Railend n;x;y,
Where n is the rail to be ended, x is the distance in metres to the left (negative) or right (positive) from the running rail,
y is the distance in metres below (negative) or above (positive) from the running rail at the point where the rail is to end.

To end the rails, change this:

To this:

Take a look at the route now and you will see there are a few problems evident.

The line visible straight ahead suddenly ends 200m in front of us as we pass over the points – in practice this can be overcome by extending rails 2 and 3 to for a further 500m. This distance is exceeds the 600m viewing distance of BVE as the straight will still be in our field of view as we round the curve after the points. We can correct this by extending these rails by applying the same principles as have already been used (increasing the offsets of rails 2 and 3 by 5.08m every 25m of route length.

The second problem which is evident are regular gaps occurring in the rails of the straight mainline. This is because the track objects are 25m long but the distance of the straight mainline is greater than 25m for every 25m length travelled on the running line. We can correct this problem by extending the length of the track object used on the straight mainline.

The final problem to overcome is that where the tracks diverge, we need to include pointwork to divert our train in the correct direction.

In the next tutorial, we add code to extend the ‘disappearing‘ rails, modify a track object to remove the gaps and also add pointwork. For more realistic running, speed limits will also be introduced.

Leave a Reply

Your email address will not be published. Required fields are marked *