mirror of
https://github.com/3b1b/manim.git
synced 2025-07-28 20:43:56 +08:00
Add Mobject.has_same_shape_as
This commit is contained in:
@ -671,6 +671,16 @@ class Mobject(object):
|
||||
return False
|
||||
return True
|
||||
|
||||
def has_same_shape_as(self, mobject: Mobject) -> bool:
|
||||
# Normalize both point sets by centering and making height 1
|
||||
points1, points2 = (
|
||||
(m.get_all_points() - m.get_center()) / m.get_height()
|
||||
for m in (self, mobject)
|
||||
)
|
||||
if len(points1) != len(points2):
|
||||
return False
|
||||
return bool(np.isclose(points1, points2).all())
|
||||
|
||||
# Creating new Mobjects from this one
|
||||
|
||||
def replicate(self, n: int) -> Group:
|
||||
|
Reference in New Issue
Block a user