fit curve between two points