利用者:Beneficii

For this one, choose either x1 and m1 or x2 and m2 to substitute in for x and m and of course the positive result is what you want:

From this, knowing 2 points and h and r, deriving k should be easy.