mirror of
https://github.com/3b1b/manim.git
synced 2025-11-14 15:17:46 +00:00
commit
764dec20eb
4 changed files with 14 additions and 10 deletions
|
|
@ -347,7 +347,7 @@ class Circle(Arc):
|
||||||
def point_at_angle(self, angle: float) -> np.ndarray:
|
def point_at_angle(self, angle: float) -> np.ndarray:
|
||||||
start_angle = self.get_start_angle()
|
start_angle = self.get_start_angle()
|
||||||
return self.point_from_proportion(
|
return self.point_from_proportion(
|
||||||
(angle - start_angle) / TAU
|
((angle - start_angle) % TAU) / TAU
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_radius(self) -> float:
|
def get_radius(self) -> float:
|
||||||
|
|
|
||||||
|
|
@ -94,15 +94,12 @@ class Matrix(VMobject):
|
||||||
or mobjects
|
or mobjects
|
||||||
"""
|
"""
|
||||||
VMobject.__init__(self, **kwargs)
|
VMobject.__init__(self, **kwargs)
|
||||||
matrix = self.matrix = np.array(matrix, ndmin=2)
|
mob_matrix = self.mob_matrix = self.matrix_to_mob_matrix(matrix)
|
||||||
mob_matrix = self.matrix_to_mob_matrix(matrix)
|
|
||||||
self.organize_mob_matrix(mob_matrix)
|
self.organize_mob_matrix(mob_matrix)
|
||||||
# self.elements = VGroup(*mob_matrix.flatten())
|
|
||||||
self.elements = VGroup(*it.chain(*mob_matrix))
|
self.elements = VGroup(*it.chain(*mob_matrix))
|
||||||
self.add(self.elements)
|
self.add(self.elements)
|
||||||
self.add_brackets()
|
self.add_brackets()
|
||||||
self.center()
|
self.center()
|
||||||
self.mob_matrix = mob_matrix
|
|
||||||
if self.add_background_rectangles_to_entries:
|
if self.add_background_rectangles_to_entries:
|
||||||
for mob in self.elements:
|
for mob in self.elements:
|
||||||
mob.add_background_rectangle()
|
mob.add_background_rectangle()
|
||||||
|
|
@ -129,7 +126,7 @@ class Matrix(VMobject):
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def add_brackets(self):
|
def add_brackets(self):
|
||||||
height = self.matrix.shape[0]
|
height = len(self.mob_matrix)
|
||||||
bracket_pair = Tex("".join([
|
bracket_pair = Tex("".join([
|
||||||
"\\left[",
|
"\\left[",
|
||||||
"\\begin{array}{c}",
|
"\\begin{array}{c}",
|
||||||
|
|
|
||||||
|
|
@ -627,7 +627,7 @@ class Mobject(object):
|
||||||
mobject = pickle.load(fp)
|
mobject = pickle.load(fp)
|
||||||
return mobject
|
return mobject
|
||||||
|
|
||||||
def become(self, mobject: Mobject):
|
def become(self, mobject: Mobject, match_updaters=False):
|
||||||
"""
|
"""
|
||||||
Edit all data and submobjects to be idential
|
Edit all data and submobjects to be idential
|
||||||
to another mobject
|
to another mobject
|
||||||
|
|
@ -647,7 +647,8 @@ class Mobject(object):
|
||||||
if isinstance(value, Mobject) and value in family2:
|
if isinstance(value, Mobject) and value in family2:
|
||||||
setattr(self, attr, family1[family2.index(value)])
|
setattr(self, attr, family1[family2.index(value)])
|
||||||
self.refresh_bounding_box(recurse_down=True)
|
self.refresh_bounding_box(recurse_down=True)
|
||||||
self.match_updaters(mobject)
|
if match_updaters:
|
||||||
|
self.match_updaters(mobject)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def looks_identical(self, mobject: Mobject):
|
def looks_identical(self, mobject: Mobject):
|
||||||
|
|
@ -1265,7 +1266,10 @@ class Mobject(object):
|
||||||
return self.data["rgbas"][0, 3]
|
return self.data["rgbas"][0, 3]
|
||||||
|
|
||||||
def set_color_by_gradient(self, *colors: ManimColor):
|
def set_color_by_gradient(self, *colors: ManimColor):
|
||||||
self.set_submobject_colors_by_gradient(*colors)
|
if self.has_points():
|
||||||
|
self.set_color(colors)
|
||||||
|
else:
|
||||||
|
self.set_submobject_colors_by_gradient(*colors)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def set_submobject_colors_by_gradient(self, *colors: ManimColor):
|
def set_submobject_colors_by_gradient(self, *colors: ManimColor):
|
||||||
|
|
|
||||||
|
|
@ -294,7 +294,10 @@ def find_intersection(
|
||||||
denom[abs(denom) < threshold] = np.inf # So that ratio goes to 0 there
|
denom[abs(denom) < threshold] = np.inf # So that ratio goes to 0 there
|
||||||
ratio = numer / denom
|
ratio = numer / denom
|
||||||
ratio = np.repeat(ratio, n).reshape((m, n))
|
ratio = np.repeat(ratio, n).reshape((m, n))
|
||||||
return p0 + ratio * v0
|
result = p0 + ratio * v0
|
||||||
|
if m == 1:
|
||||||
|
return result[0]
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
def get_closest_point_on_line(
|
def get_closest_point_on_line(
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue