get_critical_point -> get_bounding_box_point

This commit is contained in:
Grant Sanderson 2020-02-13 10:54:09 -08:00
parent 176079b678
commit 574b464a3c
6 changed files with 17 additions and 17 deletions

View file

@ -3905,7 +3905,7 @@ class RandomnessVsProportions(Scene):
arrangements = VGroup(*[ arrangements = VGroup(*[
VGroup(*[ VGroup(*[
dot.copy().move_to(square.get_critical_point(ec)) dot.copy().move_to(square.get_bounding_box_point(ec))
for ec in edge_group for ec in edge_group
]) ])
for edge_group in edge_groups for edge_group in edge_groups

View file

@ -841,7 +841,7 @@ class Test(Scene):
arcs = VGroup(arc1, arc2) arcs = VGroup(arc1, arc2)
for arc, vect in zip(arcs, [DOWN+RIGHT, RIGHT]): for arc, vect in zip(arcs, [DOWN+RIGHT, RIGHT]):
arc_copy = arc.copy() arc_copy = arc.copy()
point = domino1.get_critical_point(vect) point = domino1.get_bounding_box_point(vect)
arc_copy.add_line_to([point]) arc_copy.add_line_to([point])
arc_copy.set_stroke(width = 0) arc_copy.set_stroke(width = 0)
arc_copy.set_fill( arc_copy.set_fill(

View file

@ -1280,7 +1280,7 @@ class EndpointsGluedTogether(ClosedLoopScene):
self.loop = line self.loop = line
dots = VGroup(*[ dots = VGroup(*[
Dot(line.get_critical_point(vect)) Dot(line.get_bounding_box_point(vect))
for vect in (LEFT, RIGHT) for vect in (LEFT, RIGHT)
]) ])
dots.set_color(BLUE) dots.set_color(BLUE)

View file

@ -32,7 +32,7 @@ class GrowFromCenter(GrowFromPoint):
class GrowFromEdge(GrowFromPoint): class GrowFromEdge(GrowFromPoint):
def __init__(self, mobject, edge, **kwargs): def __init__(self, mobject, edge, **kwargs):
point = mobject.get_critical_point(edge) point = mobject.get_bounding_box_point(edge)
super().__init__(mobject, point, **kwargs) super().__init__(mobject, point, **kwargs)

View file

@ -361,7 +361,7 @@ class Mobject(Container):
if about_point is None: if about_point is None:
if about_edge is None: if about_edge is None:
about_edge = ORIGIN about_edge = ORIGIN
about_point = self.get_critical_point(about_edge) about_point = self.get_bounding_box_point(about_edge)
for mob in self.family_members_with_points(): for mob in self.family_members_with_points():
mob.points -= about_point mob.points -= about_point
mob.points = func(mob.points) mob.points = func(mob.points)
@ -396,7 +396,7 @@ class Mobject(Container):
corner in the 2d plane. corner in the 2d plane.
""" """
target_point = np.sign(direction) * (FRAME_X_RADIUS, FRAME_Y_RADIUS, 0) target_point = np.sign(direction) * (FRAME_X_RADIUS, FRAME_Y_RADIUS, 0)
point_to_align = self.get_critical_point(direction) point_to_align = self.get_bounding_box_point(direction)
shift_val = target_point - point_to_align - buff * np.array(direction) shift_val = target_point - point_to_align - buff * np.array(direction)
shift_val = shift_val * abs(np.sign(direction)) shift_val = shift_val * abs(np.sign(direction))
self.shift(shift_val) self.shift(shift_val)
@ -422,7 +422,7 @@ class Mobject(Container):
target_aligner = mob[index_of_submobject_to_align] target_aligner = mob[index_of_submobject_to_align]
else: else:
target_aligner = mob target_aligner = mob
target_point = target_aligner.get_critical_point( target_point = target_aligner.get_bounding_box_point(
aligned_edge + direction aligned_edge + direction
) )
else: else:
@ -433,7 +433,7 @@ class Mobject(Container):
aligner = self[index_of_submobject_to_align] aligner = self[index_of_submobject_to_align]
else: else:
aligner = self aligner = self
point_to_align = aligner.get_critical_point(aligned_edge - direction) point_to_align = aligner.get_bounding_box_point(aligned_edge - direction)
self.shift((target_point - point_to_align + self.shift((target_point - point_to_align +
buff * direction) * coor_mask) buff * direction) * coor_mask)
return self return self
@ -520,10 +520,10 @@ class Mobject(Container):
def move_to(self, point_or_mobject, aligned_edge=ORIGIN, def move_to(self, point_or_mobject, aligned_edge=ORIGIN,
coor_mask=np.array([1, 1, 1])): coor_mask=np.array([1, 1, 1])):
if isinstance(point_or_mobject, Mobject): if isinstance(point_or_mobject, Mobject):
target = point_or_mobject.get_critical_point(aligned_edge) target = point_or_mobject.get_bounding_box_point(aligned_edge)
else: else:
target = point_or_mobject target = point_or_mobject
point_to_align = self.get_critical_point(aligned_edge) point_to_align = self.get_bounding_box_point(aligned_edge)
self.shift((target - point_to_align) * coor_mask) self.shift((target - point_to_align) * coor_mask)
return self return self
@ -733,7 +733,7 @@ class Mobject(Container):
else: else:
return np.max(values) return np.max(values)
def get_critical_point(self, direction): def get_bounding_box_point(self, direction):
""" """
Picture a box bounding the mobject. Such a box has Picture a box bounding the mobject. Such a box has
9 'critical points': 4 corners, 4 edge center, the 9 'critical points': 4 corners, 4 edge center, the
@ -749,16 +749,16 @@ class Mobject(Container):
) )
return result return result
# Pseudonyms for more general get_critical_point method # Pseudonyms for more general get_bounding_box_point method
def get_edge_center(self, direction): def get_edge_center(self, direction):
return self.get_critical_point(direction) return self.get_bounding_box_point(direction)
def get_corner(self, direction): def get_corner(self, direction):
return self.get_critical_point(direction) return self.get_bounding_box_point(direction)
def get_center(self): def get_center(self):
return self.get_critical_point(np.zeros(self.dim)) return self.get_bounding_box_point(np.zeros(self.dim))
def get_center_of_mass(self): def get_center_of_mass(self):
return np.apply_along_axis(np.mean, 0, self.get_all_points()) return np.apply_along_axis(np.mean, 0, self.get_all_points())
@ -901,7 +901,7 @@ class Mobject(Container):
the center of mob2 the center of mob2
""" """
if isinstance(mobject_or_point, Mobject): if isinstance(mobject_or_point, Mobject):
point = mobject_or_point.get_critical_point(direction) point = mobject_or_point.get_bounding_box_point(direction)
else: else:
point = mobject_or_point point = mobject_or_point

View file

@ -467,7 +467,7 @@ class Bubble(SVGMobject):
can_flip = not self.direction_was_specified can_flip = not self.direction_was_specified
if want_to_flip and can_flip: if want_to_flip and can_flip:
self.flip() self.flip()
boundary_point = mobject.get_critical_point(UP - self.direction) boundary_point = mobject.get_bounding_box_point(UP - self.direction)
vector_from_center = 1.0 * (boundary_point - mob_center) vector_from_center = 1.0 * (boundary_point - mob_center)
self.move_tip_to(mob_center + vector_from_center) self.move_tip_to(mob_center + vector_from_center)
return self return self