pick a model for your lines. piecewise linear? spline? bezier? …?
the model should support “nearest point on the line” queries, or it should be able to give you a Y value, given an X value. if you picked “piecewise linear”, both of those things are easy to calculate.
now define each line from points.
then either
- walk along the lines (increasing X values), get the Y values, and calculate vertical distance
- walk along one line (arbitrarily, perhaps as a function of path length), and then query the other line for its nearest point, then consider that distance