Make input_to_graph_point always use a binary search, since graph's have uneven density now

This commit is contained in:
Grant Sanderson 2020-02-23 22:56:50 +00:00
parent da8dc4ea03
commit 26dccfe9a7

View file

@ -108,13 +108,10 @@ class CoordinateSystem():
return graph return graph
def input_to_graph_point(self, x, graph): def input_to_graph_point(self, x, graph):
if hasattr(graph, "underlying_function"):
return self.coords_to_point(x, graph.underlying_function(x))
else:
alpha = binary_search( alpha = binary_search(
function=lambda a: self.point_to_coords( function=lambda a: self.x_axis.p2n(
graph.point_from_proportion(a) graph.point_from_proportion(a)
)[0], ),
target=x, target=x,
lower_bound=self.x_min, lower_bound=self.x_min,
upper_bound=self.x_max, upper_bound=self.x_max,