to_x = int(round(((distXmid + bandlength / 2.0) * res).magnitude))