mirror of
https://github.com/3b1b/manim.git
synced 2025-09-01 00:48:45 +00:00
Make input_to_graph_point always use a binary search, since graph's have uneven density now
This commit is contained in:
parent
da8dc4ea03
commit
26dccfe9a7
1 changed files with 11 additions and 14 deletions
|
@ -108,21 +108,18 @@ class CoordinateSystem():
|
|||
return graph
|
||||
|
||||
def input_to_graph_point(self, x, graph):
|
||||
if hasattr(graph, "underlying_function"):
|
||||
return self.coords_to_point(x, graph.underlying_function(x))
|
||||
alpha = binary_search(
|
||||
function=lambda a: self.x_axis.p2n(
|
||||
graph.point_from_proportion(a)
|
||||
),
|
||||
target=x,
|
||||
lower_bound=self.x_min,
|
||||
upper_bound=self.x_max,
|
||||
)
|
||||
if alpha is not None:
|
||||
return graph.point_from_proportion(alpha)
|
||||
else:
|
||||
alpha = binary_search(
|
||||
function=lambda a: self.point_to_coords(
|
||||
graph.point_from_proportion(a)
|
||||
)[0],
|
||||
target=x,
|
||||
lower_bound=self.x_min,
|
||||
upper_bound=self.x_max,
|
||||
)
|
||||
if alpha is not None:
|
||||
return graph.point_from_proportion(alpha)
|
||||
else:
|
||||
return None
|
||||
return None
|
||||
|
||||
|
||||
class Axes(VGroup, CoordinateSystem):
|
||||
|
|
Loading…
Add table
Reference in a new issue