def scale(v: float, a: float, b: float, c: float, d: float) -> float:
  """Scale a value, v on a line with anchor points a,b to new anchors c,d."""
  v01 = (v - a) / (b - a)
  return c - v01 * (c - d)