# An Open-Source Algorithm for 3D ROck Slope Kinematic Analysis (ROKA)
## 2 The ROck Slope Kinematic Analysis (ROKA) Algorithm  
The stability of the rock slopes is frequently controlled by the discontinuities affecting the rock mass. In such cases, the geometrical relationships between the structures and the slope's orientation determine the kinematic stability of the slope. Kinematic Analysis (KA) refers to the geometrically possible motion of blocks of rock without considering the forces involved but evaluating the allowed and constrained directions of movement.  
Thanks to its simplicity and speed, the KA of a rock slope is generally used to assess whether masses of rock may move along geologic structures and slide down a slope. In particular, it can be used to evaluate four principal modes of potential sliding, which are also called Modes of Failure (MOFs): plane failure, wedge failure, flexural toppling, and direct toppling.  
As already described, the traditional KA has some limitations, such as the impossibility of considering different slope orientations and taking into account the dimensions and positions of the rock discontinuities.  
Here, we present an algorithm called ROck slope Kinematic Analysis (ROKA) and written in MATLAB language that is able to overcome these limits performing an ad hoc Kinematic Analysis (KA) of the possible Modes of Failure (MOFs) of each differently oriented part of a rock slope, considering only the discontinuities really measured onto the DOM, even if it is characterized by a complex geometry (i.e., considering all the different local orientations of the slope).  
This code calculates the criticality of the discontinuities in a deterministic way, correlating their measured position, attitude, and size with the slope's local orientation and determining for every fracture the potential MOFs (planar failure, wedge failure, flexural toppling, and direct toppling).  
ROKA has been organized into four main stages (Figure 1):  
1. Preparation and definition of the input data (described in Section 2.2), which essentially consists of the point cloud representing the slope, the geometric information of the discontinuities, and the calculation of the variables (slope-discontinuity intersection cutoff, scan-radius, friction angle, and lateral limits);
2. Preprocessing calculation to obtain the geometrical information of the real intersections between the discontinuities, described in Section 2.3. This step is fundamental for the KA of the wedge failure and direct toppling MOFs;
3. Ad hoc KA described in Section 2.4, which represents the main core of the algorithm. After the two previous phases, the KA is performed in each position of the rock slope considering its local orientation (calculated using the scan-radius) and the discontinuities that really intersect the rock slope in the analyzed sector;
4. Exportation of the results (potentially unstable discontinuities and portions of the rock slope) and their visualization in the open-source software Cloud Compare (Section 2.5); Cloud Compare is a 3D rendering environment where the 3D point cloud and meshes representing the rock slope can be visualized, and \"virtual\" discontinuity surfaces or traces can be measured [23].