code: public static double interpolate(Coordinate firstCoordinate, Coordinate lastCoordinate, Coordinate toBeInterpolated) {
          if (Double.isNaN(firstCoordinate.z)) {
              return Double.NaN;
          }
          if (Double.isNaN(lastCoordinate.z)) {
              return Double.NaN;
          }
          return firstCoordinate.z + (lastCoordinate.z - firstCoordinate.z) * firstCoordinate.distance(toBeInterpolated)
                  / (firstCoordinate.distance(toBeInterpolated) + toBeInterpolated.distance(lastCoordinate));
      }
docs: Interpolates a z value (linearly) between the two coordinates.
  
  @param firstCoordinate
  @param lastCoordinate
  @param toBeInterpolated
  @return