## 2 Materials and Methods
### Determination of the Movement Direction  
In our previous work, we did not include the determination of the movement direction of the train into our system; thus the train was always moving in the same direction. In the here-discussed advanced system, we show that also the movement direction determination can be realized as an additional task by the means of VLS. As already indicated in Figure 1, the moving object can now have two moving directions, Forward and Backward.  
In order to realize a direction determination procedure of low complexity, we devised the solution approach to exploit the reflections from the ME in combination with the given overall train setup. As shown in Figure 4a,b, the acquired reflections from the ME are unambiguously clearly observable in the acquired output values of the three color channels. Furthermore, we can also see that the acquired outputs of the color channels are almost symmetrical. This symmetry is the main starting point for our solution approach. Depending on the movement direction, we can observe that there is a transition phase for the example when the train is moving Forward, where first only the reflections from the environment are acquired, followed by the clear and steep flanks from the ME element and then the reflections from the main body of the train. As shown in Figure 6, this effect is also clearly present, independent of the circumstance of whether there is a retroreflective foil placed on the train or not. When the train is moving Backward, the described sequence is exactly the other way around, first reflections from the main body, then the ME element followed by the reflections from the environment, since the train has left the detection area of the VLS unit.  
In order to exploit this fact, we implemented a movement direction determination process. At first, a self-developed algorithm determines the positions in terms of sample numbers of the two flanks \"caused\" by the ME. In the following, we name them Flank 1 and Flank 2. Flank 1 (falling flank) occurs when the ME enters the main detection area of  
Figure 6: Output of the VLS unit color channels (V) in the scenario of 3M green Area 4 Speed 3 moving in the Forward direction.  
the VLS unit and Flank 2 when the ME leaves it. The algorithm is based on building the difference from one sample (sample number n) to the sample with the sample number n + 50. A negative difference yields a falling flank and a positive difference value a rising flank. From this simple algorithm, we follow that the lowest negative difference indicates the steepest part of the falling flank, and the highest positive difference value indicates the steepest part of the rising flank. Once these minimum and maximum values are found, the corresponding sample numbers are consequently defined as the positions of Flank 1 and Flank 2. From the positions of these two flanks, we now calculate the mean values of the red color channel of 10,000 samples before Flank 1 and 10,000 samples after Flank 2. These two mean values are hereafter referred to as Mean_Flank1 and Mean_Flank2. For a simpler graphic explanation, please see Figure 7, where we show Flank 1 and Flank 2 (dotted black lines) as well as the periods for the calculations of Mean_Flank1 and Mean_Flank2 (labeled greyish areas) for the red channel of the data used for Figure 4a, in a zoomed-in view.  
With the calculated values of Mean_Flank1 and Mean_Flank2, and a simple if statement, the direction can be determined. If the value Mean_Flank1 is larger than Mean_Flank2 (as depicted in Figure 7), the train is moving in the Forward direction. If Mean_Flank2 is larger than Mean_Flank1, then the movement direction is Backward. This simple method of determining the movement direction could be applied for all three color channels, but in order to reduce the computational effort, we only perform the flank determination and the calculation of Mean_Flank1 and Mean_Flank2 for the red channel.