slope_matrix function

Calculate the gradient of line segments from a 3D matrix of coordinates