## 2 Materials and Methods  
A method of calculating the soil slope through a given point is being introduced. The input data are: the level curves, in Figure 1, the two level curves located at elevation 610 and, respectively, 620, and the 2D coordinates of a point Q on the topographic map. The direction of the Ox axis is considered from west to east, the direction of the Oy axis is south-north. The output is the slope calculated at point Q. The slope can be determined using two other points collinear with Q for which the elevation is known. The points on the map for which the elevation is known are located on level curves. Therefore, it is enough to find two points collinear with Q located on two different level curves. Of course, for accuracy reasons, it is preferable that Q is located between these 2 points and the distance between the chosen 2 points is minimum. Consequently, the problem can be accurately solved if we determine the closest two level curves to Q (Q is located in between these curves) and two points P1 and P2, each located on one of the level curves, and the distance between P1 and P2 is minimum (see Figure 1). Since a level curve is approximated with consecutive coplanar segments of straight lines, our problem can be reduced to finding the shortest length segment \(\left|\text{P}_{1}\text{P}_{2}\right|\) that connects two coplanar line segments located on two consecutive level curves. When the two 2D points P1(x1,y1) and P2(x2,y2) are determined, they are transformed into 3D points by adding the elevations z1 and, respectively, z2 of the level curves on which each of the points are located. Using the 3D coordinates of these 2 points, the slope m = tan(\(\alpha\)) at point Q (see Figure 2) can be calculated as follows:  
\[\left\{ \begin{array}{c}\text{m }=\ \frac{\left|\text{z}_{2}-\text{z}_{1} \right|}{\sqrt{\left(\text{z}_{2}-\text{x}_{1}\right)^{2}+\left(\text{y}_{2}- \text{y}_{1}\right)^{2}}}\\ \alpha\ =\ \text{atan2}\bigg{(}\left|\text{z}_{2}-\text{z}_{1}\right|,\sqrt{ \left(\text{z}_{2}-\text{x}_{1}\right)^{2}+\left(\text{y}_{2}-\text{y}_{1} \right)^{2}}\bigg{)}\end{array} \right. \tag{1}\]  
Figure 1: Finding the slope at a point using level curves. The first problem (denoted IPS) intended to be solved is to identify the pair of segments (located on two level curves) to which the finding of the shortest length segment should be applied. Of course, for each of the two level curves, the candidates are the closest segments to point Q. Let us denote by \(S_{i}\) the set of candidates (segments) for curve i (i = 1, 2). For each pair of segments \(s_{1}\in S_{1}\) and \(s_{2}\in S_{2}\), respectively, the corresponding shortest length segment [P\({}_{1}\)P\({}_{2}\)] between \(s_{1}\) and \(s_{2}\) is calculated. If \(s_{1}\) contains P\({}_{1}\) and \(s_{2}\) contains P\({}_{2}\), then the pair (\(s_{1},s_{2}\)) is added to the set (denoted C) of solution candidates for IPS (Figure 3). The set \(S_{i}\) (i = 1, 2) can be built as follows: first, we find the point T belonging to the level curve i that is closest to Q. We consider then k \(\geq\) 1 points (L\({}_{1}\), L\({}_{2}\),..., L\({}_{k}\)) to the left of T on the level curve and k points (R\({}_{1}\), R\({}_{2}\),..., R\({}_{k}\)) located to right (see Figure 4). Finally, the set \(S_{i}\) consists of 2k segments of straight lines given by the consecutive points on the level curve i: L\({}_{k}\), L\({}_{k-1}\),..., L\({}_{1}\), T, R\({}_{1}\), R\({}_{2}\),..., R\({}_{k}\), i.e. :  
\[S_{i}\ =\ \{[L_{h+1}L_{h}]\,|h\ =\ 1,2,\ldots,k-1\}\cup\ \{[L_{1}T],[TR_{1}]\} \cup\ \{[R_{h}R_{h+1}]\,|h\ =\ 1,2,\ldots,k-1\} \tag{2}\]  
Now, let us see how k (giving the number of points in the vicinity of T) is considered. Usually (in real tests), k is enough to be 1. In few cases k is found to be greater. So, the calculations are started with k = 1 and, if necessary, it is increased. The Algorithm 1 for solving IPS (denoted AIPS) is:  
Figure 3: Finding the closest line segments to Q.  
Figure 2: Determining the slope at Q using P\({}_{1}\) and P\({}_{2}\).