mirror of
https://github.com/3b1b/manim.git
synced 2025-08-02 11:03:03 +08:00
added synonym for number line labels
This commit is contained in:
@ -120,6 +120,9 @@ class NumberLine(VMobject):
|
|||||||
result.add(mob)
|
result.add(mob)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
def get_labels(self):
|
||||||
|
return self.get_number_mobjects()
|
||||||
|
|
||||||
def add_numbers(self, *numbers, **kwargs):
|
def add_numbers(self, *numbers, **kwargs):
|
||||||
self.numbers = self.get_number_mobjects(
|
self.numbers = self.get_number_mobjects(
|
||||||
*numbers, **kwargs
|
*numbers, **kwargs
|
||||||
@ -219,29 +222,7 @@ class Axes(VGroup):
|
|||||||
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))
|
||||||
return self.coords_to_point(x, graph.underlying_function(x))
|
|
||||||
else:
|
|
||||||
#binary search
|
|
||||||
lh, rh = 0, 1
|
|
||||||
while abs(lh - rh) > 0.001:
|
|
||||||
mh = np.mean([lh, rh])
|
|
||||||
hands = [lh, mh, rh]
|
|
||||||
points = map(graph.point_from_proportion, hands)
|
|
||||||
lx, mx, rx = map(self.x_axis.point_to_number, points)
|
|
||||||
if lx <= x and rx >= x:
|
|
||||||
if mx > x:
|
|
||||||
rh = mh
|
|
||||||
else:
|
|
||||||
lh = mh
|
|
||||||
elif lx <= x and rx <= x:
|
|
||||||
return points[2]
|
|
||||||
elif lx >= x and rx >= x:
|
|
||||||
return points[0]
|
|
||||||
elif lx > x and rx < x:
|
|
||||||
lh, rh = rh, lh
|
|
||||||
return points[1]
|
|
||||||
|
|
||||||
|
|
||||||
class ThreeDAxes(Axes):
|
class ThreeDAxes(Axes):
|
||||||
CONFIG = {
|
CONFIG = {
|
||||||
|
Reference in New Issue
Block a user